PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
5 E5 u! g) v) @# x
! J6 N. G; G0 `' `) w; WUF_CURVE_create_shadow_outline (view source)& f$ I: z. v$ Z( K, M( Y& E" x4 P, `
, f5 Z4 h9 I7 t8 h
Defined in: uf_curve.h
, J6 f+ X- V6 D$ j) s
5 x2 i3 ?, f1 ?9 Y
  q, R+ K. g$ }0 b( T4 q( NOverview
4 G% o+ R3 b- s; _+ v5 |0 ]) L& z1 c" r+ b- ?3 m
Create shadow outline for a given array of solids. Solids passed to this
( O' C2 Q$ y' T7 W, Iroutine must be on a selectable layer and visible. If created shadow curves " Y2 U$ E5 _0 W7 E/ C7 J
can not form loops, please use UF_CURVE_create_shadow_curves instead to get 2 {( @+ z( {* P2 z
shadow curves. 8 x/ o3 k% ^6 Y: p' A" D

; A- [% ]1 L" ?) D# ~2 W( ~) N& k, R% B
[hide]
$ W" T) g0 c  w4 [+ V) g) R
/ @5 q) }9 r+ l- }2 a. T[mw_shl_code=csharp,true] void DoIt()
- }$ ?' `- `  ~( x    {: n4 g. ?8 J5 z* C$ n$ c% D
        if (theSession.Parts.Display != theSession.Parts.Work)
5 G8 r+ X( z2 y$ W            theSession.Parts.SetWork(theSession.Parts.Display);
, Q. y$ U, C' w0 ?4 i$ N; G8 B4 b& Q* V4 S
2 O2 v; M# i1 ~* E# d) \: ^8 D
        TaggedObject[] theBodies = null;& l/ g; ^1 s+ B% ]5 c7 `  Z
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)4 l% C, [" S+ `5 T0 u3 M
        {0 ^$ R- e9 b9 k
            Echo("Selected Bodies: " + theBodies.Length.ToString());
7 H" N6 t9 O* w: _. P* k- a5 O* ?            Tag[] theBodyTags = new Tag[theBodies.Length];
/ B! w( W( c! @. P5 D            for (int ii = 0; ii < theBodies.Length; ii++)
* @; Z* Y, u# k5 E" L                theBodyTags[ii] = theBodies[ii].Tag;
8 Q4 x# m# q6 z6 z# m: d) t% o$ _, c: ^( h0 V
            List<Curve> theOutlineCurves = new List<Curve>();. W% d" v5 S4 ?  W2 _
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
$ [0 _- \1 i" }9 {7 ~            int loop_count;
. M5 r- f  K1 ^# ]+ |  E            int[] count_array;7 [" [( C9 V. R2 Z2 K/ j( U  d& ]( m
            Tag[][] curve_array = null;
: T5 t( s7 n/ x) |3 k$ b5 ?            double[] tol = new double[2];
; G' T" b" N, g, Y! L0 s4 e
* a$ ~/ l2 _% F4 w            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
, A1 y: @8 N+ k. l2 Q2 _/ e4 m; a            theUFSession.Modl.AskAngleTolerance(out tol[1]);, \+ c4 v  d* Z& o9 X8 G4 O- J8 L

# b( S$ a' J1 A3 _6 Y0 `# N/ Y            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
7 ?" z4 z. |7 k                workView.Tag, out loop_count, out count_array, out curve_array, tol);
- R* m" Y3 F. H2 \+ l. z
1 O; @0 Y% {+ o. ]            Echo("Precise Outline Loops: " + loop_count.ToString());
. Y7 O# a; o. a0 R6 c$ ]9 V9 N            for (int ii = 0; ii < loop_count; ii++)
; l( f& t6 o" X                for (int jj = 0; jj < count_array[ii]; jj++)6 l& F- M! ?6 a& ?% q0 s# S) S
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
& i5 W% n/ @; T7 Z2 ?. a            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
8 N" d1 @4 C5 e; m) h/ a/ n# e; n/ D+ i* P: o/ R/ U
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 3 d0 i9 y2 \4 m: }( W+ ?  D
            int curve_count;
! J2 \  k# l8 S! C            Tag[] outline_curves = null;0 n$ }- ]! m8 x4 s  p! [, h) x
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
; z3 ^5 R$ l1 s0 u+ e" ?2 y                workView.Tag, out curve_count, out outline_curves);
: l0 t4 {8 }* g' _5 I            Echo("Precise Outline Curves: " + curve_count.ToString());) ^0 j: E$ t/ Y& y% T
            */
# h+ ^* @) Y7 L: ~; v$ a( Z0 `        }. d0 x  k; B. ^4 [! O5 L: a3 R: t. A

1 b) \7 J' b0 x/ r, z    }[/mw_shl_code]
1 D& ?' ]- ]6 ~, a8 Y( o- h: a8 h[/hide]
3 w+ D0 g$ Y3 x" z
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了