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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓& N5 ^( O0 v' O3 p% B, Y# E- m
5 |0 p; P9 z. I( w% W, H  t# k1 W% ]
UF_CURVE_create_shadow_outline (view source)
9 ~. w) @7 H" J7 e) v3 s: A- s % ?( H$ ^' M( z9 l) H, s
Defined in: uf_curve.h% j/ U# {) l' ^9 @

# C  R0 m- L; V
3 g/ v- O7 R8 u4 F, hOverview
9 T6 g; P8 p! @3 z9 a/ R9 W5 t# I
Create shadow outline for a given array of solids. Solids passed to this 6 w, b- ~; q, ~
routine must be on a selectable layer and visible. If created shadow curves
7 H' m: \- \5 S7 h! h2 Ncan not form loops, please use UF_CURVE_create_shadow_curves instead to get 2 d; q8 h  Y. f
shadow curves. ( D- m! X, c$ M

. u) u1 T: ^- _$ ]- y  n
5 Y3 R* V6 |+ c. }( Z2 t( U[hide]
' }( v( h' l: k+ y& Z( n" K) ~
7 a9 ?. R# n# }0 _[mw_shl_code=csharp,true] void DoIt()
( ]/ d" J5 Q' g( N0 g% X! O    {2 M8 J  ?7 q6 j! J* R2 T5 R7 t. Y
        if (theSession.Parts.Display != theSession.Parts.Work)4 y/ H( N4 `, n( |
            theSession.Parts.SetWork(theSession.Parts.Display);
* P2 h) A" c7 }+ M, p6 U" Z# \  T5 e$ ^$ @

1 ?; W1 k' n3 r# `        TaggedObject[] theBodies = null;% O' @0 c7 l1 o, y& J1 j8 `
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)1 l. e- F/ ]6 ?5 `9 v' j9 D
        {% S/ Y7 Y! K" x- `
            Echo("Selected Bodies: " + theBodies.Length.ToString());% d: H! d& P; R5 J% ]' A% M
            Tag[] theBodyTags = new Tag[theBodies.Length];
9 w+ }+ C4 O3 S4 [& b- B7 j* Z+ x( X$ m            for (int ii = 0; ii < theBodies.Length; ii++)& v1 D, N* O; Z( h: x7 x5 X: \
                theBodyTags[ii] = theBodies[ii].Tag;
' f* r4 e7 G9 w8 K9 j% t( {
1 a) R5 T' o( @6 f, D" a            List<Curve> theOutlineCurves = new List<Curve>();
. l  h9 A/ X" e' C            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;! p2 i2 q/ c; Y; J5 p9 u  q
            int loop_count;2 r; {& `: ~9 {  h
            int[] count_array;
9 m8 S& K1 p' w& l            Tag[][] curve_array = null;7 C( A' c/ g; A2 S/ y* g! Q
            double[] tol = new double[2];
7 [7 q/ H1 `! s/ I5 i! C+ ~# h# J/ n7 q/ a5 W  B4 |( x" S) m: j9 V" d. |
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);. C4 ^* T: Z/ }
            theUFSession.Modl.AskAngleTolerance(out tol[1]);& _6 m" l: i- ^" N, r
8 y, H+ P1 A" N- S; d
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,4 m' P- V2 G1 \
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
+ U% y5 }( T0 t* r& V0 N0 [( J
/ |3 ~; j7 S0 x. [" \7 @            Echo("Precise Outline Loops: " + loop_count.ToString());/ ?5 R/ A- i) F: @+ d7 i
            for (int ii = 0; ii < loop_count; ii++)
9 ?; W7 Q+ U- [7 C8 t                for (int jj = 0; jj < count_array[ii]; jj++)
7 b7 g1 E6 \* k% e                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));4 H/ M' z0 j9 N' y4 R
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
. i6 w6 h9 M. C7 p8 D$ [/ k5 e' z$ w# `  k2 M/ F# m
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead " s2 X3 b5 j1 u8 m# E9 z
            int curve_count;9 _. H4 ]% S4 A4 L3 J2 J: Z7 u
            Tag[] outline_curves = null;
2 Y+ B' e+ m+ i, u            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
6 f! P! ]* B! |& b4 X                workView.Tag, out curve_count, out outline_curves);. ~1 C. I- ~: w+ Y7 N3 x
            Echo("Precise Outline Curves: " + curve_count.ToString());
$ s# i9 u: M0 e  \+ m( N            */" @* d/ X$ ?/ ^4 u8 J0 C3 f
        }9 R& S$ |* Y# Y/ V( N

: V( g) v$ l' `0 R% Z; ^0 x% M4 x# }    }[/mw_shl_code]
! c$ X2 H9 ], A( B[/hide]( N: Y: e) J, v7 B- J  h
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了