PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓8 R3 ~8 Q6 U- y

2 _6 L. L/ Z/ o/ S4 XUF_CURVE_create_shadow_outline (view source)
; N2 J8 E/ q9 c9 b: t; Y
  k. ]% \$ ?  H+ j0 xDefined in: uf_curve.h) o3 @. |( v! P+ a* J

- \- v. s5 b9 ~; Y6 `& ^
; ?$ o; ^' e7 @# x, h2 \Overview
0 c( D  Y1 t4 J& A5 L" X
" o1 O& h7 k6 d' F& m! tCreate shadow outline for a given array of solids. Solids passed to this ( B# |3 Y+ K9 k' q7 C
routine must be on a selectable layer and visible. If created shadow curves
4 e9 [( n2 H1 X( c) Ncan not form loops, please use UF_CURVE_create_shadow_curves instead to get % x. W7 \/ E/ g& a2 ~
shadow curves. % F) w- d2 b! o/ U

2 I1 P3 w* x$ r2 A$ E( g
! I5 |  [) M4 W[hide]
- i% u. r$ W: I% y
$ \  X' Z4 P4 Q/ O/ F) m6 O+ w5 o: f[mw_shl_code=csharp,true] void DoIt()
. i  i+ L" a3 k3 c( _- {* P    {6 B& V- V9 \! i5 L3 ?
        if (theSession.Parts.Display != theSession.Parts.Work)
5 b: _/ e7 A% t/ K3 c. r# f, T0 ^            theSession.Parts.SetWork(theSession.Parts.Display);' P9 a0 K; P* G  n, `0 x
2 u  |7 {, ]: `. ]
' z' G& I1 i! Y5 z" ?& ^6 ?5 f
        TaggedObject[] theBodies = null;% y& ~, j( d" H1 M
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)/ y# r! O* U# k5 h! }( N/ j$ l2 o
        {& S; W" z* }- j- S% U% v
            Echo("Selected Bodies: " + theBodies.Length.ToString());
1 z' ?: i, a- D8 c& n            Tag[] theBodyTags = new Tag[theBodies.Length];6 g4 |* w+ t: Z) K# j' y! y$ R  Y
            for (int ii = 0; ii < theBodies.Length; ii++)& {& _6 m" r+ k0 O
                theBodyTags[ii] = theBodies[ii].Tag;
9 s+ x. u0 `* {
3 s& U% G' t5 o% h            List<Curve> theOutlineCurves = new List<Curve>();
4 f& Y# Y1 [6 a            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
. J/ f9 h7 _1 U- M; u            int loop_count;" @, d* I$ N! j  F/ h$ j
            int[] count_array;6 T" \9 X; D$ K& c  z. P: u
            Tag[][] curve_array = null;
" `' k6 k" f' @            double[] tol = new double[2];% Q7 S. v4 v+ e* J
$ u7 I; q3 k' `" Q/ H% Q# ]
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);1 J! o8 c6 Q) J) |# |6 V1 l
            theUFSession.Modl.AskAngleTolerance(out tol[1]);2 q# r7 c. x! h8 T
) v2 [9 {5 l' t1 e0 ?8 R
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
: t4 c8 |" w% y% ~6 I3 a+ l: E; k4 H: y                workView.Tag, out loop_count, out count_array, out curve_array, tol);
0 ^, y" Y" z0 o. ?& ^: H0 c/ ]( ]1 e7 d8 r7 U7 s
            Echo("Precise Outline Loops: " + loop_count.ToString());5 z' W6 g$ R5 d) L  k& a: m$ U  q
            for (int ii = 0; ii < loop_count; ii++)
0 L+ P0 f- I3 C# s                for (int jj = 0; jj < count_array[ii]; jj++)0 y: w( v  Z/ }6 V' Z& q
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));' T3 `2 R; U* G  W
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());4 r% v; m! t, J( o* U7 M0 }

! o, |! n2 \; H) u. K. I            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead $ ^& j1 K% h3 R  `8 I/ z3 x1 D* @
            int curve_count;
# K$ K4 G+ W2 ?$ S% Z' e9 g* @            Tag[] outline_curves = null;  e8 d* F/ H6 K
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
2 e7 o4 y# H& v$ j* T                workView.Tag, out curve_count, out outline_curves);
3 z* e; m$ |9 Y& k            Echo("Precise Outline Curves: " + curve_count.ToString());
1 O8 F6 g/ N' q$ w$ o            */
- E, `& x6 r- @: ]1 A        }
' D2 R' w; s0 @& w: @
! P' N5 ]$ L3 Z9 y; Z. ?2 }    }[/mw_shl_code]
. O" M" s/ f5 y! o$ V[/hide]1 b' i. p2 @! d
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了