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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
8 {! K' l/ S2 i9 w
( K4 Q( {7 s# @1 `" [- Q. r3 IUF_CURVE_create_shadow_outline (view source)
* X" k3 C& _! e+ C5 d: z
6 R& ]6 |" N. Y1 H0 f+ uDefined in: uf_curve.h8 g1 b$ L+ v  T. H% ]. t1 h; X
$ z, c! }2 Z" X7 `- ?7 w
3 \5 W$ R3 L: [4 r/ o
Overview
! ]8 D7 \! B( u: m6 n9 r, ?% c* E+ J0 C6 `" }
Create shadow outline for a given array of solids. Solids passed to this
' {( t* Q+ m0 |  Broutine must be on a selectable layer and visible. If created shadow curves
1 d9 {1 c7 f5 X2 h: K/ r+ |7 C, lcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
' O9 k5 t7 L1 b3 P( ^7 x. @) oshadow curves. - A6 ~1 D8 K% u, G5 E# |2 N7 r
0 v1 k0 m, X" ~3 V( j2 k

& u! f/ L" h+ V7 m! F, M[hide]. W* \  x# Z4 R4 ^

8 S8 t% M( N7 q! Q[mw_shl_code=csharp,true] void DoIt()0 f! t' h2 m5 j7 W  t, j% U' B
    {) d, g! z, o* E( g* d# k9 g
        if (theSession.Parts.Display != theSession.Parts.Work)
  {& l% w9 K' f! X9 l# W2 T            theSession.Parts.SetWork(theSession.Parts.Display);6 |" ]/ H- [- J' m, X& _+ H
6 ?  m/ E8 _! n4 z* H

" F/ a( b3 |& R- R& W7 v3 c        TaggedObject[] theBodies = null;$ z  U! N$ m1 D  o$ K
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
1 n+ [9 J7 m. _/ y- J6 N        {
9 L6 B6 F8 n; l/ S" Z            Echo("Selected Bodies: " + theBodies.Length.ToString());
* e6 P" v1 O+ t, X% I9 r* N' ]            Tag[] theBodyTags = new Tag[theBodies.Length];5 Y$ U3 [, m; X5 }
            for (int ii = 0; ii < theBodies.Length; ii++)" g: d# A* R5 ?5 ?3 C* P
                theBodyTags[ii] = theBodies[ii].Tag;$ _' ^/ A& q4 e1 G: l

: Z+ M7 l3 z7 n$ G            List<Curve> theOutlineCurves = new List<Curve>();% Z- w. L. |& M: \" T, N
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;* I) k' A+ a  D# [# r' z$ ^9 M8 G
            int loop_count;
  h- i1 u4 B( Y            int[] count_array;
5 _( C$ n; o* M+ V+ I9 ]4 r            Tag[][] curve_array = null;
$ ]7 H/ w9 _: X: Y            double[] tol = new double[2];+ z/ Y# _6 m4 N, L" r

+ W6 \0 J6 y* v3 x8 {            theUFSession.Modl.AskDistanceTolerance(out tol[0]);- L! h4 s: L* `  Q$ H" z# }7 @: P
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
' f6 W% E6 ]& |( q. A7 L" p8 ]3 v0 f, f9 |! B7 y
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
) g5 E- w! C% O                workView.Tag, out loop_count, out count_array, out curve_array, tol);7 _4 n6 S4 d/ n0 K4 F( Z! X; y, F' h

" @! L! |; V2 [* _2 L; v; T            Echo("Precise Outline Loops: " + loop_count.ToString());$ l8 u  m" n& X9 W
            for (int ii = 0; ii < loop_count; ii++)
5 _( N: y+ m0 n! R- g                for (int jj = 0; jj < count_array[ii]; jj++)
8 {' t2 W5 a0 J0 {3 d3 d. b                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
0 D9 W5 e  e7 {, D6 V: V+ A* C            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());% b/ N5 @) A4 x$ z1 T. A& M

" f8 U: [; R9 M3 @2 B            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 9 v, {- n5 X- S6 h- n/ d: Z! f$ N
            int curve_count;: k# j* }" O" `; M  S4 J, c( t
            Tag[] outline_curves = null;1 w# c4 c5 V4 V9 o+ S% r& {
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
' K8 m  t2 V! _5 [2 {                workView.Tag, out curve_count, out outline_curves);
3 \1 e2 g( A' t$ `6 H1 F& t1 Q            Echo("Precise Outline Curves: " + curve_count.ToString());
# p0 Z! X7 {3 l- x/ y+ N            */
9 R& g' W6 O5 Z* g, V        }& E' {  I! r# c: [! S- }6 y- E) L

0 \% W$ d- ^9 Q/ X  A    }[/mw_shl_code]
$ L0 @+ b  G( j5 {' d# [: O! S[/hide]0 l+ |4 t7 j: a' H+ Z7 `# K0 L
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了