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

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

[复制链接]

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

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

admin 楼主

2019-1-17 10:56:35

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

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

x
NX二次开发源码分享: 创建精确外轮廓0 S0 q3 B6 e1 R8 X$ N

: l, P* Q3 m: B+ OUF_CURVE_create_shadow_outline (view source)9 p/ T' Y/ P+ a# \
; _5 h: a/ i% @$ A
Defined in: uf_curve.h, l- V" a" l* u4 ?' G) T. o! y" j0 Q, {

8 C' _5 f+ k. ^- M
: p5 o5 w& @; r, C7 l3 ^" q. IOverview
: l9 N# U. @8 y$ S! N. m0 R2 d* A& s) R1 i
Create shadow outline for a given array of solids. Solids passed to this / F, C- I) Z* |; Q
routine must be on a selectable layer and visible. If created shadow curves . M+ G6 C( D9 I% K4 Q
can not form loops, please use UF_CURVE_create_shadow_curves instead to get * G( y( }; d- z( m; n
shadow curves. # D; g/ e$ B) t& u9 Q# E. X/ ^

8 K" |9 K) c3 c+ |
* {7 C* F8 p- U! t4 b. [[hide]9 z$ M$ l& ]4 `! ^/ @! n' e5 d
+ o" j- I4 l$ ?/ E
[mw_shl_code=csharp,true] void DoIt()
, c- U- K* l3 `    {9 ?1 f: h) S+ ?+ z' H2 {8 t5 m/ q
        if (theSession.Parts.Display != theSession.Parts.Work)" Z8 i( ]7 N  |
            theSession.Parts.SetWork(theSession.Parts.Display);/ e9 W2 d3 E. j( {2 w' e% s, S
* H5 X- K5 T& G6 E5 p5 O5 b$ x+ J

- z% w( }1 U! h& F2 D% o        TaggedObject[] theBodies = null;$ T3 ~: f6 [8 c: O" i
        if (SelectBodies("Select Bodies", ref theBodies) == Selection.Response.Ok)3 M0 ?: @' h$ B. q/ ]" R% I  @( Z4 O
        {
2 ]: z- L' R3 g, O            Echo("Selected Bodies: " + theBodies.Length.ToString());* ?8 w7 @6 y6 T$ J
            Tag[] theBodyTags = new Tag[theBodies.Length];) @/ l4 o. O* Y* a: h7 \, Y2 P
            for (int ii = 0; ii < theBodies.Length; ii++)
: ]+ d/ l2 {2 P3 p7 c                theBodyTags[ii] = theBodies[ii].Tag;, Y7 J% j) o( Y" C. \. W" [  B

( e: ?! v' ]' r9 `7 ~1 b            List<Curve> theOutlineCurves = new List<Curve>();
8 V: A8 M9 F' s: X* T* Q& n            ModelingView workView = theSession.Parts.Work.ModelingViews.WorkView;
0 I. v  r) `' h, E8 T: }            int loop_count;
  t- l) a; _0 ?: F8 F- ~; s; H! [            int[] count_array;9 D% u& |# C& R4 {, {
            Tag[][] curve_array = null;
0 e) R; h1 ]2 B0 T5 ]            double[] tol = new double[2];
% S/ w/ W; N- i# m: k& ~( u2 ^. V9 y* n) L) p
            theUFSession.Modl.AskDistanceTolerance(out tol[0]);& _8 p0 A! {$ u9 n
            theUFSession.Modl.AskAngleTolerance(out tol[1]);
! |7 W2 E; |* w
+ r) p. u% s3 Q            theUFSession.Curve.CreatePreciseOutline(theBodyTags.Length, theBodyTags,3 {1 r1 s' }; i* k, [5 ]* D
                workView.Tag, out loop_count, out count_array, out curve_array, tol);) ~* K+ b. \# j1 B8 M) v
0 A! g4 H: n( \0 N# h
            Echo("Precise Outline Loops: " + loop_count.ToString());
; ^  ~# W" h0 H9 W( Q            for (int ii = 0; ii < loop_count; ii++)/ r0 u- P  A- }5 q
                for (int jj = 0; jj < count_array[ii]; jj++)
# p3 K8 d9 k" @6 E                    theOutlineCurves.Add((Curve)NXOpen.Utilities.NXObjectManager.Get(curve_array[ii][jj]));
' q+ K6 @# S+ M* ^            Echo("Precise Outline Curves: " + theOutlineCurves.Count.ToString());" O  l( i5 r1 w

6 y- q. }" Z- h$ W( ?; p            /* If created outline curves can not form loops, use UF_CURVE_create_precise_outline_curves instead
8 V+ C+ y8 j7 c* O0 z. ^* w            int curve_count;
0 p) [" U  S5 r- b3 g            Tag[] outline_curves = null;" _/ y. j3 t" b9 M4 N
            theUFSession.Curve.CreatePreciseOutlineCurves(theBodyTags.Length, theBodyTags,
9 h% ^- q$ p7 F  J                workView.Tag, out curve_count, out outline_curves);9 z6 z# b9 C: Z# F, r% `$ m% V
            Echo("Precise Outline Curves: " + curve_count.ToString());
8 \' U; x7 l3 |            */7 ]' F5 u( M$ M5 n+ ~" I5 d
        }+ s" K+ G5 E+ S7 r% M' b/ ~

, p+ s. ]1 ^$ {  r4 ?    }[/mw_shl_code]6 [! Q' q; Z5 y6 y  s. P8 o8 y+ d0 x
[/hide]2 Q; X. @; V' }% M
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了