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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓8 x6 ~; I: f% l# S0 G- R9 b( _

/ R6 W0 M% x- {8 L% Y6 o! OUF_CURVE_create_shadow_outline (view source): t9 |+ `4 G- z- ?

. t% N& f, t1 x- M* q0 w  gDefined in: uf_curve.h
* E4 S! S& e" Z9 f" H 8 m2 d7 u- B! W
5 u% q1 X8 {; c6 G2 R$ F* D( J! t
Overview
! S  r# E& T2 D% Q9 j
% B' z% ^4 y+ d3 D5 \* l' W7 ACreate shadow outline for a given array of solids. Solids passed to this ) r6 v; Q- f' y. w
routine must be on a selectable layer and visible. If created shadow curves
& A' M5 \8 r# f  T  D. ican not form loops, please use UF_CURVE_create_shadow_curves instead to get
5 ^7 T/ `* q5 O% c" }5 wshadow curves.
. G7 n7 c: g0 b7 L! K. D' {2 }3 {  ~! G$ n* \( {
' g7 T* S$ ?& x, U. [( @
[hide]
0 j  B: C$ X8 I8 t% D, t% r2 q+ P
[mw_shl_code=csharp,true] void DoIt()
! r( @% ?, J% l" l  O; j4 B    {, n( z' N! G: B) L
        if (theSession.Parts.Display != theSession.Parts.Work)
. Z. C1 F2 O, t: g7 B" ~            theSession.Parts.SetWork(theSession.Parts.Display);
! J3 `- K7 m/ ~0 Q; n1 W. _
$ `1 m! x1 u4 q( p9 p0 \6 `, ^' T2 ~, `3 T' q
        TaggedObject[] theBodies = null;
1 g7 [6 X! Y6 s7 ^        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)1 v1 j. C* w8 D
        {
3 Y4 v4 Z! D/ z6 F' X" @            Echo("Selected Bodies: " + theBodies.Length.ToString());
1 R+ Q# {9 b) h6 q            Tag[] theBodyTags = new Tag[theBodies.Length];, j+ m9 i8 q( V& D
            for (int ii = 0; ii < theBodies.Length; ii++)
1 N# \( m4 F/ g" T$ l                theBodyTags[ii] = theBodies[ii].Tag;" a2 t6 H6 k: N

$ I  g; A+ |* j& T7 y* r            List<Curve> theOutlineCurves = new List<Curve>();
, Y3 a0 B7 b  `: n" t" m            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;  T' ~: A1 Z- i* r" w0 L
            int loop_count;4 y7 J5 z& |% z2 f
            int[] count_array;9 R& a- ^8 {# t$ W- r5 c- u0 g
            Tag[][] curve_array = null;( l+ P$ I% N/ H' q7 K2 {
            double[] tol = new double[2];2 }! A1 i: C8 F0 x3 [( G  d' ^- a
, X1 }: x" f. C+ v, Y% o" l
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
% r9 A4 D. A' C& u0 i            theUFSession.Modl.AskAngleTolerance(out tol[1]);) n9 O- r% U  h, V; v
* |; h5 G+ R8 L" H4 A6 W
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,# w; f3 W: D& l; H, P
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
* u' ?, P/ z. P! a4 e
0 v; J, t6 g" l/ G  g            Echo("Precise Outline Loops: " + loop_count.ToString());) E. k2 ], D2 m6 o
            for (int ii = 0; ii < loop_count; ii++)
0 z5 d" l- T) x, R3 q' R                for (int jj = 0; jj < count_array[ii]; jj++)' |, H- H; t6 h. e" [
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));# e- p9 g% V. Q3 K
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());' D9 Z& R/ v) B" U/ f9 L

) [6 d7 T2 }9 Z: y1 {4 z2 X            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
) r" O; S: X. |1 Z            int curve_count;
) Q9 p/ n" o0 ?1 D% u4 R4 @  E            Tag[] outline_curves = null;
7 [$ \3 N7 f4 |9 p            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, $ X- b, V8 [0 J. o& H$ e) v: Z
                workView.Tag, out curve_count, out outline_curves);7 g3 W. A& t5 F1 h) y, M
            Echo("Precise Outline Curves: " + curve_count.ToString());
+ o+ w4 }) `( N2 G* S            */1 R% n% }# h% j0 ]
        }
0 N; Y$ n6 v4 u* R- b9 o1 @4 F2 k
    }[/mw_shl_code]* d! L) S( H( k2 C; ?$ n
[/hide]$ y7 w! G- o8 q: F) S
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了