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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
3 |- c) n# G7 Q. h0 ^! o% D/ C- H+ _
1 i6 z+ S- a) c% r4 \2 K7 OUF_CURVE_create_shadow_outline (view source)
. I$ q9 ?$ U; d7 ~' g6 q6 o
. F" s: X" m1 j% }Defined in: uf_curve.h
/ r8 C9 L, r$ H; R; i
. s/ J. M( y3 d& g8 L8 J4 j7 b* @7 s/ |( ~6 h8 V) m0 C
Overview
! l) _0 D9 A6 N5 z4 F) S( X
* F; ]: u3 p# j! gCreate shadow outline for a given array of solids. Solids passed to this 7 H# I" s- l; b) r3 `) P1 ^
routine must be on a selectable layer and visible. If created shadow curves - j6 Z* @/ M# j: H/ W7 J2 K& ?7 H
can not form loops, please use UF_CURVE_create_shadow_curves instead to get ( T8 \  z+ G3 X$ g
shadow curves. . R: ^+ `1 Z: Q

6 T. V* N7 N6 Q7 w8 U
& U$ T* w- T! f/ A. @) I[hide]
0 j, Y& o: t/ o
8 x; J! P4 d2 l[mw_shl_code=csharp,true] void DoIt()6 B' l9 p! U/ Q6 [" G
    {
" E1 L6 X+ M- u% O4 O        if (theSession.Parts.Display != theSession.Parts.Work)0 ^/ q# {8 c# q+ `9 D
            theSession.Parts.SetWork(theSession.Parts.Display);8 A% v2 C! l8 K  C
8 j) I5 p$ `3 C8 H
9 @( W& s+ L5 o9 x) u0 m
        TaggedObject[] theBodies = null;$ S" l, u6 K& o
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
, e0 N, n+ f, ]( `. c        {
, T4 C" o  y, p1 k! i2 Z# W            Echo("Selected Bodies: " + theBodies.Length.ToString());( D6 U4 g6 ?. l. x8 n! I
            Tag[] theBodyTags = new Tag[theBodies.Length];
! I  n6 h  |% a6 N            for (int ii = 0; ii < theBodies.Length; ii++)6 d8 m* }/ a# O' E
                theBodyTags[ii] = theBodies[ii].Tag;( K7 T: W  g5 ?1 X
5 s3 o* w) ~. \( V& @. _
            List<Curve> theOutlineCurves = new List<Curve>();
8 c  q: n, Y+ g$ A( `7 E' r            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
6 f1 z6 u2 c6 D( F7 X" R; U8 D. m% L: U/ L6 H            int loop_count;
9 M! c' @  b' d9 L( b            int[] count_array;
- e* _" ~+ E0 u  n; Q' A6 ~            Tag[][] curve_array = null;; o. s. J! [9 X: ^
            double[] tol = new double[2];( o" T8 o; }# g; p3 g

3 q/ j- D, W! e9 |4 A/ E, c            theUFSession.Modl.AskDistanceTolerance(out tol[0]);: _1 i# L# B* P$ z5 W5 x
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
9 ?0 j+ s) T( \) F; ]0 R/ E. k) @) [8 I% s
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
; g8 |' Q: |1 d                workView.Tag, out loop_count, out count_array, out curve_array, tol);
4 O' P  [, ]+ j6 P' n( B/ Z5 J2 a: Q8 T# f0 M) _
            Echo("Precise Outline Loops: " + loop_count.ToString());# }8 a& u" b, F1 q
            for (int ii = 0; ii < loop_count; ii++)
- _" }: q% A  r; f! C                for (int jj = 0; jj < count_array[ii]; jj++)
  K; f. h; T$ P% @7 I                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
# a1 z! Q0 o) M% ^            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
1 K8 Y. P1 m. A# [# }7 Y8 u6 O" y- y) [7 W& r
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
* q5 L2 M7 f# b2 u  j8 R2 v3 B            int curve_count;+ t3 j% N" q- ?5 K: B* Y  s
            Tag[] outline_curves = null;
! r4 ~' r6 X* m; n: ]) p7 }. S            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
3 ?7 |+ q( k8 y- \' N- T: @9 K/ k                workView.Tag, out curve_count, out outline_curves);# p' E% p# r0 p, f2 E
            Echo("Precise Outline Curves: " + curve_count.ToString());
! b8 O1 {8 t$ [  I! N            */6 h  M+ {- \9 j; }( }! M
        }# i; T* o& E) `  p0 ^) i% r1 C

, e. M5 e8 i3 z5 G    }[/mw_shl_code]
% f: Y3 T2 Q# Z* ~$ W3 X7 ][/hide]
+ |/ I( O' c2 \  S" m& \& 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二次开发专题模块培训报名开始啦

    我知道了