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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓" h4 S) p4 V$ k" t4 _( U

6 Q) V4 ]) L; W+ }5 S2 b3 x: vUF_CURVE_create_shadow_outline (view source)1 F* N: h7 @7 v9 Z( H3 D4 H
" X- S- j# |  [( R& v
Defined in: uf_curve.h
6 i1 f; c9 u% P" b7 ^8 t% K
; d& L% v& I% V# Y) i& q7 R' Z
4 o3 }* D; D6 wOverview9 y# `" }, ^- {2 f4 Y: h

$ ?% R! b$ [2 e% M! rCreate shadow outline for a given array of solids. Solids passed to this ; ^  B# R  k4 i0 F' [/ Y- v
routine must be on a selectable layer and visible. If created shadow curves 8 T4 `) }% l2 A
can not form loops, please use UF_CURVE_create_shadow_curves instead to get   ^6 t. A( w- c1 a1 L
shadow curves.
2 j1 z0 W: G- r8 P/ v8 M: y  l3 R1 `7 W; J

8 K; a; g6 J- M, j, t6 M[hide]- |5 S: l7 E3 ~" b  M: [8 f

: A+ Z% ~# R4 G' N  H- l; K4 N[mw_shl_code=csharp,true] void DoIt()
6 _3 b& ^9 w* e' j    {% ]# s$ |! c  E) ?
        if (theSession.Parts.Display != theSession.Parts.Work)
9 n6 m' e2 K- {9 _" ?7 i, i1 i. c            theSession.Parts.SetWork(theSession.Parts.Display);0 U0 a; G$ q8 r' T  Z

" p& p0 K) y! l0 s4 M/ q* B# a
5 a9 Z0 N6 |$ k7 |; Y# _        TaggedObject[] theBodies = null;
6 v, j8 g' ]6 s- B1 q$ f# \' H        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
$ {' r0 I- V8 K2 g2 q: l  s        {& ]! `  o# l, r8 a
            Echo("Selected Bodies: " + theBodies.Length.ToString());. }* k- B5 ~" Y, }5 P
            Tag[] theBodyTags = new Tag[theBodies.Length];  c" S( L2 }$ G0 U& q$ k
            for (int ii = 0; ii < theBodies.Length; ii++)
/ j1 `( h3 V; u* J                theBodyTags[ii] = theBodies[ii].Tag;2 ?9 v; N, @5 ?8 J
( W3 O/ T7 S* u& ^- P+ y9 v
            List<Curve> theOutlineCurves = new List<Curve>();4 Y# y2 V, E  u+ [' {1 q+ ^
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
) A! U+ {8 v# q; v: c+ S( `' B. A            int loop_count;
5 j) U6 y; h5 `! j# L8 `/ N+ U% C            int[] count_array;0 z& ?% A/ k1 X. g% @3 k$ Y0 a
            Tag[][] curve_array = null;, b) |% [5 J% E. l2 P
            double[] tol = new double[2];- P* g$ B2 A+ Z. I/ V& D8 Y

6 [& Y! @; v3 }4 R: L            theUFSession.Modl.AskDistanceTolerance(out tol[0]);0 ]; v2 n# f0 _1 ^& J+ l5 h
            theUFSession.Modl.AskAngleTolerance(out tol[1]);2 v$ X5 Q7 `; q* `5 X! P
8 `' `4 k: W' ~
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
+ a6 ?/ B  {7 W8 M: H6 J4 \                workView.Tag, out loop_count, out count_array, out curve_array, tol);' B- j6 |2 N4 r
/ M, o$ h5 @& o4 @2 i) ?9 `: N! Z% w; \
            Echo("Precise Outline Loops: " + loop_count.ToString());$ C* Y8 G$ k6 O; i$ {: b& _1 m
            for (int ii = 0; ii < loop_count; ii++)& M3 {6 q. a4 T, l0 ^
                for (int jj = 0; jj < count_array[ii]; jj++)& U/ s  G3 C# ?; q4 h0 e% f
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
5 a/ t. A& Y$ x% s            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());6 `2 J5 b+ m" @! ^( d2 J( }9 f
& l; p4 o! Q" H+ `0 s
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead # j/ B) x9 |3 m1 A& w
            int curve_count;
& R& l1 N! J6 z0 \            Tag[] outline_curves = null;
7 ^+ o- Y& ^1 a1 G' Z6 [            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 5 N8 Q7 k  T& D% w
                workView.Tag, out curve_count, out outline_curves);
% F) {* u. i) J+ G+ U" @# F            Echo("Precise Outline Curves: " + curve_count.ToString());
& N/ _: \: }7 r6 a            */
  [7 @1 C( T- F7 E/ g+ x! q        }7 {4 w6 h: _- P* I( R
+ W! g* {; t! W$ N7 @6 u* z: E
    }[/mw_shl_code]$ D8 F3 D- a5 [! ~) @* Q
[/hide]9 q- B, A5 @! K; I$ z" s3 O. a, E& ~
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了