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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓9 _: c5 g! r$ O) s) I

9 t: T# D3 {) Q# |UF_CURVE_create_shadow_outline (view source)
! [5 G8 p. k+ Z( Z) i ; G& `& w, z+ e1 F9 ]9 g
Defined in: uf_curve.h% r# [9 U+ O, u$ W. ~8 m
" i' f7 G$ ~7 B8 C1 |
$ C* \1 F/ y9 i1 R( F
Overview/ c6 p% H, _$ e& ?9 U# H

2 A- y% R2 P6 N9 Y. xCreate shadow outline for a given array of solids. Solids passed to this
8 M) o: ]* d1 h% R& ]" g& n! vroutine must be on a selectable layer and visible. If created shadow curves
4 ~" r0 \) X$ z, ]can not form loops, please use UF_CURVE_create_shadow_curves instead to get 5 Y. R# p% e8 C3 @4 t
shadow curves. + u( x: L8 d/ R- Y7 C7 I7 o, W& J

, e% n! P9 f, t* o$ k3 T4 u" r1 ?  d4 w0 U
[hide]
, {2 y3 ?3 r6 y4 o* {3 _3 S, y9 |+ h- c! D* X$ y# p* p( ]
[mw_shl_code=csharp,true] void DoIt()5 _1 d& a5 p) c0 y
    {5 {$ p) Z! Z( ?
        if (theSession.Parts.Display != theSession.Parts.Work)
6 q% T- r8 n& V) b* U0 Q            theSession.Parts.SetWork(theSession.Parts.Display);- A3 l8 \5 F8 A4 f5 h, h! N& m/ N
* ^# e5 I, k& D( ?% I
; Y; J/ u, |! s& }: N
        TaggedObject[] theBodies = null;
0 o- i4 _  u0 [0 p        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
" _$ A2 B0 p: G5 O. A/ P# P        {% q3 D  |5 g$ V* E
            Echo("Selected Bodies: " + theBodies.Length.ToString());
' C. N' ^8 ]7 v% O" [3 J; U2 m            Tag[] theBodyTags = new Tag[theBodies.Length];
5 k2 U  C% w5 i5 L7 G4 Z2 V            for (int ii = 0; ii < theBodies.Length; ii++)* ~' l! ^' k) H
                theBodyTags[ii] = theBodies[ii].Tag;
  k  S8 w9 P& m8 Q0 ~) L- F; j5 f+ n5 b. R& f# s
            List<Curve> theOutlineCurves = new List<Curve>();% |; u5 S0 y6 C0 x' }5 N  L) M8 k
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;. N$ p0 D5 ^" d3 D% q+ R: w
            int loop_count;
9 i2 ]7 p; l( }! d& z& p  x; n' O            int[] count_array;2 F3 s" L) E& b$ O4 ^
            Tag[][] curve_array = null;
3 G; x7 J" u: q" g            double[] tol = new double[2];
: ]5 a; Y+ }7 F" k: Y
/ E8 ?. H0 H; v0 g4 C# d4 e) T            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
: v0 Z1 s6 h. f6 {            theUFSession.Modl.AskAngleTolerance(out tol[1]);
8 g' o, O  V# r' j) e+ n$ ^7 |- H% |5 G
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,& @; b* Y/ r/ r9 w0 v
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
! G- I8 C) K: r" _" {; v
% N6 I6 p" m- o  F% O            Echo("Precise Outline Loops: " + loop_count.ToString());
: y: P, S6 S$ `7 O6 u' v            for (int ii = 0; ii < loop_count; ii++)( i! j2 S/ P- ^  H9 R. d
                for (int jj = 0; jj < count_array[ii]; jj++)
% A' e6 [4 r3 |8 I7 v                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));2 W2 q: r/ [) g4 A- o1 g4 V' j
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());4 ]) `# |! Z  j! [+ u% O
0 X( m7 P0 [+ k! w
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead ' \1 ?  b( q, M+ D$ ?
            int curve_count;
3 A6 l3 R, t/ ^+ }4 |# a            Tag[] outline_curves = null;3 a+ ]7 L; K. i! y- D
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
! d) K: A4 b% s0 j                workView.Tag, out curve_count, out outline_curves);
; n2 A% G0 f5 w$ ~9 h- K            Echo("Precise Outline Curves: " + curve_count.ToString());: r# p2 I$ N5 u1 h
            */! h1 |  p/ W  [* }1 j
        }: g7 N7 M/ F0 p# Z7 N5 h" }

6 N$ V) t7 q% K    }[/mw_shl_code]8 j# u5 l4 t' P/ U
[/hide]8 ^; N: ]- Y# F
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了