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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
5 C6 [" H" N* J% B% H) I" W; b% t( S) B1 u3 h, N, L
UF_CURVE_create_shadow_outline (view source)
( p( G7 Y3 a9 B6 R# c0 a
: m& b% Y& [( i3 x( ADefined in: uf_curve.h
6 z6 f9 `# p) ]+ z, @
0 f. ]3 M6 h& b' h1 E: C9 S- J. o- v% \& N2 A0 E
Overview
4 w: s, D7 V/ _  i6 D
0 _) Q# Y8 ]6 w) f7 ICreate shadow outline for a given array of solids. Solids passed to this
0 m3 A7 T4 K1 O, uroutine must be on a selectable layer and visible. If created shadow curves 2 V/ ]; V; g$ J$ x0 G8 j
can not form loops, please use UF_CURVE_create_shadow_curves instead to get 7 X3 Z. v, }$ H
shadow curves.   }4 `. t/ Q4 b5 h
7 U  f5 ~% h8 Y  ^- d9 T! O' p

* k6 l  E$ P% [[hide]6 {  N; W0 \' S; I5 U0 N8 }7 v

8 o3 f$ H, V  P5 Z' s# X[mw_shl_code=csharp,true] void DoIt()
# ~  ]" H  O9 ]9 k2 U: c    {! U: u6 l) h8 S0 |
        if (theSession.Parts.Display != theSession.Parts.Work)3 n% n" b9 G$ E; `
            theSession.Parts.SetWork(theSession.Parts.Display);( W7 c* G/ w# }* b& y
; r, s. K6 t) f- k! H! `

! I, E* z+ u  w9 E" j        TaggedObject[] theBodies = null;: J6 y6 O9 H& q' d+ s7 ]& C
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
" ~  a3 v& S+ t* ~, B) Z2 k        {
9 u- a' ~6 O' N            Echo("Selected Bodies: " + theBodies.Length.ToString());
5 H7 @- P3 v7 @/ h            Tag[] theBodyTags = new Tag[theBodies.Length];
: {/ Z/ u; C9 w  l& J+ p3 H            for (int ii = 0; ii < theBodies.Length; ii++)6 ~. J- W% U6 n8 U/ h5 P4 \9 ~
                theBodyTags[ii] = theBodies[ii].Tag;
( u8 j- r. t: [* k4 K( C
( O  r% Z& t  E6 z) h0 ], Y            List<Curve> theOutlineCurves = new List<Curve>();
7 k. u2 {3 v& H            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. B; ~1 L% u4 h. ^7 g( G1 G            int loop_count;
6 q- Z+ s* U. l            int[] count_array;
9 a. p$ T; _7 u, q; d            Tag[][] curve_array = null;
! [( S/ p, k& t            double[] tol = new double[2];9 I( ]9 \) m+ e: }9 ?! }/ P4 A
4 w4 J& p6 Q' s- G1 P4 T1 E
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);$ `7 _' X7 d! t6 Y
            theUFSession.Modl.AskAngleTolerance(out tol[1]);8 L: _1 w  K3 B. A6 M

. B0 z; b4 V3 v; g            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,9 n: t/ K1 l' w! ~( N2 j4 i
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
- Y) i6 b' A# ~3 p0 k
7 y* n/ h0 \3 J: q; Y# P            Echo("Precise Outline Loops: " + loop_count.ToString());
  p( w% c  O; h% Y% t( O# A            for (int ii = 0; ii < loop_count; ii++): z$ e$ W# a. W; ?* }# M$ |& G
                for (int jj = 0; jj < count_array[ii]; jj++)9 x" p! `. F  l) V7 f; [7 g4 ?# O
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));5 s7 D, p5 s/ o0 R. ~/ B6 w
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
1 x9 K, A* L1 i! G9 v! i" ?" M2 o5 ^  K9 M2 E
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead . R8 o9 u- A0 _/ {, Z
            int curve_count;
0 D; }" o, B4 f* ]3 G6 e: K$ g            Tag[] outline_curves = null;, j: A/ H: ]: ?0 B
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
( z7 l1 F% y) {; o                workView.Tag, out curve_count, out outline_curves);. N3 O1 a4 j. P3 h2 e) A* \
            Echo("Precise Outline Curves: " + curve_count.ToString());, m; O6 K; `+ r4 C. Y4 c" R' |
            */
* C) C, Y  J$ q" y0 `. j; X9 x        }# {2 `0 n* n9 s* h9 f( l
1 k+ b9 q. u7 P
    }[/mw_shl_code]
7 E/ }& u. {. i& @- h& e' J- h[/hide]0 `- F7 p/ b9 x! X$ R, @( i- j
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了