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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓8 m) ^% M  n6 |( h" y

$ q+ r6 T" @* g) O7 y' ZUF_CURVE_create_shadow_outline (view source)
7 d6 w" d/ `+ j8 c: ~% R8 @/ S
' G& v( C, S! u2 S4 ^; wDefined in: uf_curve.h1 G+ \9 m5 [8 M& H. H" d4 f

6 w/ k, J  B1 n: A, P( k5 f
  G" P& b3 H4 i1 P4 h+ z) tOverview0 k& F& v# n2 O' T
: k- P7 ~9 j2 i
Create shadow outline for a given array of solids. Solids passed to this
* i) R- L6 ~+ D/ t, u" g! Wroutine must be on a selectable layer and visible. If created shadow curves
$ x4 A! j& S4 Z9 s7 j- S: K1 ocan not form loops, please use UF_CURVE_create_shadow_curves instead to get 3 Z; s' Z/ i2 X) i# X/ Y" d. l
shadow curves. 6 k! o; l. q3 v

6 a- Z+ C* V" ^$ a1 \8 _3 Q/ X+ x9 e! u+ i: C) r. z
[hide]
. t( |: u: i  m" S$ W. u$ k0 R: z- [9 v4 R8 n
[mw_shl_code=csharp,true] void DoIt()
: l. b7 x7 N2 l, C    {
/ s8 I* s# K, A) y        if (theSession.Parts.Display != theSession.Parts.Work)+ q- O% l: [) {; M) K  q' n+ E
            theSession.Parts.SetWork(theSession.Parts.Display);0 Z7 D8 R9 c- W# A7 m. @5 P
- l/ C) D/ A* \1 f1 w

( c% ]% W. h1 i& w# X        TaggedObject[] theBodies = null;- @5 {: T7 u0 B* n
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)/ Y) U% y4 t; L( O7 x# A% _  C
        {
  i- i6 e! w' \: X6 F: Y            Echo("Selected Bodies: " + theBodies.Length.ToString());' J4 \$ P. V0 \4 E) g" w% T% z
            Tag[] theBodyTags = new Tag[theBodies.Length];, K& k; ^) `6 J
            for (int ii = 0; ii < theBodies.Length; ii++); j6 D& L+ t( E, `: A
                theBodyTags[ii] = theBodies[ii].Tag;
- w9 W( L# R  g. u; [. O: z2 r+ ^0 T3 j) \, o" n6 M
            List<Curve> theOutlineCurves = new List<Curve>();2 U" C1 s3 M& ~! b
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;  ?1 o1 y8 j- B4 s" ?' _
            int loop_count;
) r: D" W) w! i/ U+ ~            int[] count_array;
( [5 S3 \9 a5 e' C8 E6 }            Tag[][] curve_array = null;
( w. p/ d; D, j: z! \! e            double[] tol = new double[2];
* J/ K. T3 s. g0 l8 z9 e2 {8 X: x1 Z/ h% r) G( B4 Y5 l- r
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);. V5 N& j5 R8 Q3 t, c! m
            theUFSession.Modl.AskAngleTolerance(out tol[1]);- _( F0 x# W2 D9 P4 a
  w; b! P6 W. i" `
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,, p( U* ^- i6 u7 Q
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
' m' u5 v$ f# {9 z* F
4 M' _- F+ O( P            Echo("Precise Outline Loops: " + loop_count.ToString());
' y* r3 U% D# r: o* Q9 ?: x5 u            for (int ii = 0; ii < loop_count; ii++)
8 T: a9 k" v6 Z; I& Y( ]7 p                for (int jj = 0; jj < count_array[ii]; jj++)1 c' o# C4 X" B% {# X. v7 g
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
7 y4 |0 x+ D* v' @4 w5 ~3 n$ C            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());  j; |) L( v$ L: ~7 _

0 u0 ?: `  v6 y3 V            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 4 \, m; ^9 D/ u9 A  y
            int curve_count;
9 N6 Y* L% _0 H9 Q; }            Tag[] outline_curves = null;# u$ {2 W) m* z) p! J
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
$ V1 L, t0 R$ g                workView.Tag, out curve_count, out outline_curves);
/ p7 d5 G) f" M# ~: w; j2 l            Echo("Precise Outline Curves: " + curve_count.ToString());
$ g* ^3 C% U, ~- U7 D2 ?) q& l            */! M) V. d% l5 x1 C+ p; a. t+ Y' W
        }
$ G$ {/ D/ @( r& [5 C1 R' D8 a! t8 G3 c
    }[/mw_shl_code]4 w% ]* h6 f. D( i5 P& c2 T0 j
[/hide]5 f" y$ s+ m( d/ T- F  c& o
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了