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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
, T) m' I" K7 d0 n% p* Y$ i
! r5 M  ~# x0 Q7 @4 DUF_CURVE_create_shadow_outline (view source)
: z' F5 T- k# x6 G5 g/ O3 V : I  {& z* _) x( z
Defined in: uf_curve.h
1 W2 \- I2 |) n8 a8 _0 Y( w$ r ( l! h8 {6 I9 l
2 O3 ?0 l% S$ K% l
Overview) ]1 \# V. E9 m6 D( T

+ I9 O" J1 a) \9 t* R3 D  ]" Q. WCreate shadow outline for a given array of solids. Solids passed to this & D3 T/ r7 ]( P/ d
routine must be on a selectable layer and visible. If created shadow curves 5 f2 W; A- A0 M1 @: }
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
; _: ~9 V/ K. P3 _shadow curves.
, M. H! F! m& b4 K- W  }& w& |2 i/ B& y; C0 ^
/ a/ {& a/ ]! F  }% m
[hide]0 [; i# G$ q; B# X; q

. Y  ^& }$ h1 o8 F9 h9 X5 a9 c2 @, N0 U( |[mw_shl_code=csharp,true] void DoIt()
& ~1 i& `5 D" b    {
# ]2 Z) q8 N! H& E# q        if (theSession.Parts.Display != theSession.Parts.Work)( D: D- X# F4 s8 i. {0 [7 a
            theSession.Parts.SetWork(theSession.Parts.Display);
$ u5 g4 J- W+ Z+ b5 @2 |
" e! r. T$ m8 b
. G& R$ p% h# b        TaggedObject[] theBodies = null;
) H) ?$ V! M; N- A) l( q        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)! K1 [* V, ~& R$ b4 H; S; f
        {
5 Y% V# u5 w9 U9 i            Echo("Selected Bodies: " + theBodies.Length.ToString());" [+ {8 O% Y3 d  I3 j* m) \3 o/ \
            Tag[] theBodyTags = new Tag[theBodies.Length];9 v8 @3 A" U6 W0 }3 J
            for (int ii = 0; ii < theBodies.Length; ii++)
7 q0 F  G& `$ D3 ^0 m! q) x3 O; }                theBodyTags[ii] = theBodies[ii].Tag;/ c- B+ I/ ]  k8 {! S/ t0 a  z, Y: I
" \/ I: ]/ S/ `( Z3 y
            List<Curve> theOutlineCurves = new List<Curve>();
9 g# o* a* Y( |9 J( Z( U) B            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
# n# C, u1 K. y$ Z3 Q            int loop_count;" i4 ]5 S% C  M* X
            int[] count_array;
$ O2 E" i; _8 ]) F            Tag[][] curve_array = null;. C) e& ]2 g. z( h
            double[] tol = new double[2];
* s0 S- h# o  L! v: P+ ?! ?
  i# r5 _, a. Y: u$ [            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
" f" V/ ?% J, h  L) Z9 d( G) M$ T            theUFSession.Modl.AskAngleTolerance(out tol[1]);. s1 Y- t0 f( Q) A5 o
/ F6 Y) O0 S8 ~  e
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
0 M- r: ^0 y& N4 N4 q                workView.Tag, out loop_count, out count_array, out curve_array, tol);
  M4 B& ]9 O! ^' Y. x  e; o# F, O3 [3 _7 Y( L/ F% u
            Echo("Precise Outline Loops: " + loop_count.ToString());' e  c7 [) f! D6 N; w% u# E: D3 n
            for (int ii = 0; ii < loop_count; ii++)& t% v) b- [8 ]* t" _+ O8 h7 p6 w
                for (int jj = 0; jj < count_array[ii]; jj++)6 f" e; v$ V4 z+ S. o; W5 w$ b. K& l
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));& n8 r+ f" b# h6 F* j3 i& {! K
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
3 B0 V9 m# x5 a( ^0 U* _6 A8 ~4 t5 [+ E, {  F
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
, j- D/ V- H5 z4 t- o            int curve_count;9 a/ c5 ]5 n6 U
            Tag[] outline_curves = null;* ~% N4 {  h8 c7 Y- {! r
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
& @' Z, q4 D0 r5 h/ M                workView.Tag, out curve_count, out outline_curves);" q. S1 p! `2 p" l4 Q
            Echo("Precise Outline Curves: " + curve_count.ToString());
) U0 i7 a3 A1 B* g% C9 Z            */0 |3 Q- l( [- j+ }8 l) z0 D
        }
2 m4 j  A' E4 ^  T0 p  X$ A9 f' y# `7 k! e$ w/ i2 g. f! s
    }[/mw_shl_code]' l4 P5 j6 d! O$ Z7 g$ V: t7 I
[/hide]
  w8 d/ [! I3 |# S) T& M# r; 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二次开发专题模块培训报名开始啦

    我知道了