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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓& c/ k' K# T5 n$ k

! a1 [/ e1 N: j; y/ K$ A/ Z7 g4 LUF_CURVE_create_shadow_outline (view source)5 o' l& f9 e7 W

& R3 F9 E6 k- e& L3 dDefined in: uf_curve.h- O9 q* I* B1 Q+ B- k0 p

- h9 u8 b3 \  h" h6 ~7 P) V/ x6 ]! U5 T  [
Overview+ d/ E+ j5 H, L8 H
5 K5 z7 F/ n& I) Y! k$ g# P% p
Create shadow outline for a given array of solids. Solids passed to this + h& {! Q% w9 k
routine must be on a selectable layer and visible. If created shadow curves
# k8 G) Y! h# _+ ucan not form loops, please use UF_CURVE_create_shadow_curves instead to get 9 T$ O3 Y4 s9 t; u, t* P
shadow curves.
* H- d! [& l5 O9 u# O4 |
" V+ ]( n, p) _, W! G7 S4 K/ b. r$ t& s# Z8 g7 F" C% B3 B5 }
[hide]/ {- ?4 B3 q4 _. a3 Z2 \

% g' P0 N# L& b% K. v+ [# h+ Q; g[mw_shl_code=csharp,true] void DoIt()
2 J6 b: t: k+ X) k    {  f# p. h) g4 q
        if (theSession.Parts.Display != theSession.Parts.Work)) P* J% {: ~6 d' D
            theSession.Parts.SetWork(theSession.Parts.Display);
; D8 h* W6 D+ n8 n, ], H) p$ i9 j7 e% \9 a7 [

7 y1 L1 ?* D8 K8 [1 z! z+ Y& R        TaggedObject[] theBodies = null;8 D/ @& f" L4 {- M/ Q5 @
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)7 p1 m: E$ P. v6 `! T/ E- \/ v
        {
! ~, N; Z4 w' P( K' ~$ |- q' v            Echo("Selected Bodies: " + theBodies.Length.ToString());
' M' ^+ ?* s- X/ s            Tag[] theBodyTags = new Tag[theBodies.Length];
3 a7 c6 ], M% m% i# S* Y            for (int ii = 0; ii < theBodies.Length; ii++)% i3 l/ Y9 n4 h& y' ]9 ~& g
                theBodyTags[ii] = theBodies[ii].Tag;) I4 G" N4 y1 ^5 `1 F

2 D8 k9 ?2 p  t, w; w6 E4 W/ |            List<Curve> theOutlineCurves = new List<Curve>();
: \# d5 w4 I2 m% _3 `9 |8 u            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;6 y( V+ e9 o+ P5 Y9 g" \: f
            int loop_count;
/ g6 O; U8 `, l4 H% R4 x. ^) `, D            int[] count_array;
! U  {8 N+ [. _( u: _0 z            Tag[][] curve_array = null;: B1 @0 R4 o/ [4 s8 F# u) i
            double[] tol = new double[2];
9 o* M" z. f2 d; X% E1 ?9 y/ [
3 w1 i- z4 u- x: J: J+ l: I5 m, _            theUFSession.Modl.AskDistanceTolerance(out tol[0]);2 I' y0 i6 A) o, F9 C% D
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
9 ~# y" C9 f- ]& i* `1 u1 m' ~" ~2 a5 s
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
4 c$ P3 x' K8 s$ [* Y                workView.Tag, out loop_count, out count_array, out curve_array, tol);7 @  u8 ~" W, h+ P" w+ F
+ T; @) f; N8 w: c! T3 I. s5 C/ N
            Echo("Precise Outline Loops: " + loop_count.ToString());: I4 x: m- B8 l/ z
            for (int ii = 0; ii < loop_count; ii++)
8 G& e. J3 N6 ^3 h; v                for (int jj = 0; jj < count_array[ii]; jj++)
  D* b/ h& H, t                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));3 W2 l3 I$ }3 `! \0 I
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());. `3 r$ F5 Y) Y

+ n* R" ^% e4 H: x8 Z            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead + g- g) A6 G+ Y  E! X
            int curve_count;
9 X/ S: v9 w( }            Tag[] outline_curves = null;
( J# i0 D# O/ b! g: }2 `. d: z5 H            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
3 m& b  A* V: @/ v+ P                workView.Tag, out curve_count, out outline_curves);
) x) N( M3 ~9 d0 `& K6 I            Echo("Precise Outline Curves: " + curve_count.ToString());5 s) J: s6 A5 w, `2 M- @2 h
            */
& D) {8 {6 j3 ^0 c        }# ^0 }( Y. A) [7 f1 ]4 [
  ^% c2 N# g- m% _8 J, b) p9 I
    }[/mw_shl_code]3 _" n0 {: V& Y: w4 x. J3 M
[/hide]4 q$ z) {1 B8 j
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了