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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓4 X. h9 Q: s  T. F' C$ P# G

- F* t1 g6 L9 R& M# gUF_CURVE_create_shadow_outline (view source)
3 W& \3 F5 Z  O" F+ Q4 B+ |$ Z$ q
$ R$ F; q! G. i3 NDefined in: uf_curve.h
8 R0 G9 f0 I  J7 ` - e- R' I6 T$ B8 w; B" X

# T' f8 F& t# h9 ?/ ^Overview
' L5 n$ U1 Y) c1 z6 e5 ~( r1 t  n8 }2 ^4 p  J" p) ~5 F" B! _0 f& E
Create shadow outline for a given array of solids. Solids passed to this $ ^, r6 F3 G4 X
routine must be on a selectable layer and visible. If created shadow curves ; I" C# |$ t) p3 D3 A0 @
can not form loops, please use UF_CURVE_create_shadow_curves instead to get * f0 w# K0 j% Z. V1 t0 E, g6 P" p
shadow curves. 0 S7 j1 W5 H# D, Y9 g" F

  Y  u* A: H2 i9 j: O( F) w9 N4 Z9 ~7 g" ?- p7 s
[hide]9 z% v$ F, F  a) ]( P; a
4 b7 t) n# V6 u. h  ^
[mw_shl_code=csharp,true] void DoIt()
, n2 N  a) R; d, d# q* f4 x- y    {/ `* d4 Y' M5 p# d0 J) _/ O
        if (theSession.Parts.Display != theSession.Parts.Work); ^# R8 K# _8 @5 S
            theSession.Parts.SetWork(theSession.Parts.Display);. x. o' R+ W* I! l

% J2 _, Z$ z2 @# R9 K. y5 O9 w7 M$ s4 v$ Z
        TaggedObject[] theBodies = null;
( w" v8 P4 @, r! z6 T3 A0 w        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
  ]$ c9 y( [9 q2 g) M: j' {& h2 W        {0 ?8 m. z2 t# g+ ^" l
            Echo("Selected Bodies: " + theBodies.Length.ToString());" y, e+ t: a3 W% w9 V, n
            Tag[] theBodyTags = new Tag[theBodies.Length];
7 w5 [  V$ p$ P" j  a1 |            for (int ii = 0; ii < theBodies.Length; ii++)
- e' c$ X, k% T5 |+ r                theBodyTags[ii] = theBodies[ii].Tag;
  {: l" T1 ~6 F3 X1 g  U8 n+ |/ E8 Y3 y2 \
            List<Curve> theOutlineCurves = new List<Curve>();* Y1 i$ L& q* D8 ?8 D5 c
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;4 t# Q! A2 _; u) y
            int loop_count;
; c6 S3 W& x, J7 K2 ^) ~+ M            int[] count_array;
- W  Z" _3 x1 N. |4 p            Tag[][] curve_array = null;
- [: K, c; Y, t7 x( g" Q            double[] tol = new double[2];$ M' L4 n' z. g% j
/ K4 E+ A% X0 v. K. _
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
/ D2 N- [. @8 V) Q8 ]' h            theUFSession.Modl.AskAngleTolerance(out tol[1]);( W/ Q% I% |8 I
! h- _- D- s6 F+ D/ K4 m
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
5 L. R% j; l% W. A1 t6 a: h                workView.Tag, out loop_count, out count_array, out curve_array, tol);) e& U, U5 }7 F* G0 D
, o* H; |1 r7 G9 U5 V+ _* S' c
            Echo("Precise Outline Loops: " + loop_count.ToString());& j+ h' Q3 I! A2 Y/ b. ~0 I
            for (int ii = 0; ii < loop_count; ii++), P, x9 k5 m" n7 j6 H) u5 a
                for (int jj = 0; jj < count_array[ii]; jj++)
+ t5 a3 ]; k- M2 m" J4 T' |5 d0 ~1 \                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));  N  P5 M7 j- A# C. q
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());1 I0 s* c+ R) V
3 X% T% j2 n* b; O9 [
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead & J- l6 f, g1 H' |' O$ [( k* Q
            int curve_count;, ]! ^' s  p( Y
            Tag[] outline_curves = null;4 @. b  t8 F- i: R
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
; v2 w' P/ W3 n4 @' I5 q+ e8 G                workView.Tag, out curve_count, out outline_curves);0 `7 V2 \" q- z. ~6 ?5 P
            Echo("Precise Outline Curves: " + curve_count.ToString());/ {. D% X, W" a. k2 S
            */% O2 P, k$ h0 ^, H! F* c
        }
7 F4 y" P' A9 @3 l% t3 r
, |0 `" _( \$ I( i/ ~    }[/mw_shl_code]" I- i4 I, Y7 m
[/hide]
% b) P' p2 F. y3 w  K5 i! |: a# h
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了