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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓9 G( t8 C3 Y2 x. }" f. C, r
, Y0 |1 V% q% d1 O
UF_CURVE_create_shadow_outline (view source). t- k- q1 F6 i( m* R/ b# ~

2 n6 h7 M1 m; ]5 C& |' f/ VDefined in: uf_curve.h3 M" L6 D* `  H6 p4 w! G/ g

9 O" S/ N9 r" [% F7 v. i: u0 G# q7 e# @6 m
Overview, W8 O% h: Q+ o, @
1 Y: Y5 x7 d7 N$ f) \  V
Create shadow outline for a given array of solids. Solids passed to this * u' t. X0 M: x7 m6 Y
routine must be on a selectable layer and visible. If created shadow curves
) y! j. U# P: V$ ncan not form loops, please use UF_CURVE_create_shadow_curves instead to get
/ o# ~9 K! P+ mshadow curves.
7 J+ E9 V2 j$ ~5 Z( I1 g% S( l
( T0 Q, D6 y1 J" B, M  n0 N0 }1 r- W9 f3 V
[hide]
* Z8 h# V3 t: G3 |! h, p1 {5 X2 V* R' q2 `- y
[mw_shl_code=csharp,true] void DoIt()" b6 T0 s" t( X! K) r
    {2 @7 q5 M2 F$ O) O0 k. G2 S
        if (theSession.Parts.Display != theSession.Parts.Work)! s& [! p0 S5 b7 q
            theSession.Parts.SetWork(theSession.Parts.Display);
+ ~5 x9 x" b8 ^2 H( Y2 v* Y( t6 }8 h
$ S4 [' g" u5 M$ Y- m1 I
        TaggedObject[] theBodies = null;' d& b5 \" d/ A& n
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
( s: `7 E2 g1 y) U        {
3 z. J6 R- g0 B3 E& m            Echo("Selected Bodies: " + theBodies.Length.ToString());
8 Z, T4 F  y. H+ L  s' _7 Q            Tag[] theBodyTags = new Tag[theBodies.Length];/ |* W/ y  {' X0 z3 o2 U8 y
            for (int ii = 0; ii < theBodies.Length; ii++)
; M) p, K, ~/ I9 j9 |                theBodyTags[ii] = theBodies[ii].Tag;) [: O$ }# E8 u0 P7 _( I/ v
$ p( A/ d: e/ r8 P- Y- }7 G; P) o
            List<Curve> theOutlineCurves = new List<Curve>();
, g7 k, R8 a% N            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. w* d9 z& j( _2 ^1 W& \            int loop_count;
4 c6 l, p6 C& H3 K5 P/ Z0 }            int[] count_array;
8 |# M' u! |4 a  t% a3 @            Tag[][] curve_array = null;, ?# e* X7 m; x4 Z8 N
            double[] tol = new double[2];
7 F) s4 y* m+ @/ Y
/ J7 E! C9 [) ]0 b0 o            theUFSession.Modl.AskDistanceTolerance(out tol[0]);+ Q8 }9 s" h5 D/ f, g7 C& y
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
# E4 D- l4 j# e/ m8 l3 o" y! i* ~- V" q+ o% G# |6 M# [/ J& Z/ a
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,- l( @( I* N0 g: C" }
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
! m  J$ Z( V) [) t$ i
$ N0 v/ Q, a8 ^* ]! H' K            Echo("Precise Outline Loops: " + loop_count.ToString());& J3 k* R2 @" n4 J7 p3 S9 }
            for (int ii = 0; ii < loop_count; ii++)/ \0 X( Z6 s9 `% E& s3 W% |
                for (int jj = 0; jj < count_array[ii]; jj++)( E, f( d# z; B3 _& J! K7 B9 [
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
( y- F: c$ {% k            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
" a; S$ K% B# U- G2 r- F) H
$ R. u! d& x: k( n8 b& G5 \            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 8 M/ B8 ]" f0 ^! I7 h; Z
            int curve_count;* e5 A5 c2 X1 @8 k) ^  U1 X1 P9 q
            Tag[] outline_curves = null;
1 w; u6 x# T% F3 V' ^            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
# s; T/ s) a) @$ n+ l. [                workView.Tag, out curve_count, out outline_curves);
2 h: P, A  T) _; p, x            Echo("Precise Outline Curves: " + curve_count.ToString());" ~! _* G! P8 B8 Q8 t" z
            */" w% @4 L2 z$ F% R
        }' e/ l5 ]! Q8 C" t
( p* b4 R0 G3 ?5 f
    }[/mw_shl_code]8 o1 \) x# K2 I- v1 `, h- L* t7 S
[/hide]
7 w# I: Y5 Y, ^' Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了