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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
4 w0 c0 {6 |* [. M+ e( p5 m$ o2 x5 `+ [: {! C2 M0 T% n
UF_CURVE_create_shadow_outline (view source)
% b. r9 r+ P0 M' w! i
. X. b- B4 ^) Y. N$ P5 V6 ^Defined in: uf_curve.h2 @' C0 |1 N4 M8 c% m! `
& S  w8 b3 K0 N6 w2 [) q

. r/ b0 @5 |% M  U3 gOverview
! X& X: V$ p5 `# @8 ]
2 N1 P9 f+ G4 }, v4 _3 PCreate shadow outline for a given array of solids. Solids passed to this & b) C. B5 G) O5 t. w0 Z# g4 L$ A
routine must be on a selectable layer and visible. If created shadow curves 2 w0 j. A4 U5 ]2 `* g: Q) |
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
8 A6 g: Z3 y9 W/ r5 Nshadow curves.
4 }) r2 k5 X4 U- t& R7 U  I/ y  u0 T8 X. l
: S" E6 E% ?3 _9 Q$ D9 v/ V
[hide]
9 E6 J8 Y* T. D. a% k3 b0 B) Q/ b9 m
[mw_shl_code=csharp,true] void DoIt()
4 B) P9 g% ~, }  u, X    {
+ A' D6 t# W2 D        if (theSession.Parts.Display != theSession.Parts.Work)5 A5 a, D1 q/ T9 I% k7 j, i/ y
            theSession.Parts.SetWork(theSession.Parts.Display);
, @4 c, J/ a- w! u) W4 N% Z+ W9 d+ B) K; I5 P, N3 Z

" W8 B2 I7 a/ S& i! T7 I        TaggedObject[] theBodies = null;
: P2 [! K+ m" W6 e( F& h        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)  s6 E0 ^9 S+ ?* u% U: L1 O
        {, v+ s8 z7 A1 E% \9 T
            Echo("Selected Bodies: " + theBodies.Length.ToString());6 k" O2 c2 u, l" D- O# P: b
            Tag[] theBodyTags = new Tag[theBodies.Length];( Y' W1 Q' Z8 ]+ `
            for (int ii = 0; ii < theBodies.Length; ii++)
4 m8 O1 w% t3 V5 E# U, @                theBodyTags[ii] = theBodies[ii].Tag;3 e1 i5 H$ |+ c3 n4 Y

) L2 |8 K& t, I* X$ p            List<Curve> theOutlineCurves = new List<Curve>();5 H& q0 ?  h- Q% [2 L0 c- v
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;+ U& R, X) j, P- b/ K
            int loop_count;
8 x& j- `: ~0 t( c; N& z            int[] count_array;
3 C4 [. C8 s& V7 Y            Tag[][] curve_array = null;- x& Z3 S0 w9 Y# f
            double[] tol = new double[2];
9 o3 `9 [1 }- m' b0 l* i6 R9 T2 J; }: T
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);1 g( P) C/ h5 ?) ], B3 A& N! q
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
/ h5 n, ?9 C4 b: \
+ a! ^8 a* Z( Z0 @8 {% i            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
: P6 ]4 \) k1 E: ?, G7 W" o                workView.Tag, out loop_count, out count_array, out curve_array, tol);( Q* h9 g2 m" a! f

9 }4 i0 G5 V& X" M' F5 a' F/ p0 Z            Echo("Precise Outline Loops: " + loop_count.ToString());8 O; B2 _# q# Y* }* Q+ k
            for (int ii = 0; ii < loop_count; ii++)
+ F$ H4 ~- O; h# p4 v& W, i                for (int jj = 0; jj < count_array[ii]; jj++)/ }  t( t8 o# G7 F) `
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));: a( n  Z; Y) c$ W
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());- i- |+ a/ D) T) c0 M! T' O
" J* G3 _# [& u
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
7 J& ?( E$ P3 r            int curve_count;- ~2 v0 R1 w2 d" Y% o& A
            Tag[] outline_curves = null;
. f3 S  g& d% B3 Y9 ^9 I: v            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, * s4 C* G  `  e! Z' M, n
                workView.Tag, out curve_count, out outline_curves);& j% O/ h9 \4 s; `, c. V
            Echo("Precise Outline Curves: " + curve_count.ToString());/ R4 ?. s$ S4 B! V
            */+ N; X" u1 M4 y, y
        }  ?0 U8 M* G+ D, `% y
* u5 N+ R9 I# m% H( _( t
    }[/mw_shl_code]
! |" p. L! G: r7 M2 M/ n7 g# Y0 j/ s' C; x[/hide]
( n! u0 A' S* w
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了