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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓& m) v6 i4 R6 f1 i) f5 Y* q. U
2 R2 @; g( \( w8 F7 |+ O! R# j7 {
UF_CURVE_create_shadow_outline (view source)* u) D' k3 b, F: O
9 q/ P' m& S$ w/ M' P8 a* z/ }1 a
Defined in: uf_curve.h0 v1 D+ Y0 a& F( n! g; \
( }7 [  i! h& q. l+ }

5 ^, n2 [& |* |1 {" WOverview( f; q  T3 V$ g. J+ |( n

+ r4 ]. {# L* b! c  SCreate shadow outline for a given array of solids. Solids passed to this
1 B/ E+ s1 g, I1 q( m; aroutine must be on a selectable layer and visible. If created shadow curves ' b5 j6 l- t4 E# }( @* l
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
8 s. j0 z1 h& b% U2 n6 Z7 Lshadow curves.
+ i: U9 s' ?# c6 D  Y  B4 t* u! ]; I  v' i

: W1 }  z; k, T+ f4 \[hide]1 h  Q7 P2 w, d) w" W0 z
* V' Z  Z4 J! d. Q+ J5 E5 |1 Z
[mw_shl_code=csharp,true] void DoIt()" w6 [) r5 v0 r! ^) ~
    {
0 w$ Z" |/ d# l/ G3 G! U! D- ^        if (theSession.Parts.Display != theSession.Parts.Work)# v3 S, ?- q; L% D
            theSession.Parts.SetWork(theSession.Parts.Display);9 Z, p* G  X- J$ ]5 n- k. n* r9 b" b

- T* S4 R, S4 s3 T$ ]! z
* H0 L9 {* t& F) A        TaggedObject[] theBodies = null;/ {; C( R! @; y' Y! j$ D  m
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
/ _3 ~- {/ i( q) }9 L2 ]0 K        {
6 y9 Z2 }  d2 n' b( c  w% }            Echo("Selected Bodies: " + theBodies.Length.ToString());
7 M% e2 H9 A$ ~6 k            Tag[] theBodyTags = new Tag[theBodies.Length];
2 _- a" Q; m3 E* i+ S            for (int ii = 0; ii < theBodies.Length; ii++)$ }( s- d) p# |9 [+ |5 p
                theBodyTags[ii] = theBodies[ii].Tag;
8 P' U' X0 ?5 f1 q! T( f$ _% `9 Q
2 S: P5 a8 d% b- }+ f# |8 n0 T& Y            List<Curve> theOutlineCurves = new List<Curve>();/ R6 ]/ I. ?% r) h% B! a
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;3 Z; t/ O2 l2 ~6 h
            int loop_count;
8 q. S6 i8 ?- M* r' X9 L+ m            int[] count_array;; Z4 |$ J$ D: ~' E7 p: Z
            Tag[][] curve_array = null;6 \0 k4 w0 K) b2 k
            double[] tol = new double[2];; T  @  t4 k8 d& Y
  Z8 B: k$ a% m
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);1 h% e7 b5 H0 y& [& R. E
            theUFSession.Modl.AskAngleTolerance(out tol[1]);" A# m8 \/ r; W( z: a4 p

/ G: n2 r, D1 D            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
; e! N7 S- K  k8 k! I1 e                workView.Tag, out loop_count, out count_array, out curve_array, tol);0 C! u5 U5 F1 N) T" J: D

3 o' s) W% R: J            Echo("Precise Outline Loops: " + loop_count.ToString());
1 p& m. C7 p1 j$ t9 G            for (int ii = 0; ii < loop_count; ii++)* y3 l4 h: r4 s* l# V
                for (int jj = 0; jj < count_array[ii]; jj++)
  @# k8 q; h. }" O                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));6 d' J9 K9 _7 O
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
5 z; O/ @1 H- r, t. }6 j/ ]5 Q0 j1 j+ x: s( C+ D4 Z( e
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead & w6 I: B; R4 Q. ]$ ?; U& [1 X, ]! [
            int curve_count;% A6 W1 w; [  D0 d; U$ {: e
            Tag[] outline_curves = null;
+ F4 G; i( p+ B$ y, O2 i4 q            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, ! N+ m) `* }" t" Z* h1 J7 ?% t
                workView.Tag, out curve_count, out outline_curves);
  I! n: \, z. m% \) h+ d            Echo("Precise Outline Curves: " + curve_count.ToString());$ q2 Z2 l1 _0 e0 W1 S* B
            */0 k& B/ M6 m2 O9 j% X7 D% }1 @
        }
9 G- i' H) g% D% ]7 @
1 M  j# m  r9 `3 `8 U/ G    }[/mw_shl_code]
+ A; K" H/ U2 l& @4 H# v$ Z[/hide]
# y! T5 |- u) ]3 U
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了