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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
/ e6 K. g4 e$ |; ?; z7 g) X- C2 R3 u& I0 X" d' A4 z
UF_CURVE_create_shadow_outline (view source)1 V2 R: {8 \4 Q: z- R3 c  K  T2 s9 B( s
. `% V+ N& }5 ?
Defined in: uf_curve.h6 i0 t7 [# R5 L5 L1 r) q! y7 c

- |/ W3 k1 a# U
2 }1 @3 m6 b  U7 r0 GOverview
& C' o3 d( \4 x0 W+ |
7 l3 C5 r/ z7 X- _7 I& f3 x8 ICreate shadow outline for a given array of solids. Solids passed to this
. D$ ~! {! w+ y  ]2 Troutine must be on a selectable layer and visible. If created shadow curves
  J1 M7 M  J! hcan not form loops, please use UF_CURVE_create_shadow_curves instead to get / a0 @% d' K0 M9 y  _
shadow curves. * b! w, A! Y- O/ _5 @1 A
7 V- y5 i# e5 }9 Q# |/ ^1 W$ W( ^
4 Q' y" m  r" p& i+ b5 ?
[hide]# h* U% K- X9 T/ N8 I3 C2 }( u, Y

* ]/ m! f" }: r( H; P7 J5 H' r[mw_shl_code=csharp,true] void DoIt()
/ p- b1 @0 W6 |( |! J2 k% n; H    {
& {! I' E1 a5 p; D8 k        if (theSession.Parts.Display != theSession.Parts.Work)
: [: w) y% d8 h/ A8 r            theSession.Parts.SetWork(theSession.Parts.Display);
( H! C$ M' h0 `* L! b/ x( y( j' R  K9 ]. F9 u$ \6 E
( b* A* m1 C1 G. G! V# d$ ], |
        TaggedObject[] theBodies = null;+ v( v% [3 F% _5 `0 ?) r
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
, c2 q- [7 Y" a5 e# W4 w! y3 K        {+ ]8 T5 G9 U9 t( `8 q/ h$ ?* w
            Echo("Selected Bodies: " + theBodies.Length.ToString());
5 m9 O0 G5 U; Q2 d. l2 c/ S/ S            Tag[] theBodyTags = new Tag[theBodies.Length];* I$ k4 Y9 z* a  Z: z
            for (int ii = 0; ii < theBodies.Length; ii++)) a$ ?% S2 W7 v1 _) W8 \" L
                theBodyTags[ii] = theBodies[ii].Tag;
! U5 q+ T/ r- ]& x1 C& V% n; F& b5 t0 E
            List<Curve> theOutlineCurves = new List<Curve>();+ ~1 N" {2 B; m0 g- ?) V
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;' N9 O; o% u0 R* Z8 X* R2 B
            int loop_count;
# P6 A* G5 O1 v' Z- Q5 }2 f            int[] count_array;
% _. R' v( M% l  C+ \# l1 A            Tag[][] curve_array = null;
- e. g7 [( X" a3 `" x- T: w  m6 M            double[] tol = new double[2];
) B* i- l1 ~% [( n* b4 O- d! a" }- R8 ?1 b
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);/ U8 u) J' n& j. m+ c  V8 B6 q$ V+ s+ R
            theUFSession.Modl.AskAngleTolerance(out tol[1]);7 A" j) X- S3 Q7 G. F4 U

$ p6 Z3 N1 ?" G1 s& P, D            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
8 o, ^  Z  F$ H# o5 Q                workView.Tag, out loop_count, out count_array, out curve_array, tol);$ F/ ^0 `. h- F' I2 r/ S3 q

7 h" m' P; {9 J+ j: S; Y" G            Echo("Precise Outline Loops: " + loop_count.ToString());
) L6 ?5 g( a- X* S) I: I            for (int ii = 0; ii < loop_count; ii++)
" q/ ^: u( o& q( J                for (int jj = 0; jj < count_array[ii]; jj++)2 I0 W: Y# s+ A" `8 Z; Q
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));2 I! g8 E. P# M: X% L  w
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());/ K' N1 `" f* `' I# m
9 e6 v$ r3 k  b" ^! H- T: Q
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead " W9 a" l( S; ?# s, T: _
            int curve_count;
! @0 X# @5 n0 O            Tag[] outline_curves = null;3 F& V" W4 @( T: s, \, Q9 r* A, g
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,   A; g1 E- M5 R
                workView.Tag, out curve_count, out outline_curves);
( o3 m" d# `# _; I            Echo("Precise Outline Curves: " + curve_count.ToString());7 J8 k% @, C! x$ C2 |( C% u
            */
- Y, Y+ Q; r0 B8 {8 L. G        }
: ~) p4 K' A! a% D" X3 U% O! n/ {9 f7 G/ T& h6 C
    }[/mw_shl_code]
" o+ I8 b- u6 {3 E6 Q8 b" I[/hide]
' B2 r  f( T( f+ 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二次开发专题模块培训报名开始啦

    我知道了