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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓# k* T2 c9 T# R
4 w0 ]( I$ f% P" E  L+ H$ H
UF_CURVE_create_shadow_outline (view source)0 X) o2 o! c3 U

" c- P- }' ?( t0 Z6 e4 q$ {! @9 {Defined in: uf_curve.h
% R. u  J4 X/ V( @: A, T
+ |6 B: t% G6 a5 u
: K/ H# ~- P! I( y2 NOverview. V; I( e  }4 V' g; c4 P

, A( s+ v0 i: P/ ~( fCreate shadow outline for a given array of solids. Solids passed to this . T% ^5 w+ j$ n' @3 s0 `, k, v9 K
routine must be on a selectable layer and visible. If created shadow curves $ m. G3 @2 F  V, A' Q! H
can not form loops, please use UF_CURVE_create_shadow_curves instead to get / q4 s7 g* c: n; G( d3 A5 x% f# M
shadow curves. 1 ~6 [! K# Q. b& X) y

$ G- Y& P/ ?0 z9 n: {7 ^+ q$ i
+ W; |- U3 G+ e- l- {[hide]
$ o* `# Q! T* U9 v3 [& m+ Z3 Q6 f
[mw_shl_code=csharp,true] void DoIt()
2 K4 h; \1 i2 A& f5 ~/ Y1 q    {. \7 \. a; d5 ^7 {. U- h
        if (theSession.Parts.Display != theSession.Parts.Work)
, y, h* R, r# y) ~            theSession.Parts.SetWork(theSession.Parts.Display);
  ]2 p$ ]) t1 ]. O, j4 V  W2 W0 f5 f8 F2 t

8 X9 I+ T* i+ C+ J( D# M/ G        TaggedObject[] theBodies = null;6 h; T# f+ P+ C6 ]1 F
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
# l; g4 L: q- O7 t        {- F# Z& b3 {. J
            Echo("Selected Bodies: " + theBodies.Length.ToString());9 `% h  A4 W( w" J
            Tag[] theBodyTags = new Tag[theBodies.Length];
' P: ]; n- V. p" \) i# |            for (int ii = 0; ii < theBodies.Length; ii++)( y) ~' m' N2 Z6 S5 {5 s9 }
                theBodyTags[ii] = theBodies[ii].Tag;
  q* @4 W: _) E. b
( A5 m3 }  I! n4 K            List<Curve> theOutlineCurves = new List<Curve>();
+ k, |6 l6 o4 s+ M7 n, f- b. E            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
1 _; m5 S" \$ y$ R6 Q            int loop_count;7 H- k7 t/ A$ ~& `
            int[] count_array;# _  |) `) B# \, J; H0 j# b7 s
            Tag[][] curve_array = null;( g$ [; V3 d8 Q) g
            double[] tol = new double[2];- }) M9 z" ^; u( X& U$ Q

# ^( _, L: D9 @0 L/ ]$ t            theUFSession.Modl.AskDistanceTolerance(out tol[0]);7 W4 Z" s, f, J2 ^# W
            theUFSession.Modl.AskAngleTolerance(out tol[1]);$ l: U7 C& p% D. K7 f+ f* U7 }' L3 I
+ `8 z" u0 B0 }0 v3 L
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,- z! v& P6 u. }: v& C7 G5 T
                workView.Tag, out loop_count, out count_array, out curve_array, tol);4 B( L4 S- K5 W- C1 y' z
' Y0 z. o) c) A/ G# Z
            Echo("Precise Outline Loops: " + loop_count.ToString());
3 |9 K6 s2 c7 z            for (int ii = 0; ii < loop_count; ii++)0 b5 c9 k  j2 w: H6 |. u
                for (int jj = 0; jj < count_array[ii]; jj++)
0 ^7 a4 Z1 a" N                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
- |# v) S  k  p8 ^. S            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
1 K; }- y2 J" q! v% o0 T3 y9 Y( `* P) S: E
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
2 z* S, b3 g5 d& W2 B            int curve_count;
2 R) b; x3 g* ?  H8 M; @% z. H3 k            Tag[] outline_curves = null;9 ]+ S% L5 }8 [1 \' j. J) c
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
- R% [( {  C+ Q- W) K& P                workView.Tag, out curve_count, out outline_curves);, t" H- N8 o( @" |* J; q1 {& l
            Echo("Precise Outline Curves: " + curve_count.ToString());
7 m' L0 b: ^+ ]            */" i1 {3 I2 D+ s. s, F) Q, g
        }
6 f2 I5 h* X" }/ a6 _% J; s2 Z
- C" E* Z5 ]$ U4 M6 x6 I6 a    }[/mw_shl_code]
. ~/ f' L. g2 |/ @. W7 h[/hide]
4 I: E6 @# [4 D% h  D# 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二次开发专题模块培训报名开始啦

    我知道了