PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓1 D1 y6 a* ^9 |, X* O& E

) C+ z) `: g1 k1 b6 E, L( [0 mUF_CURVE_create_shadow_outline (view source)% V1 ^6 i, F5 \4 x  h! Q
7 [. f" x! n5 U
Defined in: uf_curve.h, Q  C! ]3 J& i0 v  w
: M  t6 B& {! K) v) w& I" W
+ O* {0 e/ R* b# z4 B+ m8 s7 p6 w4 z2 d
Overview" ]% ~! {6 k' t( @

' x9 _; |2 E" _$ ]( p# }* BCreate shadow outline for a given array of solids. Solids passed to this
+ u+ r6 F6 Q" ~/ p: Z- Wroutine must be on a selectable layer and visible. If created shadow curves . m1 n$ H1 ]) G. ^  N! u
can not form loops, please use UF_CURVE_create_shadow_curves instead to get + D! A8 b' h; l( g: L! p4 U2 e
shadow curves.
: F- q2 X- a$ b' f
; h2 j. J* q3 B% C) ~- N! b' c2 L. [5 N  D3 M/ }; ~  M
[hide], T3 P: d8 U& W
; D4 b9 ]  h( Q+ G, ]
[mw_shl_code=csharp,true] void DoIt()4 o5 \2 u* k9 N  `6 S8 j
    {/ ?% j) i  n  F+ J
        if (theSession.Parts.Display != theSession.Parts.Work)
5 O3 r0 M6 f8 Z' h            theSession.Parts.SetWork(theSession.Parts.Display);# h2 t/ \: K* s' ]$ t& x3 L4 B7 O

3 ~$ ~# J& J8 p# \1 b7 I+ Q7 j1 p# T6 D
        TaggedObject[] theBodies = null;/ j/ X7 |8 z9 K' i; `/ T; _
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
8 F. J4 E- Z$ d6 T  w2 f2 G        {
- C) ^8 [6 w9 s# d! h" U4 e            Echo("Selected Bodies: " + theBodies.Length.ToString());
" j  s6 D7 j' y! @# g            Tag[] theBodyTags = new Tag[theBodies.Length];/ c  Q- W$ H6 i8 k
            for (int ii = 0; ii < theBodies.Length; ii++)
: y1 b+ O& [0 T) ~, O                theBodyTags[ii] = theBodies[ii].Tag;' t: D# I: W: g( z
" z/ i2 A" N( F" i
            List<Curve> theOutlineCurves = new List<Curve>();
7 h% Z. {5 H& r9 l            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
# b6 V% ^! g; V4 c            int loop_count;8 ?9 C$ K+ z  u0 A
            int[] count_array;
" O/ e" g  R0 @4 }5 \/ U            Tag[][] curve_array = null;* \1 M/ `4 S; {
            double[] tol = new double[2];
) U# ]% b4 o) a) H6 |5 y4 m4 S8 }1 e6 H% ~% H  g5 `2 r( d- t
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);! A- M$ d7 f, Z) Y1 X# k  h, w- b) C, g
            theUFSession.Modl.AskAngleTolerance(out tol[1]);" W8 E# X9 z* P. Z2 i& z

4 T0 M6 s! p; E6 H- i            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,9 D+ `- I, t& t
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
9 d1 M0 m+ @: D1 u0 G
: A' [, z! h( s1 q# h' R0 Y- |            Echo("Precise Outline Loops: " + loop_count.ToString());
! B. j; _" W  |6 u# G4 ~' ]5 U            for (int ii = 0; ii < loop_count; ii++)
- q" L! |9 r' q0 f                for (int jj = 0; jj < count_array[ii]; jj++); ^4 n  O; _% v* x3 Z9 l
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));3 z' H( B# c6 D5 Q( S; n/ Y. k% M
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());6 R4 e- c0 }( d( Y. f

4 V9 _. D3 Q% L) o9 t            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
8 q/ F9 m) E2 A" ]# p            int curve_count;
: l% {* B) l. a7 c8 K            Tag[] outline_curves = null;
* Y  p0 u1 W* x; r- O# P            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 4 M, \* L$ B( U+ D8 }  d+ M
                workView.Tag, out curve_count, out outline_curves);
4 O" z, U1 d0 R4 A& i) L3 g4 H            Echo("Precise Outline Curves: " + curve_count.ToString());
; Q, ^( Z% s8 r5 C3 c  I1 a            */
, [" c! ~2 Y' d* i0 l' R        }& M& g4 [  u4 {) z9 f" u2 \+ w

! a5 }7 i3 d0 L    }[/mw_shl_code]. R- \2 b( r8 O2 s7 [6 X' s6 }
[/hide]
$ v1 C! D; V  q5 G6 f8 u
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了