PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
3 v+ r) N  q  H) f* D* S/ A2 B' S7 X/ ?% L5 o2 R
UF_CURVE_create_shadow_outline (view source)
1 B  Z# e5 A' i& h( c . h/ l4 }; T1 S; }5 T
Defined in: uf_curve.h
% o; ^4 \- E! x7 W: I - |$ G) t4 @9 `
9 l5 t8 J' y- ?* R( }3 m. {
Overview
9 b" Z- Y) B6 J; E& ~! d, x4 t6 C! o2 S3 G& n
Create shadow outline for a given array of solids. Solids passed to this
" j& G5 Z/ U: a8 E  troutine must be on a selectable layer and visible. If created shadow curves
  |& a" r# n/ l4 N. c7 T% N- L6 |# Ecan not form loops, please use UF_CURVE_create_shadow_curves instead to get
7 h# c+ W; |, z  i) r) i) Dshadow curves.
& N+ h! _5 j( K) r' V2 c' ~8 K0 t( V' r3 k1 h2 D

) ]' O) `2 H. X: X6 x9 v[hide]: d% q- v" j* _! P, c: ]2 _( Y' i1 a9 [0 Y

9 q9 o" Z% v3 z" ]8 }, M6 v[mw_shl_code=csharp,true] void DoIt()0 `/ B3 A$ E$ j- W% b. `  W9 E; S4 v/ |% U
    {
* u5 z; S: g* F9 B1 T3 `, Q        if (theSession.Parts.Display != theSession.Parts.Work)3 c, B7 U% Q% w
            theSession.Parts.SetWork(theSession.Parts.Display);
; {4 V2 ]9 Z/ @* |  t2 Z0 a- M* G+ D: j8 [( l7 V" }$ [' U

6 T1 M( G( ~2 D4 V! Z        TaggedObject[] theBodies = null;/ H* D; w4 W# p0 \& n
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
4 o3 d  S8 F* O        {
9 D3 x# \& s5 F4 d6 ?            Echo("Selected Bodies: " + theBodies.Length.ToString());9 h; I5 S0 D0 Y' X. S! z# i! X
            Tag[] theBodyTags = new Tag[theBodies.Length];6 z9 W7 F! L7 M  [) d$ w' G2 L( s
            for (int ii = 0; ii < theBodies.Length; ii++)
6 S  ^1 e: Q% p' L) A; w& C4 i  C5 _                theBodyTags[ii] = theBodies[ii].Tag;0 N  R9 r/ s8 f+ p/ g

$ @! d( ?0 Z" N6 H& ^            List<Curve> theOutlineCurves = new List<Curve>();+ l, J# u+ f' a: i' ^
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
4 E2 x% a% E# G' g. r/ l+ h* L# t            int loop_count;
8 E4 w$ ^9 k; O! o" U& D            int[] count_array;. ]& c+ b4 b3 G& A4 y$ U
            Tag[][] curve_array = null;
0 _- j2 Z$ G9 u! y4 Z            double[] tol = new double[2];7 L* {$ c* V0 \! G6 A8 n* D( e; F

0 r, P" C7 _1 G2 l8 ^            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
% B- P& ^4 p. E$ q3 X- H& P            theUFSession.Modl.AskAngleTolerance(out tol[1]);+ _( b# ]5 i9 b$ q4 ]3 i2 O

/ J; l5 \/ W- ?" @- C- G            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,, t' N2 c, L$ @8 v' t, e; k
                workView.Tag, out loop_count, out count_array, out curve_array, tol);5 y$ A. G, ]) P% I+ ~9 A
3 C( r% s; L# P# p! j
            Echo("Precise Outline Loops: " + loop_count.ToString());
; I- B. i  K5 n" Y$ ~5 M3 h, J) O            for (int ii = 0; ii < loop_count; ii++)" K9 Y7 o2 D4 K9 S
                for (int jj = 0; jj < count_array[ii]; jj++)
( J$ y: A' H0 y! u  h                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
0 t2 e, t3 A5 |2 \) _6 E            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
; i4 I9 ^9 l/ K; `
/ ?- T* a; F1 p            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
+ @- E- p( Z" [) D/ A: Y! V$ p            int curve_count;
% r: n5 U& ~* G, ^" y- N            Tag[] outline_curves = null;
2 H$ D6 u9 F; B3 g% Q3 Y5 B2 ]            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
% B" N0 ~6 D+ a8 {. [; P4 D                workView.Tag, out curve_count, out outline_curves);
) _& `; T. g- a! `* N3 }            Echo("Precise Outline Curves: " + curve_count.ToString());: I& w. \# z1 C2 S, n) z8 [# c
            */1 @& h7 q0 Y  e$ K; Y4 O* C
        }" L0 ~( m( l% }+ B% D
- X: G- i; J# i5 g- t
    }[/mw_shl_code]! d$ N7 o1 K! \- ~
[/hide]
0 J2 m# B8 ?* ~, 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二次开发专题模块培训报名开始啦

    我知道了