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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
6 D% {1 C2 T3 _( b/ y  C: [" w$ ~# |- ?* k5 F. Z9 g/ a
UF_CURVE_create_shadow_outline (view source)0 d8 h% Y% v9 y, h) X
. w. S! b5 h; c
Defined in: uf_curve.h) m' a' Z$ m+ C7 G
, S% S/ ~+ D- q. k4 W

1 d2 m( f$ G, x3 {& k9 x" Z( k- lOverview5 t/ {/ D7 J9 d0 e+ L& X  x% _

/ E4 i1 Q' m3 G5 H! a8 pCreate shadow outline for a given array of solids. Solids passed to this * T7 B0 [0 u* }  `
routine must be on a selectable layer and visible. If created shadow curves 9 e- q. y3 L3 i: B$ t, H# ^
can not form loops, please use UF_CURVE_create_shadow_curves instead to get - M" Z/ h& m0 m" i! r
shadow curves. + v/ d! a& y1 j2 g/ m

$ F3 R2 v5 c; [9 D3 `
  |5 j# W0 S' I( k" K[hide]' F' ^: s; H% m

+ d- ~8 K) _+ z[mw_shl_code=csharp,true] void DoIt()) j5 f( h/ U9 m" _2 V. U. ]
    {& k# [, F9 \" i/ T# S$ F8 F4 b( R
        if (theSession.Parts.Display != theSession.Parts.Work)
. s4 }2 L% R" Q: y6 A            theSession.Parts.SetWork(theSession.Parts.Display);! W& l4 x/ o3 `* V1 r0 G: R
9 [. C" p! U( A4 I6 X3 X- F$ J

" R& e9 a) G2 o' Q/ W/ ^4 H7 L        TaggedObject[] theBodies = null;# q  t! X( \3 E7 R$ ?0 d* }% J
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
" l4 j3 N; e- ]9 s6 R9 p  H) t        {; ~. w' H, U$ F
            Echo("Selected Bodies: " + theBodies.Length.ToString());
( l3 y0 z4 C, U1 b4 [            Tag[] theBodyTags = new Tag[theBodies.Length];  R# f) _" E4 ^) L  T* l
            for (int ii = 0; ii < theBodies.Length; ii++)
6 F& L2 e. A; X; g4 u5 W+ P                theBodyTags[ii] = theBodies[ii].Tag;3 J5 _# O" |; v' {4 q, T: J
8 X3 R  S8 J' b- K$ C# [
            List<Curve> theOutlineCurves = new List<Curve>();
) @4 C' e  y7 }& f! u            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. D4 h3 n: f3 r' M            int loop_count;" g" u7 H" y; R* N# z/ N$ B3 I
            int[] count_array;7 S/ ?$ }6 [3 Q5 b. t/ o3 v
            Tag[][] curve_array = null;: }& {' r! h" x" P. Q
            double[] tol = new double[2];
2 p* a5 G! c9 S/ ]6 `" P
6 o$ |$ Y& P0 t* N2 J' a6 N/ r' L( j            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
! b) W( R+ z- h7 D# z. ^. K            theUFSession.Modl.AskAngleTolerance(out tol[1]);& A1 s0 \2 h5 A; |# R: |" t4 `9 o
0 v6 l5 _; S  Z0 m4 M% ?
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags," L- X6 R8 K1 }
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
& M" L) I+ [2 a% a( _7 d
- t1 q3 u  r2 L' c            Echo("Precise Outline Loops: " + loop_count.ToString());
. h$ {0 Z* n# v0 H! O4 D            for (int ii = 0; ii < loop_count; ii++)
% m* L2 q: w( c6 Q0 }. {5 V                for (int jj = 0; jj < count_array[ii]; jj++)
/ c' t+ S7 \; T5 V" [: `                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));$ N2 h. W. S, G2 E2 x9 w
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());! H9 L# s- o% S+ A) o0 v2 J
4 C/ ]' ~; Y# l1 b! z: L" Q
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
8 P" S+ P, {& I. z% ~            int curve_count;
9 _# H6 R0 G  _1 _            Tag[] outline_curves = null;
2 A4 [( d. d) l$ i, q$ }, f            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
; h- [/ n( s; Q% {) {# f! P3 Q                workView.Tag, out curve_count, out outline_curves);/ o2 X: N* e8 K% `; H1 G. p, l" p
            Echo("Precise Outline Curves: " + curve_count.ToString());
2 t: Y2 P3 L( `6 X% L; `            */
8 N* z$ i$ _, f! x        }
) ?* ?3 R( X* H
3 ?0 G# a" B  t5 ^4 E  I7 N    }[/mw_shl_code]0 H# ]4 w3 A' v
[/hide]9 \1 ^% t* x6 L& P, Q5 J! b6 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二次开发专题模块培训报名开始啦

    我知道了