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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
" o1 C& `) R4 o& v, N* }, C4 z" h. I$ A' l+ s& b
UF_CURVE_create_shadow_outline (view source)
+ p/ @" Q1 |: L) |
0 y1 m& f. w, [+ |% v3 \! hDefined in: uf_curve.h
* q) {" g  m7 g# s  Y0 ~9 q! h
" L6 i, h( H& S8 f( |. k3 A' a  I2 u5 R2 y
Overview
7 M, p' q( f3 j( c8 t0 \! N) {1 k5 w. H; M6 B: ^2 U5 ]
Create shadow outline for a given array of solids. Solids passed to this - K/ J1 e' Z  ^. z$ F
routine must be on a selectable layer and visible. If created shadow curves
6 o# {& E$ E* t  \3 mcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
) `! A6 P% A$ l. T0 ^shadow curves.
  y* l) D2 [8 E) l2 ~$ O1 o# d
% `  u$ Y3 Y/ p6 w: g- M" h( r3 g5 S
[hide]1 H; @+ ~" A  k

& U) w2 f  t# \) @: }[mw_shl_code=csharp,true] void DoIt()
( A8 I% u5 u' ^6 O    {+ z4 q* x9 z) `
        if (theSession.Parts.Display != theSession.Parts.Work)" ?! w! H% o: O& g+ }# w& v7 q
            theSession.Parts.SetWork(theSession.Parts.Display);+ B; K1 p, P) |5 l7 g; a

3 x8 A) [+ F4 r7 s5 V" O- z
7 O, ~. n+ H. W( ?        TaggedObject[] theBodies = null;
& S; d5 k+ T( b; B& ^        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
6 j9 ?/ X9 J' I! ]3 s9 l        {
' A# \+ W& K4 d            Echo("Selected Bodies: " + theBodies.Length.ToString());3 a. l, m; w8 i- c9 Z5 S0 ~
            Tag[] theBodyTags = new Tag[theBodies.Length];
; a3 v5 p* J1 h2 }            for (int ii = 0; ii < theBodies.Length; ii++)6 r) l3 Z0 V/ Y" a* a1 M; S
                theBodyTags[ii] = theBodies[ii].Tag;
  M& U, O* q" C5 C, ^: }, a4 s9 i6 }. t/ F+ c' B: r
            List<Curve> theOutlineCurves = new List<Curve>();: y0 X4 m0 V2 w- a8 p7 K  k
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;3 `; g; ?6 u2 R
            int loop_count;; W% X! J: o. A) n* c/ ]
            int[] count_array;% E6 k' f. u6 J
            Tag[][] curve_array = null;4 ^* m! G! i# M1 u" o6 R
            double[] tol = new double[2];
! z3 m# T  `9 a  C) S& s: X% H0 P; K7 ^6 Q. i3 b7 q& {3 ]
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
/ q2 G( b  e3 |' h, ~( l            theUFSession.Modl.AskAngleTolerance(out tol[1]);/ m8 M0 L, d% L0 I* A! o
$ \3 X5 N# D! g) P2 R6 a. @
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,; Z+ W$ C& T$ \+ m: w; Z9 |
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
, S7 h4 |( {7 U' t. f( L: L, {2 s# G+ u: N+ ?" g  M% G
            Echo("Precise Outline Loops: " + loop_count.ToString());; Z# I# [6 d$ |6 o/ \6 I9 S! y* F
            for (int ii = 0; ii < loop_count; ii++)& V7 o: T5 k: n) A
                for (int jj = 0; jj < count_array[ii]; jj++)- N: t) c) j8 g8 O( r* z) \
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));! w" V! \4 z5 R2 Z/ P# w+ s' t- Q
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
) K* y2 V$ J5 W3 \# l  d
9 O7 Q9 p3 Z! W; Y# C; f4 [            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
5 G2 f$ J: v9 E7 t            int curve_count;7 ~: P. k# Z8 \  Y$ \: R& o
            Tag[] outline_curves = null;
; @( M% _) `) T9 z$ A2 ~5 E            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 6 t7 ?6 o$ W4 s" B
                workView.Tag, out curve_count, out outline_curves);
& e- f( r8 A: t5 ]' }/ T2 a$ B            Echo("Precise Outline Curves: " + curve_count.ToString());" {- X# O$ J' D# \' d
            */
# C$ g3 k- a. T        }+ |( z4 f0 }* E& a  ?4 m1 x7 k7 z# f) Y
2 x8 r6 |9 e+ K5 S
    }[/mw_shl_code]: l8 x  R# I, Q) |: E# \; c
[/hide], s: K5 B$ V+ h0 ]; 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二次开发专题模块培训报名开始啦

    我知道了