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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓) W. h! a3 m) y2 w3 d

7 _9 G6 w; o; O% s+ j' C' aUF_CURVE_create_shadow_outline (view source)
, C* w% s  }4 Y& x 6 l" f: J) Y% C6 y# {/ z' |' [
Defined in: uf_curve.h
# i( v: t# ?7 }0 ~ ! U- g# {+ E6 g; o3 x
1 `, B$ ^5 ^5 I- w; g# R
Overview1 ]1 Z2 g- r( Q0 y6 M1 f
1 L) D/ X) L0 R# G1 @' I, S" V
Create shadow outline for a given array of solids. Solids passed to this - m& X9 h  g- R, M+ ?' L; C' \8 V
routine must be on a selectable layer and visible. If created shadow curves
2 Z5 d8 t+ [7 Fcan not form loops, please use UF_CURVE_create_shadow_curves instead to get
$ t9 e2 W8 J+ d- i+ _8 g  bshadow curves. 9 P. a: b6 ^0 p+ d) r

6 J( W3 D1 g1 `6 j, P6 v
3 t; b. e, x- p[hide]6 e. Q4 W% [; Z2 k  n
+ ^% \# s  H3 `& y) L5 O
[mw_shl_code=csharp,true] void DoIt(): T# k# p6 I# @3 e8 z4 A7 r
    {
! @% ^5 r( V2 L( b& @+ B        if (theSession.Parts.Display != theSession.Parts.Work)
4 W- P9 u+ m5 c0 q, G* M2 O            theSession.Parts.SetWork(theSession.Parts.Display);
( X& Y% t- _( B7 s+ V/ q. f' e; V8 Q

, W$ D6 e1 D4 C* i9 d3 c4 }. \, ~        TaggedObject[] theBodies = null;
* f/ s4 z  r) c) F* N        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
1 l3 G8 w7 @0 P* _        {
& b* Z. i+ Z: C1 o1 u            Echo("Selected Bodies: " + theBodies.Length.ToString());* u& \$ F8 O$ d4 l7 p- z
            Tag[] theBodyTags = new Tag[theBodies.Length];3 Z8 A- |7 `2 z# c  k
            for (int ii = 0; ii < theBodies.Length; ii++)
2 a9 R2 K7 y1 A, ?- _! v- X. Y                theBodyTags[ii] = theBodies[ii].Tag;
2 b7 d* T6 U+ s4 `4 J& H3 a
: Q- y; m! N  c. ?2 L            List<Curve> theOutlineCurves = new List<Curve>();
7 ~5 I4 W' l6 P! L/ p& j! ?            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;, n+ X, g( D# v# v& E; r" l' ]
            int loop_count;
. r9 z: b2 B! }+ g. n0 L" i% ^            int[] count_array;( \7 r4 |2 R/ `! m. o
            Tag[][] curve_array = null;2 M8 w; N3 U: E8 w* N* h* @
            double[] tol = new double[2];! g8 K( g0 O  [

% ^1 O* A" }6 L$ q. l8 |            theUFSession.Modl.AskDistanceTolerance(out tol[0]);, c1 T, ]0 S; P+ E' t4 W, F1 M( X$ R
            theUFSession.Modl.AskAngleTolerance(out tol[1]);' k1 t$ h, s* K: ~$ g

' L2 Y. \! W: a- z6 P* {            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,/ ~0 j# e/ y' k1 a! [0 H8 T
                workView.Tag, out loop_count, out count_array, out curve_array, tol);4 _# _9 B0 U* {& f

9 S' b+ s0 T5 b/ y            Echo("Precise Outline Loops: " + loop_count.ToString());
- H* e3 O9 g2 O            for (int ii = 0; ii < loop_count; ii++)
2 w7 ]" ?0 x! j1 K& h- r! U8 y                for (int jj = 0; jj < count_array[ii]; jj++)) H1 f7 M( M0 l
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));& x7 d% o' {" Y! B" L. e* ]$ `
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());2 s; L+ h2 w  a( ?+ W# C

0 N. M- p% E5 v            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 6 b4 {; z* B" |! D7 J
            int curve_count;0 e: H& u! {  m2 p6 t
            Tag[] outline_curves = null;; G* x: q* Q; {  @5 k
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
( j/ N9 U- T1 \  E+ g                workView.Tag, out curve_count, out outline_curves);
+ N  ?7 r, \% k8 J7 m9 A            Echo("Precise Outline Curves: " + curve_count.ToString());
0 w9 O0 `0 z) Q+ T            */; m0 u, R4 n% N( E
        }# O1 T+ d6 h& }5 k- y: j

3 O  P) K6 k, [4 l- `    }[/mw_shl_code]
1 h; B1 `# W9 @2 {9 v- g" j$ T1 Z[/hide]; \# _) t  U8 t: O/ b
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了