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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
, ?' \) X5 X( G, Y& b' ~" Z# X4 p. U1 _$ l+ k. a7 m
UF_CURVE_create_shadow_outline (view source): }- {9 f3 Y" I, m. G

  ^9 U4 q: Z2 c% Y& ~! ]Defined in: uf_curve.h+ ]% N$ u/ T6 X% |1 K" h
$ M/ ^# P$ B% D; c7 w, M/ j6 d

) u: [9 [" j6 j  q+ H2 T& c4 xOverview
: e" e- `3 T, R5 @% T9 g: Y1 k
Create shadow outline for a given array of solids. Solids passed to this 0 N( }9 y7 r* e* Q5 L1 e! |. X
routine must be on a selectable layer and visible. If created shadow curves
9 C1 C6 l+ v& h# [! c0 vcan not form loops, please use UF_CURVE_create_shadow_curves instead to get 8 i& [" n+ e/ W& C1 \
shadow curves. 5 f) j7 d2 ^/ u

& V& p9 K( v; N) k! d) [9 U3 |0 V' |9 p4 y/ o
[hide]5 U4 g1 U8 Z! A) q$ P

7 N' |  N; e, }+ D4 @( w[mw_shl_code=csharp,true] void DoIt()
' X' Z, ~6 R( v) i3 j! B, W5 A1 Z    {
/ ]2 k; v: c/ X9 @        if (theSession.Parts.Display != theSession.Parts.Work)
) l  @) ^( t, r            theSession.Parts.SetWork(theSession.Parts.Display);. p6 Z! r: b& G8 X) r8 V# ~
! `7 h/ [; G4 g& `
5 b/ Y+ T! d4 f# [/ c/ @
        TaggedObject[] theBodies = null;
# Z. t6 j# ]/ l5 x        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
, h  Z5 L% g  {7 {/ Y& E$ v  ?7 a: P4 T8 X        {. g; _. c1 Q: ]6 I
            Echo("Selected Bodies: " + theBodies.Length.ToString());! r/ i( x4 Z4 m" ]! J
            Tag[] theBodyTags = new Tag[theBodies.Length];
5 a8 ~# [+ p3 v/ z  k- ]. h# t            for (int ii = 0; ii < theBodies.Length; ii++)3 R" e1 z$ p1 h& |: s; W* t
                theBodyTags[ii] = theBodies[ii].Tag;
, R+ q2 ]: r. \: P5 N! s1 z6 v' |4 q4 L' k7 s0 U+ O( R2 Q' q( z
            List<Curve> theOutlineCurves = new List<Curve>();  E. D( @3 H" Y7 T% U$ h! Q  }7 _
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
7 ^/ M# Q4 n, J! j            int loop_count;2 S3 v  V8 W2 a# y
            int[] count_array;
8 _* q+ t1 B/ I. w! C& G0 @- Y5 e            Tag[][] curve_array = null;
, }$ g4 W, Y: w, l            double[] tol = new double[2];/ t) [6 D" [  c* u

5 R' P" `& w4 y0 ~3 i            theUFSession.Modl.AskDistanceTolerance(out tol[0]);0 E) T* _( V: ?* l/ m: J
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
& g' j/ o3 X  H8 o* @5 l. g2 }
4 {5 c! p5 c6 c7 L2 b% d5 U            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,' y6 a( Z# r# E9 H2 F7 {
                workView.Tag, out loop_count, out count_array, out curve_array, tol);; b5 b  B0 G0 f" j
8 Y, D" F2 J& }
            Echo("Precise Outline Loops: " + loop_count.ToString());
9 m# E' N( P: \5 N" p            for (int ii = 0; ii < loop_count; ii++)) z. I2 q/ g3 v) n/ h
                for (int jj = 0; jj < count_array[ii]; jj++)
" N% J8 }. M! e: E! ]                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
6 T% I$ w& }/ h0 `% l            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());$ C2 h7 ?! H7 S1 g, Z
8 P+ Q' l% N) I) h
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
  U: X& ]# q1 c# M  U% f            int curve_count;8 ]1 _7 N: J* Y1 E" z7 a+ e
            Tag[] outline_curves = null;
9 \5 W0 \0 X3 H( U            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
8 X6 ?! u% j( ^" K) L* l' T                workView.Tag, out curve_count, out outline_curves);
9 U& Y" m9 }" E9 P. H' y. j            Echo("Precise Outline Curves: " + curve_count.ToString());
% T, N' d& g, y7 H5 ~- A1 s( C            */
. \9 {2 o- x. J0 i        }& b/ ?) D) J( h8 m& ~+ a/ s

* k# Y, ^' e2 c6 v  _    }[/mw_shl_code]
0 }2 k. }. D1 J* V[/hide]
3 l' f5 L; @# c$ e% n3 J0 Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了