|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
N8 @$ d& F0 B3 n& hNX二次开发源码分享:查找体中最大的面积5 s5 ~+ `3 [, t
通过MeasureFaces 下的area方法可以得到面的面积进行遍历查询0 ?& M5 P! Q2 a: h# D
7 W' Q$ |8 o! f" W$ q1 ?
2 u* y3 A: n6 I: I h- l+ x
- #include <NXOpen/Session.hxx>7 }( F0 U$ v2 W. \3 p. w1 {% Q
- #include <NXOpen/Part.hxx>
9 ~3 G, D0 e [ - #include <NXOpen/ParTCollection.hxx>! j1 x0 f6 T, w% c! F/ @
- #include <NXOpen/MeasureManager.hxx>
3 P# g }7 o1 O! ^ - #include <NXOpen/MeasureFaces.hxx>' o. ?! z9 v. X
- #include <NXOpen/NXObject.hxx>: p1 E7 s9 R4 v3 ^; F1 s
- #include <NXOpen/NXObjectManager.hxx>
+ d( y' R5 |+ s0 d - #include <NXOpen/Body.hxx>: X5 F* `; X( t8 ]1 T5 q
- #include <NXOpen/Face.hxx>
: Q# R- v. i5 I+ [ - #include <NXOpen/Unit.hxx>
3 V6 }( q- |2 }6 } - #include <NXOpen/UnitCollection.hxx>2 T" v( ?9 l+ w6 k4 R* Q
- using namespace NXOpen;
) b' x- ]2 u3 M+ k- {# q) x - / W: k. b \# c3 U3 Q
- static tag_t ask_largest_face_interop(tag_t body_tag)# N, I5 y+ I' L( a
- {
- v3 t. d% f' `0 q4 K. F; [7 y! u - Session *theSession = Session::GetSession();
& c+ T4 u4 H) @" @6 U2 a3 t
2 l6 a, m/ n5 G5 Y; j, _" @2 D- Part *workPart(theSession->Parts()->Work());. O. i" b9 h! W- k0 P$ [
0 ?' x8 W) V [4 S- Unit *area_units = workPart->UnitCollection()->GetBase("Area");9 K/ @4 L& F% F, B% I( V: z* y
- Unit *length_units = workPart->UnitCollection()->GetBase("Length");3 j/ L8 z! T5 f- C# P; G
0 `! G4 b! o6 A1 n, N) ~- Body *theBody = dynamic_cast<Body *>(NXObjectManager::Get(body_tag));
: D, k U* h; M' g - std::vector<Face *> theFaces = theBody->GetFaces();
9 o% @! P( p6 s ?" s- k2 q
9 Y2 R; n' @! {; G1 n# q7 D- k- double bigArea = 0;
: D$ d/ m' o/ x( p3 Z - Face *bigFace;
0 Y* g2 z, T+ F! }% j0 { - std::vector<IParameterizedSurface *> theFace(1);
5 E# `( t! a; e - for (int ii = 0; ii < theFaces.size(); ii++)$ r" e: x6 y# o4 [* V+ M4 }
- {
0 V+ K4 ]7 I4 U% @; I - theFace[0] = dynamic_cast<IParameterizedSurface *>(theFaces[ii]);
6 ]$ }5 r) P4 V' ^- @ - / W: s; R' F$ \" h' B4 u
- MeasureFaces *theMeasure = workPart->MeasureManager()->. ^! D$ n3 |0 d1 y% G8 h
- NewFaceProperties(area_units, length_units, 0.999, theFace);- @9 ]& I# H) c5 `" ]2 L+ h+ x
8 R5 k' j& b, |' Z" A/ r% v- if (theMeasure->Area() > bigArea)
: v9 M2 l0 l: M& V - {
1 s$ C. ^" R2 P4 u. C) l# ]$ X" j& j - bigArea = theMeasure->Area();
) X) S) Q* n0 Y1 d0 y9 K - bigFace = theFaces[ii];# z2 e" W! J& E$ V4 A2 p
- }# Z* u( o% r# i$ D6 q7 P7 x
- }
5 u/ \: w9 \# c. z V( M' }" j3 f - 9 u( H9 r. ^0 Z7 L7 E+ A# D
- return bigFace->Tag();' l6 K6 q3 E9 x9 \" k
- }* I8 L1 N- n. w
复制代码 , q5 u0 L7 t2 _) J; g& O6 A S' n
, p9 L* E, N" l6 ?; r* F% i* N$ n6 g3 f: e: h- M
|
|