PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82170
QQ
发表于 2019-1-17 10:56:35 | 显示全部楼层 |阅读模式

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

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

x
NX二次开发源码分享: 创建精确外轮廓
5 b6 d7 Q# ^9 G! f' [! `" C  i2 q/ b/ w
UF_CURVE_create_shadow_outline (view source)& N% E+ X( E( E9 i; k$ t

! T7 |, p3 d' X7 f1 p6 SDefined in: uf_curve.h
. d% g- Q* n- C* O1 P1 Z
( S+ _$ G; a) z% u# d% R( h& k
1 P2 j+ x0 |% O5 |Overview
7 v# h- B7 L0 {$ h* A& J. S7 s& p' n) X* T3 t7 c1 u) \5 t
Create shadow outline for a given array of solids. Solids passed to this 9 }4 G3 c% y; v, e* I6 z
routine must be on a selectable layer and visible. If created shadow curves   Z; e$ o; w6 c" ^
can not form loops, please use UF_CURVE_create_shadow_curves instead to get
5 j+ x. p% @( I  E7 A" ishadow curves.
$ t8 h- V! M" N4 |1 d3 j8 X6 Y3 H
6 s6 t7 P+ o9 S3 L3 [* m* Z+ ~; \) B! ]7 D( N7 D
[hide]
1 Y7 W9 C9 B9 b6 f! c7 t
$ x) o: }* Y% k$ j$ U[mw_shl_code=csharp,true] void DoIt()% s, ^5 g- A: j+ K' y' G& w
    {
  h9 i# n1 d, h8 e        if (theSession.Parts.Display != theSession.Parts.Work)
* Q( D0 A% \/ J. W            theSession.Parts.SetWork(theSession.Parts.Display);( N  P2 K' v6 }7 J

6 T$ j5 U' r" b3 {& J0 t2 l+ `
& ^5 q: k3 D# Y        TaggedObject[] theBodies = null;
# N4 S5 d. v6 O. B* ~8 R" K        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)7 W9 m3 h8 h: r8 z) ], d  E
        {- J7 D- J, d* l3 N# c' a& k
            Echo("Selected Bodies: " + theBodies.Length.ToString());
: N' d( q. o' W8 |            Tag[] theBodyTags = new Tag[theBodies.Length];
! Y+ r* k5 z  Q            for (int ii = 0; ii < theBodies.Length; ii++)# ~, \- Q: @+ [* S1 Y% ?
                theBodyTags[ii] = theBodies[ii].Tag;2 R2 H& _3 a1 d; \+ s

5 C  u. z- L3 @  [! K            List<Curve> theOutlineCurves = new List<Curve>();% o! T' ~. I9 d8 i( b4 P
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;7 o" _& ]' [/ y1 Q4 r) I* f( \
            int loop_count;8 ^. j4 O# y: \" H
            int[] count_array;. E: o( |/ s8 q' J) Q" y
            Tag[][] curve_array = null;4 l/ w6 s8 t& y0 r6 b( k9 @, w
            double[] tol = new double[2];9 C) t6 f4 @) `+ G: K

0 p& [0 {+ C  Y  i& `+ c2 Q            theUFSession.Modl.AskDistanceTolerance(out tol[0]);+ W8 H: [# G* p$ N
            theUFSession.Modl.AskAngleTolerance(out tol[1]);1 `# |. z# P$ N# u) }. |5 y
# P+ O7 x! \1 F; m
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
. v6 F0 e- K7 x8 I6 j: b, p2 }$ c                workView.Tag, out loop_count, out count_array, out curve_array, tol);
7 U9 f6 l4 q, L6 r- u8 P" b0 z. s: d& u1 T" H/ p1 ~' L
            Echo("Precise Outline Loops: " + loop_count.ToString());# w. v4 C7 N5 z6 S) {6 J6 g
            for (int ii = 0; ii < loop_count; ii++)
0 M; B- F  I* a6 Z. Z1 w' z                for (int jj = 0; jj < count_array[ii]; jj++)
4 p. k5 n' g5 ~: _! Z/ r9 w                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));; T2 |4 {  t2 ?0 ?$ b
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());1 g/ Q/ K4 U$ U6 P  Q5 [0 c$ E

+ q3 u, c3 F7 N7 F/ ?. s  k            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
8 b, H- X% B3 H, X            int curve_count;
* L1 p* m. j: G, N  y            Tag[] outline_curves = null;
* f, U5 L9 k' [0 b5 [' e            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
- Y, t4 Z5 G( V0 \, e$ r2 m                workView.Tag, out curve_count, out outline_curves);
# q/ b. h* K% F+ R, j# h- {$ D% W            Echo("Precise Outline Curves: " + curve_count.ToString());8 K/ ~# ]0 {; I
            */
! I3 d0 o3 j3 o! N( V; v/ l5 L        }
6 L- a* F/ L. p9 K* w  p! O  L7 U2 a+ B2 H+ ^& A' ^7 ?+ D2 S
    }[/mw_shl_code]6 T; u: H* J$ Y1 r
[/hide]" B- m! _) s! q! 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二次开发专题模块培训报名开始啦

    我知道了