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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓# }/ G( {+ E% ^6 _

! j; ~) i! y+ B& p* dUF_CURVE_create_shadow_outline (view source)* W  W# W- Z( r7 M" W
: c& O6 N7 A2 D: U' h' [5 n
Defined in: uf_curve.h
( h7 T( y+ v" @6 @
! @6 Q. o1 q7 Z6 \
. b% h2 a; [8 K+ G: q+ jOverview
' F' H- O2 n+ X2 W: f( t
: |1 N6 R; z7 U3 cCreate shadow outline for a given array of solids. Solids passed to this
6 G( w; W0 a1 @7 e5 Hroutine must be on a selectable layer and visible. If created shadow curves   E" a$ L  z7 [( F4 R
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
7 Y- n7 I# W) g9 _  mshadow curves. ; u2 x  }  b9 O9 }4 }
* V  H$ ?5 g' o6 \- X7 u, U9 S
) i; e. o1 q) F  ~, v9 X* S" S. F
[hide]& c& a7 g/ K+ f

! E9 u9 I3 L* `[mw_shl_code=csharp,true] void DoIt()
. l6 y% l2 ^5 A8 X% M8 q    {" V, W6 A# B5 a0 ~3 X
        if (theSession.Parts.Display != theSession.Parts.Work). H, I. }; [) t: v: u2 s
            theSession.Parts.SetWork(theSession.Parts.Display);8 B1 T$ b- ]' y/ }7 b- h9 }
; t+ O- J* G' \# J8 @+ o& c/ ^4 B  f

7 R' X( j- S7 P; K        TaggedObject[] theBodies = null;: n2 P0 @0 T. v8 v5 ]- m8 {
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
4 D- L8 D& n3 i( W' L5 ?3 N        {4 `6 R% M/ e1 C+ t
            Echo("Selected Bodies: " + theBodies.Length.ToString());7 _" |- B3 P6 w1 g% `& f4 d2 N6 B( Y  \
            Tag[] theBodyTags = new Tag[theBodies.Length];" j2 H5 G( k3 V  p
            for (int ii = 0; ii < theBodies.Length; ii++)
5 S: r) v* W( L% c: Y% S( b                theBodyTags[ii] = theBodies[ii].Tag;4 E5 N* R2 j- L. n8 h

4 e5 q9 Y" A% c$ ?; P" f7 j            List<Curve> theOutlineCurves = new List<Curve>();+ v2 x4 z  z1 S& X8 S
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;, S/ M2 M8 A4 A1 E
            int loop_count;
2 Y6 W1 L$ R; f2 S5 f- s) r. Y8 [            int[] count_array;
% ]3 o0 `; c" Y6 ~. n0 I            Tag[][] curve_array = null;) V* O) ?; P) c( }
            double[] tol = new double[2];
6 p( s8 @' j' J. z8 B
' p# p* J1 ?/ n% i1 b3 E            theUFSession.Modl.AskDistanceTolerance(out tol[0]);2 t2 [+ g$ F& ?0 g) g
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
: Q" y$ e$ m; H6 V' h9 x. M; b4 p2 g1 i. T' V/ }
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
' f* @  ~2 g+ |                workView.Tag, out loop_count, out count_array, out curve_array, tol);/ t4 i, R( H7 y* e. F

) G" q2 [# H% J% |1 L            Echo("Precise Outline Loops: " + loop_count.ToString());
' {. S7 i4 x( g$ o1 n$ K1 P% Z& P            for (int ii = 0; ii < loop_count; ii++). s- [  s9 q# H8 H
                for (int jj = 0; jj < count_array[ii]; jj++)
# S8 {" |; ~  x$ [1 E6 r                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
, V( z0 A" \5 C& l            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
" E. ]* I; E2 Q# C5 e; N( n4 G/ b+ x
, O% e* V, X+ C: S+ U8 e            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
) N( [. i! T0 `; Y# C# G# V* H            int curve_count;
6 N2 f  ^' z; m3 Z            Tag[] outline_curves = null;9 y6 q1 u9 W3 v+ Y
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
* U3 }0 h- _- D9 p/ m% k$ C# V                workView.Tag, out curve_count, out outline_curves);$ e' A3 F7 i/ c( L% O% r! L5 I
            Echo("Precise Outline Curves: " + curve_count.ToString());
/ b% n8 D4 v3 g6 N; o5 n2 t$ J            */
. p9 d7 A9 L* ^/ {4 I        }
2 S) [# S; d, F3 M( ]4 r' S' r( _  M+ H. ?5 ^6 e$ h  `
    }[/mw_shl_code]5 x6 t6 l6 q/ R5 c6 [
[/hide]
# f% b, n4 {- O- L1 b6 F4 D
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了