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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓; W. k  \1 c0 b/ Z7 L! r" _" r& J

/ ^+ f% {/ g% o$ F' N8 W, ~; Q1 DUF_CURVE_create_shadow_outline (view source); n. l' }0 s" ^
9 O4 ^( O0 }9 _9 g% p0 r* T, Z! t) [
Defined in: uf_curve.h
! o% N2 Q) g6 {8 Y4 S ; ?# e4 T( @' o$ M. |9 |
  x" j3 f+ U' j2 a
Overview
, B( n* {. G) J  x7 I0 M5 |  U4 K( H  n6 I* U4 e# M" Y. s. g4 J
Create shadow outline for a given array of solids. Solids passed to this
+ D/ r/ D8 ~; p7 M" l+ o5 troutine must be on a selectable layer and visible. If created shadow curves - G. }( I% L* d* `$ ]6 g$ j
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
" |( [  T( ^6 p# `4 I+ r/ [! b. K$ t8 Sshadow curves. # i  K6 q5 I+ l# H7 e6 s! _0 P

4 A8 ^' @3 X) e- f6 `) {( ?  h& I1 q8 D* m! V7 X* Z7 }- H% t
[hide]
1 Q8 n3 a% B' ]/ s' f1 E: W" X5 `  j: o3 G1 ~6 B4 V
[mw_shl_code=csharp,true] void DoIt()
7 ~1 [7 h5 d/ E! W4 t& o    {
/ I' \- x* u  c" N9 o6 N" ]        if (theSession.Parts.Display != theSession.Parts.Work)# j4 }" [+ \& g# R$ Z
            theSession.Parts.SetWork(theSession.Parts.Display);
0 f9 R# C4 r- u% {2 v1 n4 E) C3 d5 b: J. K& m
9 B+ Q- a) T; `3 O& g+ L( j0 I# J
        TaggedObject[] theBodies = null;; j7 E% q! R1 D: M
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)  K7 ]. R& m# p8 \
        {
3 ]* I8 R& \1 t% |& C8 D1 `            Echo("Selected Bodies: " + theBodies.Length.ToString());
$ u- v$ n+ o9 V" j( Q9 U& Q; Q            Tag[] theBodyTags = new Tag[theBodies.Length];
* u4 c; Z7 ]5 H            for (int ii = 0; ii < theBodies.Length; ii++)7 z& m8 y& d8 m! w; p/ F% }$ c6 h
                theBodyTags[ii] = theBodies[ii].Tag;
  Q* R( s9 |8 E) b: m5 y
. I4 g& L+ j* N9 ]* |% J            List<Curve> theOutlineCurves = new List<Curve>();
5 x+ S" q! s% Z9 e6 I            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
; |7 }* k( U- u3 x' O0 v+ F            int loop_count;9 C% r7 R$ l. e) X6 }/ u, l! t
            int[] count_array;
/ c' e4 e4 A( N4 I/ Z            Tag[][] curve_array = null;
3 K  l1 L7 E! R- Q: N* N  p            double[] tol = new double[2];
- B8 d9 r1 q# I1 j  U" ?- @
/ B& }" W7 L- _$ P3 @            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
6 `3 \9 h) W- ~3 h/ ?            theUFSession.Modl.AskAngleTolerance(out tol[1]);2 Q2 y' _: h; C" ?9 V, }
- B' ]3 x2 b9 u2 l! [/ M
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,+ X* T+ L) ]6 D' O
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
% M! V  l  [, d( G# E* m8 X* r' ?' C/ r
            Echo("Precise Outline Loops: " + loop_count.ToString());
4 m( y; F4 L1 a2 e4 \" Q9 _, j0 {( z            for (int ii = 0; ii < loop_count; ii++)
0 k$ p  a( g' C# {0 G. Q                for (int jj = 0; jj < count_array[ii]; jj++)$ Z7 ^' Q5 h" m: C
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
" u" J0 h/ y: [; X0 t7 Q            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
) X6 u' ^' U1 B  {: b3 B9 t% I* ^" g0 G6 q
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
1 c3 Z: R- J( d4 t            int curve_count;
- }6 [  f6 w" M1 w, o            Tag[] outline_curves = null;
8 z" w* ]- W$ }6 D& n( F            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags, 2 u; y( T! C0 e
                workView.Tag, out curve_count, out outline_curves);! ~, Z0 f5 ]% n
            Echo("Precise Outline Curves: " + curve_count.ToString());
% C' I& R9 [$ H' c4 V            */
3 J4 ^$ v, K/ Z% e* P1 l7 z        }
) W8 `  g; w3 R" f; B! b7 h3 L# U( B2 c6 C
    }[/mw_shl_code]9 d$ k  U' S3 h3 z3 u# F0 v
[/hide]/ X6 i4 v& \2 J( Q" e. q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了