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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓: j0 P' J$ I) B0 l

( R$ V. h* y. BUF_CURVE_create_shadow_outline (view source)
3 U  V- t' ^& C9 s7 J9 L0 u) P 8 K8 A. F6 j2 G7 j' [' q( ?
Defined in: uf_curve.h4 W3 {" U5 R$ t" j
- o  t6 j  p) D: q

5 t7 T3 B, |% G. [0 V# wOverview
+ x: A; b2 Q9 d. b! R# R
" i9 d! X5 Q( U: @; t8 e7 yCreate shadow outline for a given array of solids. Solids passed to this ' q7 u1 T7 a# f- R
routine must be on a selectable layer and visible. If created shadow curves & G7 t: @) n1 V% h# |
can not form loops, please use UF_CURVE_create_shadow_curves instead to get % r0 l. ~3 Z2 c
shadow curves.
' X* d3 }: e" L: O% n
. E5 Q# g2 g, `( }1 N  G& ~( F6 @7 A2 V* r2 @4 y5 f6 P6 T0 a  V
[hide]
4 x5 @6 N: v# K
. c# M  e3 S! L8 @0 F9 G[mw_shl_code=csharp,true] void DoIt()+ [' P- }  A6 J$ o! C% ~8 e
    {5 P" H1 K9 a7 E6 H1 j3 \
        if (theSession.Parts.Display != theSession.Parts.Work)' Q5 S% T3 [& Y/ D( Q
            theSession.Parts.SetWork(theSession.Parts.Display);$ t% V, z) P; `! O7 T6 }2 _; R

* t$ p, Q4 }9 o% W0 U  `: _/ M3 p4 ^* m
        TaggedObject[] theBodies = null;& g( N7 O$ {! m# K2 l
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)1 L; n6 h3 Q1 y3 i0 U8 L" ]
        {
! F) A2 [& c! i! u6 s$ Q            Echo("Selected Bodies: " + theBodies.Length.ToString());
. p: v6 a; z; X6 w$ C" |" [: a            Tag[] theBodyTags = new Tag[theBodies.Length];
4 s  A; H) T3 y' g            for (int ii = 0; ii < theBodies.Length; ii++)8 U# Z, `8 ~$ B
                theBodyTags[ii] = theBodies[ii].Tag;
6 v8 h" |( r: G: v5 ~' u; F4 |/ T
; B  F6 P5 e) Z$ {; ~            List<Curve> theOutlineCurves = new List<Curve>();' q3 n+ I/ I8 j. L( ~( s! }5 v
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;: k/ E3 a7 H  V! y% D+ d2 \! l
            int loop_count;  m) h& S4 Z1 h5 W4 c
            int[] count_array;
+ }% c5 B, A3 `# h  |- ]8 |            Tag[][] curve_array = null;
# B" @1 A! J9 X0 f            double[] tol = new double[2];  A" I5 A$ G0 `5 O# @6 l" v

$ S, A) e# H; b1 ]3 L            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
! F5 _' J9 T) f5 z. l            theUFSession.Modl.AskAngleTolerance(out tol[1]);0 C4 i/ z  |* X- J1 r4 p
* I) w* S' o* g7 X: O% T
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
4 p# y, r8 h, a) O7 ~0 z                workView.Tag, out loop_count, out count_array, out curve_array, tol);
; Z; a; o  Y, B- m* t) o" }% ~& C# l% \5 q: `6 r- t: \  o( }. W
            Echo("Precise Outline Loops: " + loop_count.ToString());; p3 D7 C! K' x' O+ C* S8 Q1 s9 X
            for (int ii = 0; ii < loop_count; ii++)' J$ I1 E0 t7 W
                for (int jj = 0; jj < count_array[ii]; jj++)7 a# ~9 f( l6 `
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
$ T( x" C1 g) g% z            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());4 C9 Y8 x9 S$ R) |
& }. t+ P! c. [4 R6 K3 D0 L
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
* U5 O1 y6 z/ a. E( B9 B            int curve_count;4 O; e  X  t+ X6 @7 C
            Tag[] outline_curves = null;8 x! A4 Q* m3 U: H. b
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
* B3 h+ I- h4 u2 q                workView.Tag, out curve_count, out outline_curves);
1 z. J$ o( z- r            Echo("Precise Outline Curves: " + curve_count.ToString());- A* @2 Y" v- g/ i
            */; X6 o1 y8 _  I7 F, L; i! P
        }$ H) j: k: O2 @% C7 G6 A* l2 L
3 W: ~: \* Q1 V0 g+ g. ?
    }[/mw_shl_code]
+ N1 O5 n2 n3 P+ s/ x( I0 o- R2 q5 [[/hide]: b8 a' ~4 a+ X9 A! \( r  ^
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了