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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓& Y' ]8 }9 v' c- H
1 Y3 P* y( L" k# s# r- h
UF_CURVE_create_shadow_outline (view source)
4 O, o+ Y, }; B' ]4 G8 L2 m
& r2 [- a6 D4 q/ C3 f+ F/ E2 _% DDefined in: uf_curve.h+ w1 S5 V6 y& s# n& Y' ]; m8 W: x

, V. v# ~7 g5 w
0 z7 t3 `; u+ h- g, zOverview/ S" |) j6 Z1 v

0 Y5 u& k$ j! {" tCreate shadow outline for a given array of solids. Solids passed to this
9 [- d/ N' }! K# t3 E3 x8 [routine must be on a selectable layer and visible. If created shadow curves 5 q/ [: I: `. q
can not form loops, please use UF_CURVE_create_shadow_curves instead to get 7 g0 K; n4 |' }" ^' Y
shadow curves. : \7 f- S- k0 l& }: a4 T
; M& f: E1 `# S
/ U* R$ _3 x0 t) ^- l( a% U
[hide]
0 C0 Q% x3 y% Z# a: \" ^0 ?8 I+ r. M' G3 \
[mw_shl_code=csharp,true] void DoIt()
, h1 R1 {. w1 Z5 R# A7 X! t" q    {' q2 e7 f4 w$ q4 x
        if (theSession.Parts.Display != theSession.Parts.Work)
& L8 u$ q' b0 I& r) Q            theSession.Parts.SetWork(theSession.Parts.Display);9 R9 e0 x; D  i8 j. J

  w  U* d& J  Q/ v) g7 T' R0 o: s( o! N* ~. G1 g7 B# d
        TaggedObject[] theBodies = null;2 k3 P7 u! i* `$ @5 l6 e7 c
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
+ [; F/ j/ R; p/ K8 W* T        {
. W0 j" D* C5 |            Echo("Selected Bodies: " + theBodies.Length.ToString());9 Y7 Y* \/ e9 ^$ n
            Tag[] theBodyTags = new Tag[theBodies.Length];; Z, J( Z& ]+ m5 x- h8 M
            for (int ii = 0; ii < theBodies.Length; ii++)3 Y  |* R4 M% d
                theBodyTags[ii] = theBodies[ii].Tag;5 Y, c! E$ C+ s2 C9 v" k, U3 g

$ c6 r2 {5 P7 w- [% @& F: n! R$ f2 H+ X            List<Curve> theOutlineCurves = new List<Curve>();/ i% m. ^" T  W  t& s) _: ?* \. @
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;8 m" e$ O( ?  ?$ @" h. P+ x: j( K
            int loop_count;
+ q# ~* p& t3 c/ V# G* G            int[] count_array;
0 [, r3 U% v: v# l. B            Tag[][] curve_array = null;
' \( w; a. O+ \* h            double[] tol = new double[2];: M/ ^# t  ?" j/ X" V. T
6 X7 J6 e% u. c! d  i! [
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
/ u% M2 \) ^2 x' a/ w            theUFSession.Modl.AskAngleTolerance(out tol[1]);
) \& ]* Q8 v% M4 a# J9 q- B2 S; X3 ~: A) r& Z9 I( n4 R+ v. O
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,  ^2 r/ a4 U. W% |
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
+ B3 F! T- w( f
2 v+ q; g5 C/ c, j( Y            Echo("Precise Outline Loops: " + loop_count.ToString());
6 {+ w) Q5 B4 x% r; d) h* o5 _            for (int ii = 0; ii < loop_count; ii++)
8 x: q1 ?, x' l% y5 i3 w! F- x  S                for (int jj = 0; jj < count_array[ii]; jj++)) o! }3 {$ Y2 i/ P
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));5 W/ X% i" U- U
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
" x2 y( J9 b& B4 ]# T0 F0 G$ G) s7 b# P# i/ s, `
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
0 Q4 x1 x; p; O' q4 u8 c            int curve_count;8 }. m3 Y; x. m* {1 U
            Tag[] outline_curves = null;
: z4 Z5 ^8 Z# d+ `% V            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
4 [1 R! _! a! K" f3 l                workView.Tag, out curve_count, out outline_curves);
2 {$ {+ {- ]* ~& |            Echo("Precise Outline Curves: " + curve_count.ToString());
& ?; t/ `1 b4 p            */* F1 v: s# Y* W0 r
        }
& u/ z) ]8 v& R! n! |3 h
: R" |( \4 K( E- y. K( \    }[/mw_shl_code]9 |' {3 n* G3 F$ ~  t, `0 K
[/hide]
1 @4 H! Z8 q& y6 O* X
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了