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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓5 [2 {" }( a$ e" v
  U/ H; ~$ y- Z( ~
UF_CURVE_create_shadow_outline (view source)/ R6 i& }' [2 A# B/ o% J) P

8 K9 e0 o$ O; G- p/ d) V* ADefined in: uf_curve.h
# p) w( d1 V- _0 ^. l: x / _& j0 K. ~- |9 J7 g

$ {  K0 S) g+ k4 S/ OOverview. U! Y1 x! X; v& [
5 A4 F/ W9 x% j; F& {! O
Create shadow outline for a given array of solids. Solids passed to this 6 h5 I) {: [8 T& V+ C
routine must be on a selectable layer and visible. If created shadow curves - i- `! {+ U3 J0 X. {; M
can not form loops, please use UF_CURVE_create_shadow_curves instead to get 1 M  d* V& |' C: m! q
shadow curves.
2 j- v- \7 R1 S; L8 T, ^9 t
+ n, ^+ a, Y' s7 Q; c2 \) q; w  I) U" g% V  H; |
[hide]2 N9 O5 v( O5 a1 t6 |+ T
, `2 K* D8 k* }* Y
[mw_shl_code=csharp,true] void DoIt()+ W  w8 @5 D  u' P
    {
% s! D: K$ k9 T$ Z7 u+ n. P) F        if (theSession.Parts.Display != theSession.Parts.Work)
' e, P$ t6 p/ ]! N/ U" C            theSession.Parts.SetWork(theSession.Parts.Display);! X/ ?6 J6 A) Y9 r6 J

0 O0 Z8 O9 Q0 n8 [: P* w1 g# T; N6 X( F& h; d
        TaggedObject[] theBodies = null;
5 L/ h8 }; I, u        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
7 w5 K/ F, [" ]        {" p- e3 s: p% Z6 F& S) w& p
            Echo("Selected Bodies: " + theBodies.Length.ToString());& \, y. O# u( [/ U
            Tag[] theBodyTags = new Tag[theBodies.Length];
* r5 e3 l* {' _( D. S5 }% y            for (int ii = 0; ii < theBodies.Length; ii++)
' |* z* W3 ]! M" z4 R5 f                theBodyTags[ii] = theBodies[ii].Tag;1 {& s" l( c& J4 j% T+ F3 }
2 P3 w) t- W; T% u9 w  }  T/ u) T
            List<Curve> theOutlineCurves = new List<Curve>();" G) e0 m  c5 s8 f) h! N
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
7 X/ |, H% c. [( M7 ?            int loop_count;
, A5 _9 R/ ~. a% o+ v0 k            int[] count_array;, m: d, R4 B- F0 ~4 u/ T1 F; B
            Tag[][] curve_array = null;
5 h$ }, \. C& A' _4 e- h+ W            double[] tol = new double[2];0 A3 ^0 l/ H7 p1 Q6 n" Y( K! f: L

" h7 b" e7 }& ?+ c" ?3 n9 T+ Q3 ^            theUFSession.Modl.AskDistanceTolerance(out tol[0]);: E  R- {6 A$ z5 s1 C
            theUFSession.Modl.AskAngleTolerance(out tol[1]);( j+ B3 T. Y2 r% {- o( \* s
1 R) z9 p" ]) O
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
, w, l$ T. i4 m* ~                workView.Tag, out loop_count, out count_array, out curve_array, tol);
, i! T/ B2 D3 H( m7 p+ ^1 L! X2 O
* w7 W; q2 S, H            Echo("Precise Outline Loops: " + loop_count.ToString());# e/ q4 i) X5 y: ?1 E
            for (int ii = 0; ii < loop_count; ii++)2 [4 p7 v2 E6 J. Y! i2 ]
                for (int jj = 0; jj < count_array[ii]; jj++)
' n" e2 _  a/ a; t                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));( u$ U4 w* T4 n- o! g5 s; ^
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());7 G* }6 _* E7 s# U  ~: N9 v

, U+ Q& S# b# m6 k' M9 m            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead , j- g- C- G4 Q; I
            int curve_count;
2 ~; F; H( u" Z0 r" Q            Tag[] outline_curves = null;
5 Q: }& ~+ K' j: |# p- f7 B! r. N            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
' |. e+ b1 O, K9 e6 O2 ?                workView.Tag, out curve_count, out outline_curves);
% A, x; G% y, A* E            Echo("Precise Outline Curves: " + curve_count.ToString());; P& z! B( l$ c8 j. O+ X
            */& W1 X- F. Z" X* g# x
        }
1 M% ^, D% A2 a- X, G
+ |5 F" M2 {' Z2 ?  i5 ?    }[/mw_shl_code]/ X8 M8 `; |: I- P- K
[/hide]
; t" \' ^& v7 h, m" K8 q0 ~0 [
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了