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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
* n" r! n, o" L; Y% U9 d3 b1 Y/ H8 o& C! [
UF_CURVE_create_shadow_outline (view source)
0 }+ a- |- j. u0 m5 J
+ C; _0 p! a7 Z7 w; G3 j% q# EDefined in: uf_curve.h4 g9 g! O; o8 M! c7 I/ H
- s# o1 o- c0 A4 ?

+ T; ^+ N+ p. J+ X( |5 o6 h, \' hOverview
$ u6 p$ ~, C2 Q, J
+ `' C. E0 L( b0 r6 f% XCreate shadow outline for a given array of solids. Solids passed to this 9 M, E5 B/ E, q
routine must be on a selectable layer and visible. If created shadow curves
& x! o( {2 k. J# O' ]& m  u* T+ a) qcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
1 V" l' |- t# j0 Eshadow curves.   Q3 h, M1 T' o0 s

7 {1 ]+ ?4 T' c7 c; `- F& q: F' r6 K- ]7 _
[hide]
$ n; j8 L. S) O& J0 [, I' x& j- M( t5 Z/ \0 r: Q& z" a( T
[mw_shl_code=csharp,true] void DoIt()
: \4 h( D$ W, ~$ {( N2 |    {
, F6 I) v5 N; K  [8 p        if (theSession.Parts.Display != theSession.Parts.Work)
, P4 A: \9 v- O8 p. ~1 Y8 o            theSession.Parts.SetWork(theSession.Parts.Display);
- z2 |/ A# s/ O2 M
' {! ^* v) w1 N& X3 |, ?8 m# }' T/ B! ?# ^7 h/ E( x: O0 c
        TaggedObject[] theBodies = null;
5 Z# L8 I# f8 }5 w' c        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)8 V* B$ I0 \3 _- ?+ N( M6 e5 B3 }
        {3 h5 W( E8 \8 S- T
            Echo("Selected Bodies: " + theBodies.Length.ToString());
( ]2 z9 R- S2 f& V9 X            Tag[] theBodyTags = new Tag[theBodies.Length];
/ ~# z: h% n7 U  U5 C; @            for (int ii = 0; ii < theBodies.Length; ii++)
$ p4 @9 t# ?$ t, P: J& N6 [5 p' S                theBodyTags[ii] = theBodies[ii].Tag;
' I0 a4 C8 N/ H* o( A" e
5 X  p: v/ _4 e' R- y! S            List<Curve> theOutlineCurves = new List<Curve>();
# R0 ^- K) g. s/ Q            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
5 g5 M1 v  K1 U  i            int loop_count;
1 ]. l# `* s/ Z) M, \6 Y            int[] count_array;
. \1 y* y; C/ o7 p# H            Tag[][] curve_array = null;
  @' h& a* `) a4 _/ e+ o1 Z            double[] tol = new double[2];
- P) j" D- r1 x7 {, {& l5 P, p, o
" s5 A# L$ |) Q8 U2 E# H$ x            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
7 {( i  C' X+ L: b$ v. |% u' ?: U            theUFSession.Modl.AskAngleTolerance(out tol[1]);
/ g2 E  c! E5 |; |/ W+ G& l9 D) R' [
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
8 T+ a% i9 N$ V- C- K# l+ h* P                workView.Tag, out loop_count, out count_array, out curve_array, tol);
8 ~. z' y9 [% X
) a; \4 ]) B) L: _' n; D            Echo("Precise Outline Loops: " + loop_count.ToString());
- p; m3 J) E1 U* _6 s+ M$ E% A) [            for (int ii = 0; ii < loop_count; ii++)
  m! ?8 n9 k6 v* [. A6 U: w0 K+ A                for (int jj = 0; jj < count_array[ii]; jj++)$ j# T( ~9 m( b  T1 p/ J
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
( w1 a, Y! b/ X7 U' S2 R            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
* ?$ }' {% b4 t" ~0 ^/ `( `; P8 e
" D+ ~: d1 g# V            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 2 c' n% o, r) G# F4 S
            int curve_count;
4 t8 U4 a0 D* f* Q* x6 l  C" ?            Tag[] outline_curves = null;. I+ ~9 f; c. P9 k( ?: Q5 q
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
" e: t% S9 p& A* ?                workView.Tag, out curve_count, out outline_curves);
, R% Z) K% _! X6 w6 }            Echo("Precise Outline Curves: " + curve_count.ToString());+ Y6 c7 G+ {" P" Z6 V% C. C% [! T
            */2 K& t2 L8 l; [  l
        }; o- y6 ^# a. L
  Z7 l7 H* n$ V3 v1 ?" C7 @
    }[/mw_shl_code]
) ^5 M. |! Z! a: N[/hide]
( g, S3 ], e9 q7 I( ?
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了