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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
5 M* a# H2 s- ^' \0 t" R: E, R4 h. h  w5 G; Z, U+ f4 f, n
UF_CURVE_create_shadow_outline (view source)
! t" i4 {$ \! W( i; V; p
$ i" A3 \- g- DDefined in: uf_curve.h
- g% R& E. H$ M5 M9 P & P8 M& U# y/ h7 N
4 _2 J% L: E( `2 H& B$ c' S
Overview
, ]# w2 p) c' B# X$ A7 r% e& B* i/ p
# y5 \+ k. e8 j3 ]2 K( a" I3 {Create shadow outline for a given array of solids. Solids passed to this
4 y% C7 m& h- t+ X. l# Droutine must be on a selectable layer and visible. If created shadow curves
1 h0 V" U0 y$ B' A$ U9 Pcan not form loops, please use UF_CURVE_create_shadow_curves instead to get & z/ E5 f5 v. |" m& r3 |
shadow curves.
6 l4 h1 E/ S2 Y0 A$ c( S
$ i# M* G; h" ~6 D. N+ H! H) u3 `3 W6 I) O* j
[hide]1 v2 f' j* O$ O0 W: o9 N

) w* i5 ]0 \5 I) o) X5 q$ R( F[mw_shl_code=csharp,true] void DoIt()
; O" f2 H+ k$ Q. r: m    {
& N2 P9 q1 N2 }2 q/ w: y        if (theSession.Parts.Display != theSession.Parts.Work)
1 l- b0 w6 i7 s$ Y* c            theSession.Parts.SetWork(theSession.Parts.Display);( h: E& [- }( z8 J
) R6 `6 `5 L6 l  \8 ]1 a
* G% s* g4 _2 y+ P2 W3 U# L+ o
        TaggedObject[] theBodies = null;2 C0 _9 n, O% A% A' f
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)) S  k8 B4 g% P+ Z
        {
* m0 @, o0 P; w1 R            Echo("Selected Bodies: " + theBodies.Length.ToString());; V6 @" V9 Z3 H( @. S; ~( {/ A. C4 L# r
            Tag[] theBodyTags = new Tag[theBodies.Length];5 }0 ]7 w: V" K1 Z* B
            for (int ii = 0; ii < theBodies.Length; ii++)0 H' e; e* z8 b9 K1 Q
                theBodyTags[ii] = theBodies[ii].Tag;
0 @) n1 c6 o+ U/ `. `) ?, q; s1 h) y5 ~( X  y( `2 f9 g
            List<Curve> theOutlineCurves = new List<Curve>();$ J0 r0 H$ f) l1 h, n! C5 l
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;2 t0 g7 m. B2 [" x2 k+ X9 r
            int loop_count;# H  U, A' q- A# d4 c
            int[] count_array;0 m8 H  {8 Y3 r6 K" T, Z9 C
            Tag[][] curve_array = null;/ m6 r7 |/ P3 X# x9 h0 T6 q5 y
            double[] tol = new double[2];7 _2 n/ s  j* ~4 `: j* J. Y
- q: I( k+ s1 X, ?2 s
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);! O3 g" Z) w9 B* d. c( W# D/ f
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
# ~& h4 W- K# M/ P* x
2 P( L6 C, S* Z% f. {0 \! o            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
5 X6 l) \- K6 Q$ I6 e                workView.Tag, out loop_count, out count_array, out curve_array, tol);7 G/ h/ ~, |7 P# N

: z/ ^$ l, a9 ^6 q            Echo("Precise Outline Loops: " + loop_count.ToString());0 V$ _/ g, ~) @, N4 B0 B
            for (int ii = 0; ii < loop_count; ii++)8 g" g( j" m1 G
                for (int jj = 0; jj < count_array[ii]; jj++)( w3 i8 G- v6 }  T7 i
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
2 B$ x- _0 {! O9 |0 ~0 f            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());% S1 E  j9 _8 ?3 b/ m- n4 {7 d
% h* Z1 C( D7 n" D9 N
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
  _5 I! s7 \! [' j: |            int curve_count;
0 n9 @2 H6 _( a# G7 E1 Z* }, @            Tag[] outline_curves = null;$ ~# t  x8 P7 `3 l" ?
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, # L9 h  \& `! v+ T$ x- y" [
                workView.Tag, out curve_count, out outline_curves);
8 }: t- d+ k9 w+ D; U" l3 k            Echo("Precise Outline Curves: " + curve_count.ToString());. ?* s" C/ }, E# x$ z" `( O
            */; [' Y: d6 \/ V# t6 h* B2 G9 T) ?3 |
        }! `: Q/ l/ ^& E) f
$ g% u  O9 Q9 t7 J
    }[/mw_shl_code]
5 g7 D2 z. C  a2 j[/hide]: w7 T' O9 J/ t0 @. X+ j; ?  L7 M
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了