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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
  r/ @% h- k* e& Z1 h
+ J( V  k7 V! ~! yUF_CURVE_create_shadow_outline (view source)
$ n: y; k5 a! P% F0 l0 g  H( { , G, T" |$ d& r7 a9 [
Defined in: uf_curve.h$ w) [* n! d6 T, |; h; x
: a4 a! q8 ^2 i( ?1 T" @9 _6 }

$ E2 M0 {% ?8 c, ~; D: q% sOverview0 g" |2 p* b5 g# A( O
8 b5 q9 A& V3 m: H0 P% ?
Create shadow outline for a given array of solids. Solids passed to this
& Z5 H) O" e4 q0 d6 k$ croutine must be on a selectable layer and visible. If created shadow curves
* a* f. E( l' A- r8 mcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
# q$ \/ C: B+ U- P# bshadow curves.
8 D3 _  @3 J% E2 T; h' V
# N- z7 z+ I+ y# l( x5 @: O* u. d' T9 `4 @/ D  V
[hide]
/ q& y- |# w$ }) W
+ V' P% p7 U, y; F[mw_shl_code=csharp,true] void DoIt()
7 j4 i/ G# @1 r4 E$ X$ b+ b# f    {" K' v7 m! }" y! b) m- k# Q& E
        if (theSession.Parts.Display != theSession.Parts.Work)+ e' C6 O2 }9 t& ^6 S1 A
            theSession.Parts.SetWork(theSession.Parts.Display);
: S& I7 H: V% D/ k3 r$ X0 A0 ?  z( e- ?5 Q- i, ^% U

/ b0 a4 B2 V: _0 K        TaggedObject[] theBodies = null;
  F9 E- V6 A, ]. L3 `: c        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
: H8 S5 t7 \( \1 l* I        {
, t- m" g+ |* e' e  }! Z- y, u9 V" ^            Echo("Selected Bodies: " + theBodies.Length.ToString());
/ Y5 L% S4 G8 U            Tag[] theBodyTags = new Tag[theBodies.Length];
1 O) W1 W( H. n+ u            for (int ii = 0; ii < theBodies.Length; ii++)2 ~! q) @5 B/ |: V7 c
                theBodyTags[ii] = theBodies[ii].Tag;1 ]& k/ c' q, |3 G
1 R7 x  j5 W. o% O# f% F. K
            List<Curve> theOutlineCurves = new List<Curve>();
- i' m5 S$ e2 {; b4 O- ]9 a' T            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
) y! z5 {% t( p  I            int loop_count;) h' B& p! S0 O. m6 d
            int[] count_array;
% ?/ R! I% r( F            Tag[][] curve_array = null;: i+ [9 [1 I- p  g( o3 l
            double[] tol = new double[2];
5 `( b! f8 q. I, C1 }$ C  Z, m( b8 a  e/ n5 h6 k! H
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
7 |) Y" `- h* I2 R) x            theUFSession.Modl.AskAngleTolerance(out tol[1]);
3 w7 e$ R; w1 l* k' f0 I2 q3 Y$ @: M" M! L! K/ I
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,* I' k$ ?8 _$ i* ^% b! L
                workView.Tag, out loop_count, out count_array, out curve_array, tol);. S; c; x1 ?( ?6 g/ ]& U" `
, ?5 T! `+ V; g) h3 K1 |
            Echo("Precise Outline Loops: " + loop_count.ToString());
7 |8 d4 D  g) D$ L: \% Q            for (int ii = 0; ii < loop_count; ii++), B+ G2 {. k1 L& u0 C
                for (int jj = 0; jj < count_array[ii]; jj++)( x0 o+ W! d: w3 Y$ _! I5 d
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));8 |, {8 D& l; R- E3 L( `- e8 k0 A
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
& ^* |5 ]9 u# n% o: m  Q1 X
- ]3 r4 c* f+ j( [0 W            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead + f; J( P6 w0 w9 |" w
            int curve_count;& `5 k# y6 V3 J% q4 Z7 v/ p0 N- b1 l
            Tag[] outline_curves = null;
5 \6 N9 {/ w. F6 G            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, # h$ e7 V$ E! |6 G& v
                workView.Tag, out curve_count, out outline_curves);) o6 R+ a* ^& O! G- d
            Echo("Precise Outline Curves: " + curve_count.ToString());
  I$ H" B3 p( c6 B# y            */0 K7 K' c% L& J+ k
        }
8 \2 S) U9 u  i) T4 i$ P9 I) `' k8 s/ h3 j
    }[/mw_shl_code]3 G3 q3 N# d( C, M, J& V
[/hide]
2 J% s3 ~( R% h) o! M* @5 r
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了