PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
% W) n3 `/ R: O- I+ u) c, b1 Z4 p; N( ^+ t* E( N
UF_CURVE_create_shadow_outline (view source)( p; W7 ^: q( Z% ]  Z6 w) l' O

' i: \, A+ _8 e# Y6 jDefined in: uf_curve.h
5 H8 d, W7 R& Q5 C+ V1 l
: M& o' F/ b" U0 |) K2 n  m0 ^6 P0 |* ~3 d- S; R! K( {- ~
Overview  [- \5 |3 \5 p0 W* l
+ ~: F, {5 c# \' F+ D+ |4 C  E/ F; C
Create shadow outline for a given array of solids. Solids passed to this
, ]% N- I( U( D, `% oroutine must be on a selectable layer and visible. If created shadow curves ) M0 L  M2 O1 f* B$ S' M
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
2 K6 q/ _+ d7 O, M* g7 U0 Nshadow curves. 8 @# z2 X. h  y, L7 v

" o+ H) {! n; O% C+ l, F: m: a2 L# _# G/ ~. }# p0 l# n- N' [$ w9 j( H, t( @
[hide]# l) F0 V& `5 P( \
" D$ B* d7 G4 V, j  m
[mw_shl_code=csharp,true] void DoIt()2 U$ e$ {+ J' L2 @3 e9 ]/ }
    {1 h6 U4 v, K8 S9 T& g9 [
        if (theSession.Parts.Display != theSession.Parts.Work)+ \3 U2 V5 @* h
            theSession.Parts.SetWork(theSession.Parts.Display);
' C9 L8 x8 j/ y! D' `0 c3 }
9 C. Q9 Q. R- A* c" A% T( C3 w& @7 ]7 U3 ~% I
        TaggedObject[] theBodies = null;
" s/ `6 x' _$ F1 L$ F1 w% d        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)3 J; _. E. u" J$ o0 s5 W
        {  e9 J2 T9 L9 U4 |
            Echo("Selected Bodies: " + theBodies.Length.ToString());3 W1 Z& F: U9 w
            Tag[] theBodyTags = new Tag[theBodies.Length];  _, t: C8 D. e2 S
            for (int ii = 0; ii < theBodies.Length; ii++)
, y; c; W& s1 f& f' m1 B                theBodyTags[ii] = theBodies[ii].Tag;5 Q  Z2 Z* Z  ]& [# ~- e

) q2 I# v& H$ a8 g: H( n4 `, y" ~            List<Curve> theOutlineCurves = new List<Curve>();
" B( P) Q0 t6 A2 M2 F2 J/ c- }7 L            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
7 ?, S2 Y+ T+ `' J  Y1 ]* h            int loop_count;8 U, D/ R6 p% V5 C* U  A
            int[] count_array;5 f4 S  V; X; t+ s
            Tag[][] curve_array = null;& @" D2 E  W: e1 s$ n; E' I% n
            double[] tol = new double[2];5 q( U8 p% D1 r/ t3 }, o8 f; s! O

+ H4 x' {( ~$ q' {; a1 S            theUFSession.Modl.AskDistanceTolerance(out tol[0]);; X6 j$ g# Y( w4 o
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
: F4 x, s& J; ?" `- e4 b3 S
6 e1 x# Z. i; a) r( }            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,. A% ]' j1 W% H* J
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
& n% O, \1 ?9 v$ m8 r+ \# \; Y9 ?: w* N+ p% y
            Echo("Precise Outline Loops: " + loop_count.ToString());
9 u$ Y9 V0 a* |( h, Y+ M            for (int ii = 0; ii < loop_count; ii++)& H3 F9 b5 s5 h4 Z& Z) E* c
                for (int jj = 0; jj < count_array[ii]; jj++)
+ |. l0 e% V8 _" P                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));' E3 C- T& _/ u! N
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());3 D0 [7 T/ d/ ^* b- N- s5 ~9 s+ ?
  m; r" I  w6 Z+ `; R7 }; u( V
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
; m/ J: S3 B' z8 @6 b            int curve_count;
' |" |& ~; N% |: w3 I            Tag[] outline_curves = null;' R3 x- X# E  X
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, - d3 f0 ^! Q$ @' L$ ~
                workView.Tag, out curve_count, out outline_curves);
5 k' k, b. q' x. `% b' J            Echo("Precise Outline Curves: " + curve_count.ToString());
) c6 |- E$ n! I  @  Z' o/ R            */! i9 J1 N: w* f" w# k
        }
" a3 T3 j- |. b, J* \: H5 [
1 o. S" N3 d5 }" O' N; Q    }[/mw_shl_code]; j1 ]$ e/ u! D" i: U7 R
[/hide]2 E0 x6 W! s% i% J' c6 m0 e  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二次开发专题模块培训报名开始啦

    我知道了