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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓; ]& a2 s9 }* J1 r( M% [0 `
5 b6 k- J: w% |2 U, R- i1 Q- A$ W( ^7 ^
UF_CURVE_create_shadow_outline (view source)& y* B1 Y8 o! Q: x- p, v9 l

  z5 I2 ^9 T9 X# j5 t3 tDefined in: uf_curve.h8 g8 P- P/ x! j6 W. H: a5 }: h; ^
# h9 y0 S# V: ~) }7 G. ?/ l
/ y" M4 \$ T8 I
Overview
) D& `1 u2 s0 |# i! Q& Y9 x
  A( ~# d5 W- _/ X- H, ICreate shadow outline for a given array of solids. Solids passed to this
! w6 s- [$ W% c9 proutine must be on a selectable layer and visible. If created shadow curves 2 L& F, c- n# ]* s, m: G/ n
can not form loops, please use UF_CURVE_create_shadow_curves instead to get 5 L" F3 ]5 {1 T% M
shadow curves.
9 `" S) P' A% p6 ?8 R( s6 F
: m' [9 M2 M+ M) s( N
& i! P' N& H# y" L[hide]
2 |3 z: h- [& M8 R8 K, g, V/ ~+ i/ v1 ~3 E0 Z+ O, O
[mw_shl_code=csharp,true] void DoIt()% R( E( S& G& j1 v" D+ Q
    {+ c* t$ J+ W4 b
        if (theSession.Parts.Display != theSession.Parts.Work)
9 X& F) w% o( e; D% {# G$ ?            theSession.Parts.SetWork(theSession.Parts.Display);
1 u6 ]: D/ O# v2 Y7 A! v7 A( w- m; G; Q
. z- S$ W( l8 H" J; M& R5 u
        TaggedObject[] theBodies = null;
- m; K  [/ |' H* V        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
+ J0 f8 g& V( L5 M1 _" J4 o2 [  s        {; f& O3 E% U0 e' J: r
            Echo("Selected Bodies: " + theBodies.Length.ToString());
( x) q! Y4 a) H) M            Tag[] theBodyTags = new Tag[theBodies.Length];( t8 q9 q+ A1 ~# S7 _
            for (int ii = 0; ii < theBodies.Length; ii++)  F- K2 ^- K/ Q8 f( |
                theBodyTags[ii] = theBodies[ii].Tag;
0 X8 R! S' j( _' i4 a# m. G
. n& r+ V7 p# ]" N            List<Curve> theOutlineCurves = new List<Curve>();, i3 [: a# ?+ K
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
& q" a" K: L7 t7 E& M7 \8 |7 l            int loop_count;
0 F- F8 n( w! u            int[] count_array;
- g: v! \  ]  J4 {# K2 q            Tag[][] curve_array = null;7 T0 U$ c* \/ m& f5 F7 \. d$ t7 e
            double[] tol = new double[2];
/ Z8 m  L# {* I* g* N; r9 d# g
" G" r% N% E" [- z/ y. n            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
5 l$ S: j* z. D: S) T            theUFSession.Modl.AskAngleTolerance(out tol[1]);& Y, _* F5 Y+ Z4 d4 }$ [3 x

/ K7 `- a+ Z) L! @8 w& W            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
" k) i9 i0 _4 C6 o3 {) [4 ~, a                workView.Tag, out loop_count, out count_array, out curve_array, tol);2 F6 ?4 \3 b/ `. j( N4 |( b
0 O0 d# Z5 w3 Z& _( }
            Echo("Precise Outline Loops: " + loop_count.ToString());
4 e& [% o6 i' R8 L% J* c' T            for (int ii = 0; ii < loop_count; ii++)) q8 e, a3 ^9 @! m. V: ~
                for (int jj = 0; jj < count_array[ii]; jj++)0 }% P; U+ b% j$ u7 }' @
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));* X; u0 L4 r' D
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());# w$ b6 m0 w; M6 x

- ^8 h0 i+ p1 I1 u+ M            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead ' f% Q1 R8 N$ {( p0 `4 |. _
            int curve_count;/ T, \: \! Z* ^
            Tag[] outline_curves = null;
/ b4 P$ V8 s7 C; L            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
" m$ E* S, g+ k; i% @: k                workView.Tag, out curve_count, out outline_curves);
1 R* G6 ^" S' K) X! w8 \1 E* O            Echo("Precise Outline Curves: " + curve_count.ToString());0 ^# v) R9 Q: I5 |
            */
) n" a4 @6 {; E        }
  G+ }7 Q, ?) @1 L8 n
8 C/ p+ ?# D+ W0 R/ J1 Q    }[/mw_shl_code]+ C1 |9 Z& M$ x- D2 R
[/hide]
* |4 m4 n4 v, [% Y) c2 t. Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了