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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓3 v9 g8 j1 K! ]# D) r
. c- |, L& h8 {; w1 X  G( L( E
UF_CURVE_create_shadow_outline (view source)
$ _9 x- h$ E/ B4 t- m - a1 @% [/ |/ Z5 N; S
Defined in: uf_curve.h
  ?7 y( H1 H" T6 T5 i2 k1 o2 a , W9 q7 w5 u) X' K! k
" k9 |% e" D: j4 I5 I* m2 j0 X+ B
Overview8 A/ c( F7 M& c: C3 ^

4 d( ?& \& e4 ^% d* a5 yCreate shadow outline for a given array of solids. Solids passed to this & @: B$ \7 N. T" u3 o/ k' I' A
routine must be on a selectable layer and visible. If created shadow curves 3 v  ^/ N% c! a" \, j" r' v
can not form loops, please use UF_CURVE_create_shadow_curves instead to get & y3 ^# H9 l# z* O; w
shadow curves. 4 g% W7 a9 H, _) q

4 R6 E5 q7 e+ X
  y1 f: k- {# m# v4 }& v[hide]
  G! @; R7 v, N. R* J9 d" i) a; H# p9 r4 L$ i4 `( O8 i9 W+ {- R
[mw_shl_code=csharp,true] void DoIt()" E4 E6 C$ e8 S$ Y
    {
* j- B; D3 M: C! K2 Y        if (theSession.Parts.Display != theSession.Parts.Work)1 g+ x$ [& i/ T
            theSession.Parts.SetWork(theSession.Parts.Display);
" x' B5 X: r, H. B2 w- o2 G. S' f
! f4 S- _* J9 E2 Q. s/ _+ {8 V
7 r% H, V3 f) M# X6 F( Q( H: I        TaggedObject[] theBodies = null;
/ L6 e0 o# J% U        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)( I8 t: J$ u/ f( X& _7 L
        {
- D  {* L9 x9 c5 Q6 Z            Echo("Selected Bodies: " + theBodies.Length.ToString());
) J! z- u5 ?7 {            Tag[] theBodyTags = new Tag[theBodies.Length];
% s! x8 i1 _" I& p$ y5 D' W' L            for (int ii = 0; ii < theBodies.Length; ii++)
7 i% N5 z* D0 L- `                theBodyTags[ii] = theBodies[ii].Tag;
; }* K  _  A+ Q# y3 s- n/ z" P7 R6 }" y, {; l
            List<Curve> theOutlineCurves = new List<Curve>();
; O- ^& L7 k, X* T% i& e            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
& M7 l+ B4 |5 a0 Q& d" b            int loop_count;; b# t9 _8 k  \8 o  X- P# i
            int[] count_array;
9 F: G! M$ i$ J; {3 G5 b            Tag[][] curve_array = null;
* M! H8 K& H( i  c9 G0 W            double[] tol = new double[2];
# {* \) m4 _0 X, \) c6 {
8 _& F3 v8 f: Z' Q            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
7 b/ X) ?4 X" \            theUFSession.Modl.AskAngleTolerance(out tol[1]);
+ R) H. I) s" V3 i& {( Y1 M
) \+ ~  D, G+ m0 }            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
. F; u2 \! O+ B0 y1 {5 Z/ e                workView.Tag, out loop_count, out count_array, out curve_array, tol);- X2 b  L3 ?) S/ t0 m; h
. o: G8 b' X0 }( |
            Echo("Precise Outline Loops: " + loop_count.ToString());
5 I  V; `" P* c: J            for (int ii = 0; ii < loop_count; ii++)& D8 d/ k/ V1 u; s5 k/ \
                for (int jj = 0; jj < count_array[ii]; jj++)0 F3 [8 M5 Y; e4 U/ g4 s
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
* a* ]) Q# g! p, X! x& X6 m            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());5 `+ {6 O; m: b6 N  x
7 h9 V- B5 z! Z; d
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 6 H- d/ W  \/ x% G
            int curve_count;
( G' d4 Z2 Q! v            Tag[] outline_curves = null;' L" g: O6 v, R, ?
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
0 ^  K& e4 d+ l                workView.Tag, out curve_count, out outline_curves);
! O. a& k, \! h! ?            Echo("Precise Outline Curves: " + curve_count.ToString());
% l* @6 Z8 r5 n0 e            */. }1 f" h; T1 Q, q. {! ^
        }( K6 Z# _+ J1 v& c: O4 u+ L( M  K

* Q2 I- K; ^- ?1 n* u" P    }[/mw_shl_code]* m, O' E2 y4 M4 o/ J
[/hide]
! k5 B6 B! D% Q7 L
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了