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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
3 a  J. Y* s) Z7 _1 I- E" x9 t( c  I+ W1 ]% k7 P0 S
UF_CURVE_create_shadow_outline (view source)
! W* y+ }# [) U' m7 \0 N & f8 `/ h4 s% U) O/ G
Defined in: uf_curve.h
5 i( p8 u( o7 r% }1 l. x
' d2 A: |: y. x2 T1 T1 ]- W+ T/ n6 w. w% Y7 d
Overview5 ]5 n2 B6 Z5 q' j

; j$ r' h  C* J3 lCreate shadow outline for a given array of solids. Solids passed to this * c3 c! a. u& e
routine must be on a selectable layer and visible. If created shadow curves ! g) e& ?- ~+ G" |6 Z% Y
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
0 o' M# Q) }5 K, s! i, k, ishadow curves.
$ ^  W1 W% a9 m5 y
) R8 V. D# t6 z+ m" o6 T% \7 O  ?  K/ J3 `
[hide]; D5 l! c0 B# \# t1 q. i

! B! K, K/ ]+ W* _) a7 p[mw_shl_code=csharp,true] void DoIt()
2 Z, i4 A# ~* q6 X    {
  i- G) }6 I7 \        if (theSession.Parts.Display != theSession.Parts.Work)
8 w" M) V! u0 A$ d& |1 a9 k            theSession.Parts.SetWork(theSession.Parts.Display);
# T( ], n8 e, U/ P: v" {" G
3 F, R4 y3 q8 p
# D+ l" v% N. `4 K6 g        TaggedObject[] theBodies = null;
/ i( U+ `4 M2 s" q' d        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)- ?$ j7 t) ]5 L% d' y
        {5 Q3 s% a/ [6 b: x% u7 U
            Echo("Selected Bodies: " + theBodies.Length.ToString());
2 B: O% i9 T+ i" Y5 u) h            Tag[] theBodyTags = new Tag[theBodies.Length];
6 ?0 t0 @& \* U  t! S            for (int ii = 0; ii < theBodies.Length; ii++)
7 H- R* i; t8 F$ D8 `. x- P                theBodyTags[ii] = theBodies[ii].Tag;' N7 o' O7 T2 N5 n

( ]* R% |* y3 d1 m            List<Curve> theOutlineCurves = new List<Curve>();
# \7 Z* K- t4 E& y$ d& l# w3 L            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;4 D# a# X* ?0 q( T+ V4 |5 U* C0 i$ a
            int loop_count;
5 }( q: ~4 f# s# D. q3 Q. g" m            int[] count_array;
3 a, E: I% B) }7 K9 X            Tag[][] curve_array = null;
8 \3 ^5 S& \% M. Q) O+ z6 a            double[] tol = new double[2];
9 f  w" K+ g$ h6 J# N& @* B3 P. ]* P& }/ I5 L4 g' F  l
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);: A% N; M' ~! A5 ?. O& J! S3 M
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
* e6 V& @8 j) h  H0 O9 {2 w$ T8 O5 X2 y3 n9 V) K! J4 L/ c2 x
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
& A: N7 p1 l, [                workView.Tag, out loop_count, out count_array, out curve_array, tol);
* Z2 E8 q* P' E# e. Y8 w" U3 p) C/ ]5 J2 x) |# [
            Echo("Precise Outline Loops: " + loop_count.ToString());2 J7 S9 R$ c& d& U: f' W
            for (int ii = 0; ii < loop_count; ii++)
; L! z$ ~5 P5 C8 f3 x( f; O1 x- B                for (int jj = 0; jj < count_array[ii]; jj++)9 H) Q: D& ~' P: \, v! ?3 g
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
8 L6 c" P1 ^0 D/ i1 s/ _# l            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());2 I9 w0 l5 u  a" B5 A2 O
, |. g/ \# q' g9 \4 Y6 s6 m
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead ) T. p6 U" P& ~' E% q. c  j
            int curve_count;
, V3 Z% d5 g1 A9 i- B            Tag[] outline_curves = null;/ j9 h7 r+ F9 Y& a/ O- l
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
6 s, ?9 q9 k0 w  u/ ^* P                workView.Tag, out curve_count, out outline_curves);
) X& x) D$ k3 a- n; ~/ I            Echo("Precise Outline Curves: " + curve_count.ToString());8 Z+ C) C( }1 x0 f2 }) e8 z
            */
4 F" s  k" I' T' k  l) I, ~        }* Z9 B) f; ?% \, \* W! k5 {
- ?2 W1 h& w6 o  m$ Y
    }[/mw_shl_code]- G3 j  c: ?  q" D" ]
[/hide]0 e- E. ]6 g/ B: A, ^
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了