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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
2 j4 r, y& B3 g, b/ h; |: C8 \( i8 w# \. \
UF_CURVE_create_shadow_outline (view source): G! y) V0 S, y) C

; C- D8 \& N7 A. mDefined in: uf_curve.h3 p" }3 H4 m+ Q# L6 H' d1 R, ]  y7 Z
. R" H# c5 A+ g+ X/ x+ H  }" ^

! [! D0 Z6 l0 f- D% L" tOverview; S4 w; {- Q5 I. H

- W* i4 W* r( BCreate shadow outline for a given array of solids. Solids passed to this ; y: o" w. O0 P5 X, [; ]5 l
routine must be on a selectable layer and visible. If created shadow curves * [3 }# T$ w4 z4 ~: O5 f
can not form loops, please use UF_CURVE_create_shadow_curves instead to get " f# N3 x4 w9 Y
shadow curves.
" B2 E) P7 o+ x/ Q5 @. ^9 e+ R5 B9 X$ f+ `* W

) J) K1 Y7 [* X4 l2 [$ ?6 i[hide]5 Z& @/ x6 D" E( o

: d8 A9 k' I2 i1 q) c2 E4 D[mw_shl_code=csharp,true] void DoIt()5 F; w# |; V( n% Q: o5 |
    {/ ?/ t8 }/ @; F
        if (theSession.Parts.Display != theSession.Parts.Work)
- A5 p- Q) g1 D% D* k            theSession.Parts.SetWork(theSession.Parts.Display);
! }2 V7 N- |+ m9 ], H* {  K7 Q4 @9 o7 b% x3 M* U4 r

9 [2 {* `# A2 S4 \5 \! o        TaggedObject[] theBodies = null;7 v) H* a. O9 M) g. l
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
3 F  R3 [4 s4 }/ ?9 C! u        {4 K6 E& i/ x( P; @3 A
            Echo("Selected Bodies: " + theBodies.Length.ToString());  B7 A8 }7 Q& q2 Y7 W7 [$ f: W, C
            Tag[] theBodyTags = new Tag[theBodies.Length];
* b- V, Y6 y7 h: u5 |0 L( t            for (int ii = 0; ii < theBodies.Length; ii++)
) _7 u& f) d& F3 b! y+ o5 X& \                theBodyTags[ii] = theBodies[ii].Tag;8 O9 v0 \# W6 v6 w; R
2 ]% P6 @8 K% X+ K& p. ^+ c: R5 j
            List<Curve> theOutlineCurves = new List<Curve>();3 G# ]$ F4 @* I) \# w. H! z9 D" A
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;- ?1 S2 Y6 M$ c; {* u2 D; ]. z$ a
            int loop_count;- {" b9 V  G" A$ [$ [
            int[] count_array;1 \8 Q7 U/ O, `# B
            Tag[][] curve_array = null;
1 m6 @, {% b7 q4 h7 `7 M            double[] tol = new double[2];
" j9 z8 {6 W! N" G3 T8 L% W
* S1 t& B) `) E/ j  A* a/ f            theUFSession.Modl.AskDistanceTolerance(out tol[0]);! R2 G* S& W5 i
            theUFSession.Modl.AskAngleTolerance(out tol[1]);/ G7 F! ]2 l/ K6 j; x7 L

/ Z5 J( y5 c4 ^8 p8 o) z. w7 H            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,# C/ m' u: }, q8 g) m  l6 B
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
$ A4 E% I5 L& H6 n& w6 P
# F. G- o" C) x' T) u0 M; ?/ v$ R- |            Echo("Precise Outline Loops: " + loop_count.ToString());
) \  D& o' R3 H0 X7 C0 [2 g% g4 z            for (int ii = 0; ii < loop_count; ii++)
2 c1 }: K! E2 Z: e% k                for (int jj = 0; jj < count_array[ii]; jj++)
* t, G3 ^% c; b5 P                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));, m* V8 H/ S8 G7 p
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());  Y3 r4 `' V  f% R9 [1 O1 A: C

7 ?1 k# s# D. b) i- v% l            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
! ]% ?0 N- r( S+ i  Z2 f2 O+ r- u            int curve_count;- E# i$ W1 Z& E. Y0 n8 y, h
            Tag[] outline_curves = null;
# K# N6 u2 q" S            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 8 O" F( }! V3 r- Z5 F
                workView.Tag, out curve_count, out outline_curves);
1 p4 S) ~/ U6 v  E! d! f9 ~% f            Echo("Precise Outline Curves: " + curve_count.ToString());
( ?* [3 \# d) v% i            */
2 C& H! u, K0 D9 A' Q1 T' k: j        }
" _; \- I# x( ~: J8 p/ F$ H* L' ~& N! A/ L9 \
    }[/mw_shl_code]
+ k5 g+ C. |+ K  K8 L; N[/hide]
3 w, p8 {! D! L- g, 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二次开发专题模块培训报名开始啦

    我知道了