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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓7 u' e; j: A! U- y! M% c) [0 m

5 @- \, p. `: xUF_CURVE_create_shadow_outline (view source)
) Q: \% D" q( D
7 ^. z+ W) r+ h; t7 \8 jDefined in: uf_curve.h
1 J( U" ^+ n8 e/ E$ i/ N& ?; i
- `' a4 M# [- N3 l3 u7 ]
! ~4 a3 I* S: z+ h/ k: C; N# iOverview
/ R) P7 Q5 ~7 n( u
+ ^9 d+ M- |+ Z. W! _) G: D' [+ _Create shadow outline for a given array of solids. Solids passed to this 4 d- Y4 N7 [* ?/ r- R7 h6 x
routine must be on a selectable layer and visible. If created shadow curves
3 |6 e  l) x3 v4 O" {/ r" R4 ucan not form loops, please use UF_CURVE_create_shadow_curves instead to get 3 z  a$ k: S5 t" G% @7 E# C' g
shadow curves.
/ A2 j3 }7 ?$ o3 ^0 c0 r
7 l0 N* R+ w# V/ n6 N/ d7 V0 w! ]( `
: M# G* L3 A/ N. R9 _[hide]
6 U5 e2 A5 |% s5 Y5 l4 \, B( z4 G' y$ Q. o) C$ c7 c, t
[mw_shl_code=csharp,true] void DoIt()
) j) u0 g4 ]" M4 u1 f    {/ m+ @5 I- t: R3 X  E
        if (theSession.Parts.Display != theSession.Parts.Work)
0 E2 `$ F+ [( l0 c1 k            theSession.Parts.SetWork(theSession.Parts.Display);+ b; Q/ c" |. v0 U& P

7 o$ E# O' m: E5 @9 n1 U& a1 O/ w4 j+ \; }8 W) d
        TaggedObject[] theBodies = null;- ?( g) R6 O/ o8 r
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)
: W; u/ L- B, j6 s+ B& I% S        {
% S4 K3 I  ^  j: o" R, \            Echo("Selected Bodies: " + theBodies.Length.ToString());
, Y8 H6 i0 z7 O/ t' D5 a. h/ k            Tag[] theBodyTags = new Tag[theBodies.Length];7 B) G0 L2 y6 V& ]8 ^& Q
            for (int ii = 0; ii < theBodies.Length; ii++)
+ a+ m# o) ?) `0 {8 p3 w% U                theBodyTags[ii] = theBodies[ii].Tag;
, `# {2 D; e& ^  H8 h; a* |, b$ S# i4 A  F, d4 c
            List<Curve> theOutlineCurves = new List<Curve>();/ d0 G- Q* h' N8 g3 [
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;# i* o6 b; A* ]
            int loop_count;
, F& D4 n9 W8 h$ t' S            int[] count_array;3 L4 [6 ^( b7 i1 w" |' s
            Tag[][] curve_array = null;" m& m" ]' @7 J& U0 `- r
            double[] tol = new double[2];2 H/ z! d3 Q/ x0 r- b

; z3 S3 |8 u4 H; D# P* u            theUFSession.Modl.AskDistanceTolerance(out tol[0]);
3 H% e) u- k5 R  X* `            theUFSession.Modl.AskAngleTolerance(out tol[1]);
3 u2 T7 O  S# p" e+ v) d0 s* a8 Z8 C* ~+ Q: Q9 O& t$ @  p
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,
' g5 ]# G' b2 [2 s& S3 T5 E                workView.Tag, out loop_count, out count_array, out curve_array, tol);
1 `, z" s$ u% U4 [6 ~. ?
  w# C% W3 r+ J, |- V' R' _# K            Echo("Precise Outline Loops: " + loop_count.ToString());5 \- A. p+ z( `+ X+ Q* ]
            for (int ii = 0; ii < loop_count; ii++)
  N7 m  V7 M4 ]7 G0 e" [                for (int jj = 0; jj < count_array[ii]; jj++)( i4 }. U. V9 g/ c/ ]6 Y. _, x
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));, C% U1 a3 {% m! _2 Z
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());5 ~; c1 [+ \4 g6 e4 C% y

1 b3 {& {$ Z8 o" ?3 S            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
6 a$ h5 t1 A, Z- B            int curve_count;
( F. S3 d. W* Y" J1 u4 }& o% a# [            Tag[] outline_curves = null;; t8 G" s" G: h# I& h/ U- }0 P& V7 N
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
. l- T  r5 o- e5 D8 q+ z                workView.Tag, out curve_count, out outline_curves);' @; O" t% G0 w
            Echo("Precise Outline Curves: " + curve_count.ToString());' A+ N1 ^, i. b3 t; F
            */1 L% T5 E# c: h8 \9 Q
        }5 D2 p8 @% M8 w# f
$ g3 }: m+ n( N$ E/ m6 B- k3 z
    }[/mw_shl_code]' G$ G; F/ g7 f, w$ o/ L
[/hide]
' ?- H5 v* X( e4 O4 K% F
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了