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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
( V: L2 J* o  v" b; p7 b7 s; V5 H
( c* m( m5 a# G0 Y. d6 C  tUF_CURVE_create_shadow_outline (view source)# b, l; Z* j' u. {- e& ?
, j) b' T  x' P  w. m
Defined in: uf_curve.h
0 O& K# b: x. c2 l, W* V  I
. P9 g! x! E- l( {2 Z8 V3 e: s' U" v$ S5 |, Q
Overview( ?( K0 L7 m3 O

' Q5 [" o  ?& ]2 P5 e! y- ?0 ?Create shadow outline for a given array of solids. Solids passed to this ; b1 J* @5 v1 M! d; E
routine must be on a selectable layer and visible. If created shadow curves
2 G: E# H8 Y8 E, a0 I  tcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
; D- v( _1 f* L1 Y8 G; s! gshadow curves.
+ v9 g3 ~) |5 O- c& J! B& t. T. n
" Z' I1 u0 u: ~# V5 ?+ j# E% m
, L2 w( h  ]$ Y% s; N+ I[hide]
8 p- c; r5 C3 \: Z# {% S* P$ U0 ~% _. f; A
[mw_shl_code=csharp,true] void DoIt()3 S" i0 D" q. o& Y
    {" [+ @- D3 t5 u2 ?$ c
        if (theSession.Parts.Display != theSession.Parts.Work)
# J( S1 K) [, f' w  D3 |            theSession.Parts.SetWork(theSession.Parts.Display);: v9 n2 w8 X# T
# {4 G& T1 d: z' W
% a5 {1 ?% ^6 w+ j& r6 U
        TaggedObject[] theBodies = null;; m$ s& p7 C* Y  M2 t
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)6 n2 i# B# k6 O2 k: a
        {, n$ F& s, |1 T% C% P- r, K5 |
            Echo("Selected Bodies: " + theBodies.Length.ToString());
9 Y6 F2 y" ~. V% H, L            Tag[] theBodyTags = new Tag[theBodies.Length];
& Z' |1 c# ~$ S8 ]            for (int ii = 0; ii < theBodies.Length; ii++)+ B1 o7 M) F1 _  z3 x. N
                theBodyTags[ii] = theBodies[ii].Tag;
6 w& M, d; j) B8 g4 \$ d+ Y7 D5 t& |" {* h& t" T7 a
            List<Curve> theOutlineCurves = new List<Curve>();
: P2 G- u/ J& |& A$ _' f& r0 ^            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
4 s' T4 T, @- A  M, |            int loop_count;, P" E4 n' u/ C) ~; U+ s
            int[] count_array;4 T5 `3 r' [' B3 Z
            Tag[][] curve_array = null;
" T* V  S; o3 ^8 o1 K' z  }4 e            double[] tol = new double[2];: ]( B( I" G; K
8 \( ~5 _+ t, b! S7 c
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
. s0 Q1 ^, A/ y  s4 N6 A2 c            theUFSession.Modl.AskAngleTolerance(out tol[1]);
0 s5 N; ~- r9 n
/ O# B- D. U. L            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
: m2 o) g8 p: Q. \1 S$ o                workView.Tag, out loop_count, out count_array, out curve_array, tol);2 U* `/ {3 |% G) z/ C+ j
* f8 a2 u+ L8 {7 ]  u5 @8 C. [
            Echo("Precise Outline Loops: " + loop_count.ToString());
4 U3 K# z; \0 L% N7 W            for (int ii = 0; ii < loop_count; ii++)& d6 Y. H0 W) M; Z8 \! O
                for (int jj = 0; jj < count_array[ii]; jj++), \7 K6 F7 N& M: R2 g/ x" ~' ]" x
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));9 s4 n& d4 ]6 g/ f6 x; {1 `- E" B
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
+ H' _* D/ u, o
7 w: K# C8 \) |: W7 n2 r            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
# @1 K/ B9 t9 I4 _            int curve_count;/ h2 b) c/ O7 X
            Tag[] outline_curves = null;
0 N; H- x! H6 h1 k            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 1 R- m9 ^  e% T
                workView.Tag, out curve_count, out outline_curves);
- t. k; o% N' m            Echo("Precise Outline Curves: " + curve_count.ToString());
# E1 E; \. @, x4 I: H            */
: t% C& g" T8 l$ u8 L3 \" |4 w        }/ E: E8 Y1 j' m; _9 h. I3 h
9 q& B& ?0 N# _& _7 f
    }[/mw_shl_code]
1 u* y8 R8 S: W5 m; \; t1 s[/hide]
8 M% Z6 t7 D$ N. l0 w$ l' _
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了