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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓; `% j1 O6 O# Y" n+ u
# ]9 G' V& g& \4 H, n1 i9 l
UF_CURVE_create_shadow_outline (view source)9 I' a- q9 F1 V( n

2 L' U$ v* G% Z1 N1 J+ gDefined in: uf_curve.h& m$ z( J1 o! e0 j! y, M
, K8 K( d# ^( u8 @

' @( ~$ [8 T1 {3 [# nOverview
( h1 B2 [" l0 M8 g" p( v
# _8 V  O0 @# i# d0 F9 o7 X9 GCreate shadow outline for a given array of solids. Solids passed to this
1 R# T% z) D1 ^0 qroutine must be on a selectable layer and visible. If created shadow curves
* c# F4 I' e" ?3 @+ ocan not form loops, please use UF_CURVE_create_shadow_curves instead to get
5 h: a5 q0 T* t: j' X9 q/ H& @shadow curves. 8 k! F. Q, G$ B: z+ a2 _
5 }9 b1 u/ ], B, b: |/ A
) U/ g6 m+ }. L, ^
[hide]
- i* q) a: f. r7 S3 i8 a- K" E& K
2 \& Q; s* O  Q% h5 i[mw_shl_code=csharp,true] void DoIt()6 S% `+ T; @5 O7 V$ M, j  \
    {
3 Y  X& S) ~" w% V        if (theSession.Parts.Display != theSession.Parts.Work)$ }0 x) ?" ?0 L( D7 B: j
            theSession.Parts.SetWork(theSession.Parts.Display);5 s" Y6 c1 Y# q7 b0 b

. V. ~; Y5 o3 d+ p0 s. K0 L+ y+ W& u- K  ?
        TaggedObject[] theBodies = null;
. a! J; l$ x7 q  g+ u. A        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)# M' m% H8 W& M9 R3 D, f
        {! L! ?+ p; H7 p- ^. x) y4 z' W
            Echo("Selected Bodies: " + theBodies.Length.ToString());: D. A7 Q1 u+ ^. y4 ^
            Tag[] theBodyTags = new Tag[theBodies.Length];+ [0 L$ ^; R$ W9 {9 z
            for (int ii = 0; ii < theBodies.Length; ii++)$ G& x$ e$ K* i
                theBodyTags[ii] = theBodies[ii].Tag;; x$ R2 |& f, A, ?) r7 G5 Z
2 x2 A. k! s0 n9 M
            List<Curve> theOutlineCurves = new List<Curve>();
9 e- t0 d' [* |- z, g7 p3 K            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
4 P: I  X" p. W2 ]/ H) n            int loop_count;, k  \7 d8 R7 O3 R
            int[] count_array;
& f7 z0 v: t. C* i% F& Z            Tag[][] curve_array = null;
5 q; E/ R4 L# x7 I, z% y. h( z            double[] tol = new double[2];$ u/ J, O- J* \3 m& S, I  {- Z

: \, }4 X! ?7 K* |+ N9 L4 |            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
8 ?' Q# d8 a4 I" m            theUFSession.Modl.AskAngleTolerance(out tol[1]);( p: j3 Y- h$ l! C, T7 E3 r8 J4 h
+ x0 r! t: r* R- t) l3 ]
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,  Z$ o* G/ N9 L) Z9 w$ _; s& f
                workView.Tag, out loop_count, out count_array, out curve_array, tol);4 B, o* I8 \$ ~. [4 R, L+ l
  Q6 S3 N( H$ c+ z/ z: V- |) ^
            Echo("Precise Outline Loops: " + loop_count.ToString());
9 B" T5 G  q7 c+ M0 ?            for (int ii = 0; ii < loop_count; ii++)
- K, d9 L3 c. Z# V                for (int jj = 0; jj < count_array[ii]; jj++)4 P1 ~) [; A9 P7 D3 H) N& m
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));5 G) j# U0 ~3 _! R
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());- ]9 d5 R  I: H; X

5 Y- \( y7 U( ^4 A7 H            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
3 ~3 }8 H/ Q9 l  N            int curve_count;
# l+ Y% O( n! i$ i# ]( w            Tag[] outline_curves = null;: X4 p  u$ m1 Y7 f
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, % s) }7 ~5 i, \% @$ b
                workView.Tag, out curve_count, out outline_curves);+ }! h# }; G' @7 E
            Echo("Precise Outline Curves: " + curve_count.ToString());3 p' H# V) K7 D. W5 B6 p" v7 y
            */
8 v8 J5 m5 j2 m1 B+ m! d( m% l        }
& ?$ o1 a3 G( ]$ I, y2 T7 ?6 U' J  j4 c7 @1 k
    }[/mw_shl_code]
+ s& Y3 F: \3 c! Z  v7 `( g: s[/hide]0 K" [5 V8 N: }% `4 X# N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了