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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓; ?6 }9 ?7 H8 E5 F) u

) M/ q- R4 `* f1 ?& DUF_CURVE_create_shadow_outline (view source)$ g6 u# K/ H; }+ ^
3 {2 U5 |: x3 ~/ ]9 t
Defined in: uf_curve.h4 F7 Z- h; _4 f3 l2 L
4 u3 ~0 C, w  s: e7 |8 i

$ h: S% V6 l$ [" \7 XOverview6 Y$ ]" k. W/ E- I8 Z
  q4 ?# V' {4 z- s. ?6 A, B; E
Create shadow outline for a given array of solids. Solids passed to this
  I2 u# j7 N" u8 ^3 q5 r' P  R2 rroutine must be on a selectable layer and visible. If created shadow curves
9 E* h: `$ n/ ^$ Bcan not form loops, please use UF_CURVE_create_shadow_curves instead to get 8 O- Q6 ^5 q# T4 ^
shadow curves. 2 R8 i7 \7 [+ p; O: D
5 q5 p* O9 L0 G5 b9 h# \4 @; T
7 C0 k+ P0 f# w  C6 V" R
[hide]; x) j3 h( P# I6 U9 x" i

: c9 H/ R9 ]& m5 ]6 V5 G$ n[mw_shl_code=csharp,true] void DoIt()
+ w! K- R! k4 R) R& x) r% H7 p    {5 p7 X+ U, g3 l, {" W) O
        if (theSession.Parts.Display != theSession.Parts.Work)' |9 l/ _! I% y4 Y6 t2 O, d
            theSession.Parts.SetWork(theSession.Parts.Display);
) z6 M( Q% {, \+ f8 L5 w" r8 C7 ?, X
) V/ W- X$ e& Z) K$ g6 w  o- \" K) v* w% H8 N
        TaggedObject[] theBodies = null;3 n) v4 @* V; V' N: ]! \
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)% t+ b' U" l: |* e- O0 F. |3 J3 H
        {: }! \* J! U% y4 O5 s* l* h0 z/ w
            Echo("Selected Bodies: " + theBodies.Length.ToString());
3 P0 K7 y) n$ Z. V2 k# c            Tag[] theBodyTags = new Tag[theBodies.Length];
* }# i- B( \+ s- B            for (int ii = 0; ii < theBodies.Length; ii++)
& k( e; Z8 w$ @                theBodyTags[ii] = theBodies[ii].Tag;% V% v$ i- x0 f# x
, V4 ]5 W! c7 W2 s
            List<Curve> theOutlineCurves = new List<Curve>();4 e' B6 }# g  p$ T- O  c# d
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
% H; [! T  J/ Q! W2 G, f# }            int loop_count;
( {1 g; u4 q, d) I! |            int[] count_array;
$ g' {( g0 |7 i- P0 {7 s            Tag[][] curve_array = null;3 w$ k' q& u0 c! D+ k
            double[] tol = new double[2];" P, p8 C2 x( \2 k
5 w% F8 T, \  m/ T# d0 o, M
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);, L5 I# d$ W# t; f- y7 ~4 a# W, s
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
6 t; n! w% A0 i' e) U- Q; q" O8 R
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
2 v; n- X8 x) j+ z& p$ s+ {                workView.Tag, out loop_count, out count_array, out curve_array, tol);
7 v$ ~: m  O- M1 Y8 A* J( w5 d4 u# [0 n
            Echo("Precise Outline Loops: " + loop_count.ToString());. y0 _# s1 H" T3 k
            for (int ii = 0; ii < loop_count; ii++)6 L& H- n4 d! i( @: V# k- @0 f
                for (int jj = 0; jj < count_array[ii]; jj++)
: m' g+ B2 w& N6 \1 H" u1 |                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
6 i8 _5 I6 Z, D. V            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());/ X: x- c  H1 Q  g( Z; f

' |1 B8 L6 ^: S- y. A. H5 n            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 4 K+ s4 v- N) n0 _$ U& e
            int curve_count;! L' ~* n7 q* o% L: c6 K( r
            Tag[] outline_curves = null;
/ V  x' n" ~. d7 A- X) E            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
% u) s! h$ G5 E7 U0 v/ ?                workView.Tag, out curve_count, out outline_curves);
' q- @& y; B7 C: G) C            Echo("Precise Outline Curves: " + curve_count.ToString());
6 I+ X' Y4 f2 L' N: C5 P            */
/ L( H  `* m0 Q/ O' [. x/ t( K5 h) ?1 z1 ?        }& Q" K6 y; H3 E0 P1 m3 v
" _% k! a3 J% ]5 H
    }[/mw_shl_code]: p" y* i0 ~8 w) O* |/ |
[/hide]
0 A- L. T6 ~6 C1 K1 k9 `6 h3 F: w
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了