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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
2 D! q6 o0 C+ ?- \. Z
, H+ ~- J% ~! h; ]* x. U: \UF_CURVE_create_shadow_outline (view source)
9 o# q! P* }  G2 W# @. r 7 M% ?2 W) g. J) A, r) o4 f4 X) |& E) o
Defined in: uf_curve.h
( e4 }% V: N$ o8 T+ O& T% i9 r
5 s9 T( n9 g& v* r9 W4 ~; a# F9 H% d9 u# o1 j- a5 `
Overview+ V0 K: C+ i2 m% {" a
& H# ?7 v6 P. |8 B
Create shadow outline for a given array of solids. Solids passed to this ) y' q9 x7 I' R( T8 x  C
routine must be on a selectable layer and visible. If created shadow curves
/ [# q4 X8 d' V1 [  M. L9 ican not form loops, please use UF_CURVE_create_shadow_curves instead to get " C2 G* `$ ]# G7 b0 p# Y% q3 X
shadow curves.
; s: V/ |$ y5 T$ x
$ ^5 J0 x. P, Y0 m& b
# r; a: l8 _9 G/ h0 Q" W8 F0 t6 |[hide]
$ B8 F0 `  G: W' X
- g1 L3 E: @9 t& G( e$ Q  D[mw_shl_code=csharp,true] void DoIt()
: U2 I5 o; S: y% b' f% M    {
: H) o; l& }" ?: c6 {        if (theSession.Parts.Display != theSession.Parts.Work)
$ n8 [3 H; C& Y+ e* N            theSession.Parts.SetWork(theSession.Parts.Display);
; T; K+ R: c1 Z8 N- C
, ]9 S5 J9 K, z/ h0 {8 K
0 q- ~: ]* I/ Z& J( G0 [# a        TaggedObject[] theBodies = null;- m, `9 U) ?) Y1 u' ~4 u
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
2 O: C8 S, [9 U3 y* x        {
! x& I! ^  J% W5 I% M7 t: {/ Y  b% `            Echo("Selected Bodies: " + theBodies.Length.ToString());1 I6 u3 x# N- W# D6 s4 _
            Tag[] theBodyTags = new Tag[theBodies.Length];5 _' @  _$ Z3 {3 x/ G8 z& z9 `
            for (int ii = 0; ii < theBodies.Length; ii++)
5 ~2 }$ n$ V$ g! i2 n, Q8 v  z, V                theBodyTags[ii] = theBodies[ii].Tag;
5 o7 |2 {4 {0 k; r! V
, [8 Z: L2 G; W" p; T7 n2 l            List<Curve> theOutlineCurves = new List<Curve>();7 q$ [7 \& q/ y8 u
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
* Q! f9 _# a  I5 N: i$ \            int loop_count;: G2 e6 C' ]" |+ X! ~( ~+ Y
            int[] count_array;
0 i# b6 ?0 ~' f& \            Tag[][] curve_array = null;
* x# N( P' x; a; K* C            double[] tol = new double[2];9 O: i/ G# ?8 h: l/ o

- m. }" S9 G$ a6 K; o! g6 [' w7 @' A            theUFSession.Modl.AskDistanceTolerance(out tol[0]);  p3 y; h) t( _+ a' f& C4 \# R* u$ Q& `
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
9 u! x# L+ [0 ]! l4 c- b7 w+ I( c) l) ~6 f0 A3 B
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,% P9 X7 g* l3 D7 W
                workView.Tag, out loop_count, out count_array, out curve_array, tol);% Y& S, ^. b" }8 I3 `6 r
6 Z! M2 t% _3 l" _3 P# W. s
            Echo("Precise Outline Loops: " + loop_count.ToString());: x; e2 K! r5 H) t
            for (int ii = 0; ii < loop_count; ii++)1 W0 b+ }  `+ {  R) p4 |2 t
                for (int jj = 0; jj < count_array[ii]; jj++)
3 X' x8 e/ l& k3 ^) @7 t& ^4 w+ l                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
# b/ U! v4 p: a( n: t7 `            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());: u4 ~1 d; _# t+ k- J
! J$ A- W1 a, O0 S1 n- Z
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 3 v. j( p5 |7 t8 t
            int curve_count;
/ N- D6 w$ |3 w6 q            Tag[] outline_curves = null;; u3 N$ c2 _' t$ J  Y  _. X
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
- t* e3 s8 t- }  Y% ]                workView.Tag, out curve_count, out outline_curves);* o5 c- e/ I1 G
            Echo("Precise Outline Curves: " + curve_count.ToString());& [6 r5 J1 s2 o7 ^8 x
            */
, [: }& m9 ^- [9 D- j0 P# O        }
& h3 G) k' O: A
5 j/ n6 {! Y% m+ O' M4 Q    }[/mw_shl_code]( ~6 b6 B2 [# V# N4 j
[/hide]
: U) J' I! s+ m+ c  ~6 n
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了