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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
9 ~# ^  A6 U( Y3 H* }
* p! u; ?; n9 B4 q2 aUF_CURVE_create_shadow_outline (view source)" a6 ^, v6 R1 G0 E* _5 O$ I

' i8 T0 t# n) vDefined in: uf_curve.h
/ P3 I& g  a& m1 O
7 j3 G( W8 g  R' J" j4 j$ `3 Z+ O: h* B( H/ Z
Overview
# x/ C! ]# a* s# \) g6 }  f; ?0 G9 i% T% r9 m
Create shadow outline for a given array of solids. Solids passed to this 9 t  X3 v: |$ S( L: s
routine must be on a selectable layer and visible. If created shadow curves
* U, U$ e9 H3 W3 bcan not form loops, please use UF_CURVE_create_shadow_curves instead to get   I( ?% T; O! I1 C1 z
shadow curves. , N8 G- [/ C0 T1 i) ?: O! v  O

+ O( T% V9 O4 S. J) w# P9 x# ~6 [8 D+ w
[hide]
9 b' t) u5 Q3 k; w; s7 W' n
, V/ V3 C" K" A7 O; V[mw_shl_code=csharp,true] void DoIt()) x. P& u2 v; O1 M! r# }9 `
    {
# q4 W  h8 w2 ]$ k        if (theSession.Parts.Display != theSession.Parts.Work)
2 o6 ?. C( f4 I) e4 O            theSession.Parts.SetWork(theSession.Parts.Display);: w, Q' q& q! p' `$ _

6 d2 q9 |# E' f7 ~9 u5 q
' k4 ^) }- X- s6 b! u/ i- s        TaggedObject[] theBodies = null;3 v) B7 Z2 h* ^/ f
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
/ Q* ~$ e* J: ?, w        {
  S4 A+ e0 I& Y% l- N* ~            Echo("Selected Bodies: " + theBodies.Length.ToString());0 G8 W9 E0 s: R# ~0 ]
            Tag[] theBodyTags = new Tag[theBodies.Length];- Q! f- I1 G( f1 W( m/ |3 v
            for (int ii = 0; ii < theBodies.Length; ii++)
1 N0 \9 B. o( @                theBodyTags[ii] = theBodies[ii].Tag;3 D& h- M/ q5 t& o

. ?. b$ [" ]4 @+ Z! |            List<Curve> theOutlineCurves = new List<Curve>();
/ U3 c6 ~. G: m* o4 r, E4 ]            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;8 t4 b$ i/ h5 A* ?, P
            int loop_count;9 t) U! x! t: L2 E& W1 y
            int[] count_array;
! O! Z; `8 s4 W( P9 _- V            Tag[][] curve_array = null;5 l3 p' g7 H! S: z$ M% w
            double[] tol = new double[2];+ [" N) z; G! s( C
3 [" z3 g, J" ^
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);: ]0 f6 [8 i% t- _
            theUFSession.Modl.AskAngleTolerance(out tol[1]);" d8 a, ?9 ?4 e: r: o" Q- s
8 U8 @# u3 D+ `5 d  {
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,9 l. |, `) c$ }  f: R$ Z; {
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
6 b- b2 K1 a) w" P- U5 P, c) t
" |% s, q4 Z. {, \: Z( `1 t            Echo("Precise Outline Loops: " + loop_count.ToString());
) U, |, {% ?/ l6 A            for (int ii = 0; ii < loop_count; ii++)$ L7 e& [$ j4 f
                for (int jj = 0; jj < count_array[ii]; jj++)
# j* X8 ~2 V8 J& ]! f# H2 y0 O& R                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));; D9 a; P" T" @9 p
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());# p" `6 B7 b; F

# ~* a* u: u2 u: c# C- g& W0 D* f: I' W            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead $ n7 v5 O8 s  R9 J/ i5 Z
            int curve_count;! V4 y! A2 X- X7 ?/ {2 p5 |
            Tag[] outline_curves = null;- w7 d0 Y& C& y" a3 n
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, / H  }7 }5 p& b/ I
                workView.Tag, out curve_count, out outline_curves);/ Z. A$ N- ?" X2 a4 [9 u
            Echo("Precise Outline Curves: " + curve_count.ToString());6 h2 P  S# F9 \% H5 v" g6 f
            */' A- u" {7 ^0 @
        }# I7 Z1 ~7 b) E) f4 P
; f' u( [1 g4 h/ A5 {3 _4 @
    }[/mw_shl_code]0 ]) a  d- ]. [* \% l: E
[/hide]
( ~# r( i2 F0 m4 A5 W6 G+ 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二次开发专题模块培训报名开始啦

    我知道了