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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓. Y2 [  y& _  D2 ^' l5 L

7 W1 O, b( v7 S# i9 B- tUF_CURVE_create_shadow_outline (view source)8 `! B" Z1 }" \. w
. Q. H- ]1 T6 F" T" b0 o
Defined in: uf_curve.h3 P7 x5 N! Y  {/ Z! n3 u7 {

8 {! }* P3 s% ^* A; \' E+ q/ {% z
, T4 e0 Q( }9 c* G6 EOverview
' S6 A/ M! n) q6 G( r$ Q
' }1 ~, x( A% ]9 D6 Y% y. a. l* TCreate shadow outline for a given array of solids. Solids passed to this . p; m  p+ w; u# i9 d! q
routine must be on a selectable layer and visible. If created shadow curves
1 J4 k, |8 |+ hcan not form loops, please use UF_CURVE_create_shadow_curves instead to get , I( q+ N; `! k2 G3 E( S
shadow curves. : p; v; n5 W0 Z+ y9 Z, j3 I" I" d" c
, B0 @; ~( ], W$ f4 ], f
; U7 n2 P6 C& m+ o1 x5 H( m3 W% g
[hide]* o; F5 ~8 l5 `  r; |4 |1 C8 v
% Q. x2 k3 ]' @* i2 n, ?+ D% f9 p
[mw_shl_code=csharp,true] void DoIt()
6 R! Q# `" p+ _( D8 v    {+ m# Z9 s4 p$ ~$ G9 n+ t. M+ D
        if (theSession.Parts.Display != theSession.Parts.Work)5 m+ y  K! D- y1 \  |0 h
            theSession.Parts.SetWork(theSession.Parts.Display);
# r: W4 A, j4 l1 d* M" M! r" y
. J" y9 t- Z  ^' _" I3 [8 `
3 b0 N  R9 q8 z' n. c        TaggedObject[] theBodies = null;
/ m: @0 n& w* [. e3 V0 B        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
1 y( I" d2 F# |0 e        {, ?* Z' S4 J! ?
            Echo("Selected Bodies: " + theBodies.Length.ToString());# M1 O1 n1 g0 ]  V1 ^1 P
            Tag[] theBodyTags = new Tag[theBodies.Length];, W9 b9 i6 p" J; ~" U8 s; J- k
            for (int ii = 0; ii < theBodies.Length; ii++)6 D: T0 B' U0 }/ e: P& [
                theBodyTags[ii] = theBodies[ii].Tag;
2 G. R7 y) m7 G) b8 D. y/ r
+ ?9 X3 s3 ?$ y* H            List<Curve> theOutlineCurves = new List<Curve>();
  ?+ y8 C5 a7 O: Y  r3 ^            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
# l& }% u/ [7 d8 e. U  P1 i            int loop_count;
" o' I8 O& U: [% m  Y0 v. H/ H$ i6 D            int[] count_array;
) c, g3 O9 E5 p0 J            Tag[][] curve_array = null;: f8 F& N, ?  u# r
            double[] tol = new double[2];
- j- f4 C. q7 C' k, j- {5 r
% S9 r8 k/ y0 A* F" L/ I2 a            theUFSession.Modl.AskDistanceTolerance(out tol[0]);: H3 g: ?& g$ H% ]) d. C. }) ]6 z) D
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
' O/ y4 d1 [  i1 U* h6 @( K' r; {! v; Q; t$ j" F9 v
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
$ R. w3 U, `. a, I- s                workView.Tag, out loop_count, out count_array, out curve_array, tol);
1 `) M  n/ B. Q  t8 C3 v" s4 g8 V. w( \& u% T6 D) O
            Echo("Precise Outline Loops: " + loop_count.ToString());
8 B' {9 V5 D& F8 t$ i2 K( W            for (int ii = 0; ii < loop_count; ii++)4 N, Q; k) T0 D( K" y
                for (int jj = 0; jj < count_array[ii]; jj++): V- E# e6 A' w8 s3 I6 B
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));9 k" C: [% g& v' l5 c' E. {! p
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
( f$ h! q9 L) `) {# I$ W2 W6 K' k* h' s6 |6 ~7 o
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 1 f; B& `+ f2 n
            int curve_count;
+ V0 n0 t8 }5 B& T4 C            Tag[] outline_curves = null;5 j! y! Y$ c) e& `+ r( @* Q; J
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, ; H) ~& }# u( w) W
                workView.Tag, out curve_count, out outline_curves);" b5 O+ N0 e: S" p8 y
            Echo("Precise Outline Curves: " + curve_count.ToString());
  t$ v3 g2 s  `            */4 P! D( I) v6 B+ M5 C! x0 c7 i7 V
        }9 T  G, a. ~% [, O9 @: C) j

' k6 }" L( A. S. x    }[/mw_shl_code]
7 b% g* R# P% @1 P# F[/hide]0 p* W5 U4 m$ g8 P$ V* t/ t' V
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了