PLM之家PLMHome-工业软件与AI结合践行者

[二次开发源码] NX二次开发源码分享: 创建精确外轮廓

[复制链接]

2019-1-17 10:56:35 2191 0

admin 发表于 2019-1-17 10:56:35 |阅读模式

admin 楼主

2019-1-17 10:56:35

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
NX二次开发源码分享: 创建精确外轮廓
9 B* l) I, \* `1 @
& D% b# {- k- ]* w6 ~UF_CURVE_create_shadow_outline (view source)
0 G% M5 F0 \% v. _% s( C
, H; Y  m) h/ ]: B7 s: k$ a2 q% H( tDefined in: uf_curve.h0 Z/ c2 K6 D0 k8 r
4 `5 y' z( T2 G5 D. I

8 k, ~2 q+ S' k! ]Overview8 N0 X7 S! n: D% ^
( @3 p! X4 j# f  g
Create shadow outline for a given array of solids. Solids passed to this 1 D# ^$ O- i/ n; @* F: D3 C
routine must be on a selectable layer and visible. If created shadow curves 4 }1 x) t1 V: y7 \9 w
can not form loops, please use UF_CURVE_create_shadow_curves instead to get ! X6 w) Q0 q! S$ f1 T* _
shadow curves.
8 V3 p% B- w" P9 B4 {# n7 x0 N. O7 A

. J: {  T2 x9 E7 t# O5 O! a; N& S' _[hide]
4 R0 t0 d3 o8 R) J% [: v* V, t" @9 ]
, W* ]0 R, ~1 u; \3 Y$ d[mw_shl_code=csharp,true] void DoIt()4 D8 u3 v0 C/ S
    {
" p( e6 g& W. A' R; C        if (theSession.Parts.Display != theSession.Parts.Work)
% d: Z" e5 Z) B- Y, O- [0 D            theSession.Parts.SetWork(theSession.Parts.Display);
& ~* a9 U1 t, M. i) M$ F9 F; m3 f/ e0 G9 ^
  z! i! a9 C0 b) }
        TaggedObject[] theBodies = null;
( M# D/ y2 o$ @% A* W. `  _        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
( S, [5 |( b7 z; A& q        {. T" d) v" q' N
            Echo("Selected Bodies: " + theBodies.Length.ToString());* y6 g8 k5 e4 {+ b2 j# ?
            Tag[] theBodyTags = new Tag[theBodies.Length];+ Z& ~3 |8 P0 b- ?
            for (int ii = 0; ii < theBodies.Length; ii++)7 V+ b1 E  X" V- m/ b$ ]
                theBodyTags[ii] = theBodies[ii].Tag;$ S& M9 l+ ~" S, N, s
- _; F; ]; e7 l' @
            List<Curve> theOutlineCurves = new List<Curve>();
$ e8 A+ k$ I/ [* j$ ?$ P            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. E& u& M6 \9 v+ b9 a1 n            int loop_count;
6 \, j, G) L1 C' V% W4 e$ U& e3 W, |- l            int[] count_array;
. v( Q1 P0 r5 _; M+ g            Tag[][] curve_array = null;2 v) u; `9 P/ S2 T/ I. f
            double[] tol = new double[2];
9 K6 q# g  c8 u) l) b+ _+ l1 |% i4 x* b3 V4 `
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
1 l! [% [2 w& ]            theUFSession.Modl.AskAngleTolerance(out tol[1]);
0 h4 A( z' z* K9 I3 j, M. N8 w# _5 ?- Q
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
' J2 T* X% _: _0 o0 c1 w                workView.Tag, out loop_count, out count_array, out curve_array, tol);
& W4 H* f% j& Z4 h! \" Q2 O) ^0 a6 q8 G6 z: H9 g
            Echo("Precise Outline Loops: " + loop_count.ToString());  ]- l# Y; \$ m: W+ h6 ]4 l7 [
            for (int ii = 0; ii < loop_count; ii++); H  e9 D( e  X* `# q! K8 J
                for (int jj = 0; jj < count_array[ii]; jj++)8 h5 n; e: o5 B
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
9 @) P8 o' c4 W( f) T. E7 u1 D            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
9 b7 X; P- M  B& R6 x* F' x& h
4 b2 S' Q6 u! ^5 q            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 8 h9 @) g' S3 T$ ]1 ?+ W9 Y
            int curve_count;
8 w  W7 |4 n/ E, \! j            Tag[] outline_curves = null;! H, |2 s+ v6 l2 [. u
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, ) x5 ?$ Z, N* q& T3 G
                workView.Tag, out curve_count, out outline_curves);
; `2 T, `! D* z            Echo("Precise Outline Curves: " + curve_count.ToString());
7 A" S6 L' f6 R- z7 ~            */
1 y, n2 |8 ?" u% L; n        }
/ F. e* h, }- R( w# D4 E
$ v$ k2 I6 u+ D; {; @    }[/mw_shl_code]" ?+ u/ v  f  p. j8 ?( V
[/hide]
! d5 J$ c: h. P* J
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了