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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
4 N8 |& C7 c# I% M7 J2 O# q$ g$ C7 \7 Z3 x- R, J1 L/ j' u  |
UF_CURVE_create_shadow_outline (view source)+ a/ b9 s6 B/ a
& e9 @+ N+ B2 Z. [( V3 l
Defined in: uf_curve.h
% Y6 _$ W: b! `0 a$ C# |
1 l* E' I! n3 d1 I2 D: z
; w( ?! A2 r' i, tOverview
& |2 q1 `( R' Z( i% e2 L5 c2 K! [% y4 a8 ]
Create shadow outline for a given array of solids. Solids passed to this $ Q  n2 L, S) W8 }( W
routine must be on a selectable layer and visible. If created shadow curves
2 J9 x3 s* v  g! f) ican not form loops, please use UF_CURVE_create_shadow_curves instead to get 5 z; s6 A& G3 T$ X0 A4 A  {; F
shadow curves.
- h! x  Q8 E6 |2 z6 q
% b) i( c5 m6 |" U4 q% G" G0 B  \2 B) c" L  Q
[hide]  V3 A0 v# }2 `4 k
, O) K5 k8 o7 f7 U
[mw_shl_code=csharp,true] void DoIt()
$ g2 a# N" t+ e) w5 g% b+ \    {
: q3 Q: I" y* R& _/ [3 @) P3 }        if (theSession.Parts.Display != theSession.Parts.Work); d8 |  s( y/ O/ b3 g
            theSession.Parts.SetWork(theSession.Parts.Display);5 @+ |1 N: T; ^: \  }) R' k

1 \* a' c# G+ f- {* y' ^% x0 K9 ]9 T, L, t
        TaggedObject[] theBodies = null;. B6 J) [% u' A
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)2 D1 `5 ]9 x6 ^9 y( W
        {  y& i, U" m- v+ e( d
            Echo("Selected Bodies: " + theBodies.Length.ToString());
- [9 ?  X" G0 D' m1 V& [            Tag[] theBodyTags = new Tag[theBodies.Length];# S, q2 F# |. f; [) J
            for (int ii = 0; ii < theBodies.Length; ii++)
: P. x3 K4 }( ?" S4 w: U4 C                theBodyTags[ii] = theBodies[ii].Tag;/ `& Y' Y) J- c1 g  t8 H

+ ]$ r2 S, f. ]4 d. Q2 H            List<Curve> theOutlineCurves = new List<Curve>();& b! E0 S1 {) c+ y6 U) o0 K
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. w: B- m, `# Y' A, E" H            int loop_count;
( {7 t4 v1 M0 G9 T8 T0 z            int[] count_array;" u: E/ G5 v3 j, r4 i7 T
            Tag[][] curve_array = null;
( A9 ~# a7 [/ X3 t8 K            double[] tol = new double[2];
1 S2 Q- Z- a* z: G" t3 R; _9 m/ ~5 \! K
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
: z" @$ r1 y+ K7 d/ W' t% \# n) ~            theUFSession.Modl.AskAngleTolerance(out tol[1]);
3 F+ y/ ]5 r" Z! S3 H
3 z0 M. `. k* Q+ d' W* v6 }            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
1 l/ Y  |- T1 ^2 b2 E                workView.Tag, out loop_count, out count_array, out curve_array, tol);0 e5 n1 \4 @; U- F5 O
% f; _1 u) U2 G
            Echo("Precise Outline Loops: " + loop_count.ToString());1 s( B; |3 s: }$ X
            for (int ii = 0; ii < loop_count; ii++)2 F- b4 U( U9 P  T) H5 [7 W+ @- e7 @
                for (int jj = 0; jj < count_array[ii]; jj++)
' _6 ], W( v/ X                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));8 Z! X, R; A; a' O, T6 |
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());/ _3 P1 U* b* D1 p7 Y
$ r* m1 b7 t! f* o1 H# Y2 b5 \
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
) |: U, b$ i8 x3 S' F. Q            int curve_count;/ i3 u! I: B: V
            Tag[] outline_curves = null;8 u& B) {4 M& F
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
' ~5 j( X( D- Z1 v$ ]! j, h                workView.Tag, out curve_count, out outline_curves);
( ?3 s# s+ \( k- P5 K            Echo("Precise Outline Curves: " + curve_count.ToString());
8 M8 n7 S$ q  r, h( F+ R1 o            */
) n$ n6 N+ m) e+ `$ M" z" B. E        }
" ]% l6 |0 ~, C2 c' F% U4 ~: F9 x3 G- @5 a
    }[/mw_shl_code]
3 y/ d4 r! r! P+ t) w# M8 }* t/ M0 {[/hide]
' B' _- u5 S2 _: r% X
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了