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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
. v% Z) P2 o* N' l2 a, L! b) D# C0 l
UF_CURVE_create_shadow_outline (view source)
8 d$ d9 Q: J0 d1 W! ] 0 r* P* _* e" I- Z; z( e: c
Defined in: uf_curve.h
5 |1 K* `; ^! R
* A# Y# y0 f9 T" R$ i, X7 ~( F( x+ e) r; v- y2 n
Overview+ z1 Z$ a5 o' j: o. I

0 a; l" A# x5 H" u  s* w0 ?3 BCreate shadow outline for a given array of solids. Solids passed to this
  _6 N1 o4 F% f6 o- yroutine must be on a selectable layer and visible. If created shadow curves $ ^& _+ R2 b0 Z3 q3 R: i
can not form loops, please use UF_CURVE_create_shadow_curves instead to get * N' B; m- V- v- b
shadow curves.
( A- n7 H# t9 Z- d; K, u; q3 |, ^8 e( @+ z" w4 h& }2 D( r, A; f2 M

' Z2 @6 P8 C/ F7 j[hide]
* {* {2 b" f$ Z( ~, e1 o; U4 @& @" G2 w0 n, h/ ~4 ]- N
[mw_shl_code=csharp,true] void DoIt()6 e, `- y! B/ |7 N
    {$ {& L- z; J' Y( [5 G' H# f5 m4 B2 h
        if (theSession.Parts.Display != theSession.Parts.Work)
. @1 ?2 g  {( C            theSession.Parts.SetWork(theSession.Parts.Display);2 ^' O* f  _1 X( ?# J9 [3 A

" x" P& ^" j: m( z, F% l" s/ W3 L2 t2 U5 s
        TaggedObject[] theBodies = null;+ A  w7 ~5 k& P. U: r
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
" m' A  l2 j' y* G. Q        {3 _& f& J/ k7 L; W+ o7 Z
            Echo("Selected Bodies: " + theBodies.Length.ToString());
6 O. p, t  M- A& K9 i# N            Tag[] theBodyTags = new Tag[theBodies.Length];) |* ~3 w8 P. G( A% W- N
            for (int ii = 0; ii < theBodies.Length; ii++)
0 O6 d$ I4 i, I9 o2 G* l0 s6 \/ v. |                theBodyTags[ii] = theBodies[ii].Tag;& m  r! G7 s: U) T" N
. O8 \  m& N! c2 Y
            List<Curve> theOutlineCurves = new List<Curve>();' d/ J7 y( t! d* {, N
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
; j" ^0 O% ?8 k! u( G            int loop_count;: M8 ?6 v* e( Q6 o& ~% k
            int[] count_array;* f' b5 a# N2 q) g) ]/ {
            Tag[][] curve_array = null;* w9 s  h4 ]: o7 d6 m5 K
            double[] tol = new double[2];1 W# h# l3 F! _1 l% u0 |) P

1 r# z( W- R8 z; S0 M            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
# @5 g2 Y& q, }2 ]2 v            theUFSession.Modl.AskAngleTolerance(out tol[1]);
6 I. m: D- u' Y1 D$ [' T$ e" Y9 t8 H9 @4 s/ T
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
7 e, @+ x( f. ]! h& P- w                workView.Tag, out loop_count, out count_array, out curve_array, tol);
- R3 }2 w) A; ^/ z% x* e7 _- E( i: g, f
            Echo("Precise Outline Loops: " + loop_count.ToString());
% z  B) e4 _2 ^2 q; b6 I            for (int ii = 0; ii < loop_count; ii++)
. i# H) \9 {$ V$ n                for (int jj = 0; jj < count_array[ii]; jj++)
* A; {, t  n# |! Z3 Z0 ]                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));' C1 k- ]6 b% w; M& t( o4 ~+ ^
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
1 @$ q5 v4 v( z+ G, t) X. s/ X! f
9 v" V  v9 ~6 f" E- x6 R, g            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
: W* M7 i: I4 Q( F            int curve_count;; e( u2 L2 u6 [9 y( \
            Tag[] outline_curves = null;
: h8 E5 Y3 i' k( F            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
% ?# A* Y4 i# _! v- t! \                workView.Tag, out curve_count, out outline_curves);
* B3 w% l  X6 ?1 ]( ~* @9 @5 I            Echo("Precise Outline Curves: " + curve_count.ToString());
5 e* e" M) ~8 B            */
; r4 d+ G0 b! M. j# d$ j3 Y        }- a: w; n" S# p3 C. S1 E$ Q, M0 P0 z

& S% l& X% D4 [4 _5 F4 }& D2 Q- K7 G    }[/mw_shl_code]
5 i5 ?: B) P& ]; L1 L+ S[/hide]
2 _, A6 c" d- c4 o) }1 B8 z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了