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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
( b7 ], X6 W8 w( m0 a6 [
# R$ t$ r9 I% X+ }; dUF_CURVE_create_shadow_outline (view source), y/ u6 N  {' R; u  O
4 W) t; w3 \6 }: h1 g% ^0 c: w! O4 @: A
Defined in: uf_curve.h
9 x: y. V3 ]2 \
3 y0 R+ p0 f& a; `! P: H
) L2 p3 `* s7 s8 y3 u8 V7 w2 hOverview
- T) }. C' }+ {) [8 r7 ]2 |
7 c6 W6 v4 m$ X" P1 ^Create shadow outline for a given array of solids. Solids passed to this
* r1 r- S, h  V1 `! ?routine must be on a selectable layer and visible. If created shadow curves
- s- v1 U& G, I# {1 E, y# Qcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
" Z* P% P- a' N9 `, I  }' W% |shadow curves.
: Q% t' d' d9 p! r$ k! z/ f  }. x1 d- t( N& r7 h

5 b2 g! A3 g# [" ]1 o[hide]) m: n. r$ G7 S
1 p: V  q; h+ u
[mw_shl_code=csharp,true] void DoIt()- Y) x. f2 N; Y, G+ G* q
    {
& m1 c" Q( K, T/ D* \: H        if (theSession.Parts.Display != theSession.Parts.Work), m. s! V3 Q" b) D6 d& b
            theSession.Parts.SetWork(theSession.Parts.Display);" G$ G2 m8 V: E

6 |) k/ X8 x0 q9 N' v+ @$ g& d3 z9 B8 W5 c/ q  g6 d# i
        TaggedObject[] theBodies = null;
/ X' B) x' y! Y  U        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)+ r2 J- O( z* K2 T! ?8 Z
        {
, c- g; O) x2 I3 i; P) l            Echo("Selected Bodies: " + theBodies.Length.ToString());
! \3 ^) s, s2 r/ `            Tag[] theBodyTags = new Tag[theBodies.Length];
& \( k' \) x7 _. P+ C            for (int ii = 0; ii < theBodies.Length; ii++)
2 A+ [2 u8 P4 _0 o% F                theBodyTags[ii] = theBodies[ii].Tag;# T5 [2 E3 c- {/ k3 X6 c5 w
5 X/ }" i* I2 F
            List<Curve> theOutlineCurves = new List<Curve>();
7 m6 ]5 w: j+ n; G' t. I: Q            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;) O( f" \( H# j1 x2 M
            int loop_count;+ I  V7 @8 P+ p2 a
            int[] count_array;9 h5 l) ~( N( b7 v3 e0 Z4 |9 u
            Tag[][] curve_array = null;, @6 Z2 t' m( I( e: e7 b
            double[] tol = new double[2];" c  D. v8 i( d7 ]
* Z' I5 d9 u% b; y
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);$ L$ ~9 z! @+ S" n5 J, [( J; W
            theUFSession.Modl.AskAngleTolerance(out tol[1]);$ D; P9 n5 Z) M% H5 m3 P3 ?

7 N$ {% `) y) X% ~5 N  f/ S' i! S            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
0 E8 l: B' f8 ^# U  X5 C% Z                workView.Tag, out loop_count, out count_array, out curve_array, tol);
9 a# T$ P& t/ j9 r
9 a5 \- ?8 ?3 i            Echo("Precise Outline Loops: " + loop_count.ToString());
# k" P: C5 d) F2 g            for (int ii = 0; ii < loop_count; ii++)
& V6 y8 z1 A& q& Y, c# G% Q                for (int jj = 0; jj < count_array[ii]; jj++)% }/ p0 z- m: f, f$ S! m: r
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));* R' j: u+ I* s. a- j7 D. C( Q
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
% p" F& h4 |  ~9 e6 r7 y; R* B8 }( K- I+ P' D$ P( o, z
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
- b' f5 e% q3 `5 Q2 ~: d3 V# @            int curve_count;0 m* i) {3 p. V" ~
            Tag[] outline_curves = null;
' k+ V) Y" b6 J! N/ S# l            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 2 }- b8 T& M+ Z
                workView.Tag, out curve_count, out outline_curves);
1 K) E+ T1 ?/ e6 W0 T            Echo("Precise Outline Curves: " + curve_count.ToString());& P- h: b) q+ c( w! f
            *// X! j( v/ S/ B8 ~& G. T) L1 _
        }
  K% L5 H/ P4 {: U; `' U  b7 I6 X5 d# V
    }[/mw_shl_code]' N! q2 }) t. z) U8 p+ C6 {, H
[/hide]
, q, M( I  U6 z* _4 P% {
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了