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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓
7 `# Y: F. ?) M2 I, a! E
; M2 F# ^) L2 G4 P; q; YUF_CURVE_create_shadow_outline (view source)% b2 C* `& V- B+ ?9 h' `2 O; s

7 ^' _6 {  O# [Defined in: uf_curve.h7 g# T) `& w2 o! Z

+ O1 _  L# g7 F% O) W. Q) H/ X8 M$ }2 J: B# ~2 t7 m$ c& J( C4 p
Overview* Y0 x( O' ~2 s6 j/ w. b2 N% {

% M  s( P# a1 W0 g) O" mCreate shadow outline for a given array of solids. Solids passed to this / X) B# N7 A( `9 B; H+ @
routine must be on a selectable layer and visible. If created shadow curves & c4 m3 B5 Y, |# ~) S" t
can not form loops, please use UF_CURVE_create_shadow_curves instead to get ( g6 f! Y' F) D7 Q/ R- ^: _
shadow curves. / N9 f7 I# S! T; ?* a/ k
* `3 ~* Z$ X3 Q

( R% [% B5 a+ Z7 A+ h[hide]
  S0 L" u( {% F/ X
/ b/ c- y* O! L1 f[mw_shl_code=csharp,true] void DoIt()
( w8 ^, v  U' z6 h' L% ^    {
7 b' U6 [( Z  u& y        if (theSession.Parts.Display != theSession.Parts.Work)6 Q# T  F5 h" {6 g: t* Z1 M
            theSession.Parts.SetWork(theSession.Parts.Display);
5 C, a- s4 o7 h+ c5 n$ T( B/ ~2 D, ?& J" j

, D& T% g8 M! Y        TaggedObject[] theBodies = null;: n# h9 j1 J( D3 B1 Y
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)8 o0 d) A1 E$ a* n( h4 _( I
        {) o" Q; s2 F+ r5 M( Z( [
            Echo("Selected Bodies: " + theBodies.Length.ToString());
, A: [/ O0 Y& S+ o4 T: b1 U; _' j            Tag[] theBodyTags = new Tag[theBodies.Length];9 s( C& J0 N) C  y2 u& [2 A. q
            for (int ii = 0; ii < theBodies.Length; ii++)
  f6 ^+ r0 m! }, q                theBodyTags[ii] = theBodies[ii].Tag;
$ z! R' R0 g# K. c0 T
0 {' A& n8 G( r9 [1 \: r            List<Curve> theOutlineCurves = new List<Curve>();% @! I& Y4 S3 K% m
            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;7 L; [1 O4 C" ?( `
            int loop_count;1 t0 z/ B$ N, R2 i, Z/ d
            int[] count_array;
$ j: O% u; f0 [9 j( s6 p6 @# G            Tag[][] curve_array = null;
/ F" G$ @4 e: m- Y            double[] tol = new double[2];
: I! ?# l; @% C! }1 B
3 B. s6 o% V8 o. @' E& c            theUFSession.Modl.AskDistanceTolerance(out tol[0]);+ T" g& r; @0 s
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
) F4 z# o9 D! g4 T5 N. s- {% i& u6 P* Q' s1 Z
            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,) I2 H3 n2 k! F% O) ?$ {" Z
                workView.Tag, out loop_count, out count_array, out curve_array, tol);
: e+ B" {4 S- P; y. b( B# R: k4 l( ^- H+ j+ F! R* X
            Echo("Precise Outline Loops: " + loop_count.ToString());+ F/ ^7 X, |; K) d: P
            for (int ii = 0; ii < loop_count; ii++): G# ?% [- V, w8 V2 l: H  d) t
                for (int jj = 0; jj < count_array[ii]; jj++)6 P% s3 H, k3 m4 q- y  A
                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));. I% b! T' m) {
            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());
5 F4 O( j' S$ O( F, z9 }: d8 l0 v
            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead 3 {. B6 i  ^9 r
            int curve_count;
1 V) a) q0 l. n+ B$ ]/ Y% v            Tag[] outline_curves = null;& Y* p' L2 m: D; N' X8 d. D
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
0 C7 I; \4 q' l( U9 u! o                workView.Tag, out curve_count, out outline_curves);9 {" G  B/ h! @/ {- g
            Echo("Precise Outline Curves: " + curve_count.ToString());; W& i, [/ u3 n4 h) P2 r- a: \
            */
% R) o, Q: K; M5 E        }
+ g* i4 _9 U' L" V! _9 I& a
# w  D* T" K$ c2 \3 x    }[/mw_shl_code]
8 c5 z; O- v8 K( d* C+ n3 Z[/hide]
  ]* y$ `3 D0 C& {- ^
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了