|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
I8 F# z7 E/ ONX二次开发源码分享:查找体中最大的面积* ?' }) W* n; \1 T
通过MeasureFaces 下的area方法可以得到面的面积进行遍历查询" L+ ^8 Z4 O, n4 ?
1 [& g6 d, X+ q1 V1 C
/ `* t- o) h: j* O0 y- #include <NXOpen/Session.hxx>( x& i4 h$ F0 K7 M2 B
- #include <NXOpen/Part.hxx>. j( R c; M; C9 `4 L. U: u# f# S
- #include <NXOpen/ParTCollection.hxx>3 U( A2 G, D4 B) e0 c
- #include <NXOpen/MeasureManager.hxx>4 H' q. v3 H$ Z% M+ U
- #include <NXOpen/MeasureFaces.hxx>
) Z2 J) F Z1 r( u - #include <NXOpen/NXObject.hxx>
4 a8 \$ S0 O* J" _2 ?# q1 K* ` - #include <NXOpen/NXObjectManager.hxx>
& |8 @, k$ n7 _' Q - #include <NXOpen/Body.hxx>! }+ { G% f- h' I% v
- #include <NXOpen/Face.hxx> W5 h$ d+ c4 [: n% G" k5 j
- #include <NXOpen/Unit.hxx>9 t6 O T. a* W5 d- |
- #include <NXOpen/UnitCollection.hxx>
7 {) L+ L) R; L- _, ~ - using namespace NXOpen;
/ J% G& M% v. N7 W% D - ]( Y" [3 }4 l
- static tag_t ask_largest_face_interop(tag_t body_tag)1 i. C" Q$ K9 O; G" _
- {
4 Z9 T& \5 ~, f: r# L - Session *theSession = Session::GetSession();' h1 f L+ [- f
5 u6 h7 h: p) H% w- Part *workPart(theSession->Parts()->Work());1 S% w3 ~+ @- \( B* p. T9 g, [
- - t o. m \! M1 d
- Unit *area_units = workPart->UnitCollection()->GetBase("Area");8 ]3 d7 y1 X* u' ?9 I
- Unit *length_units = workPart->UnitCollection()->GetBase("Length");
, L( u. G- d# ^0 J$ v
9 Z& F2 `3 ^0 g( u- Body *theBody = dynamic_cast<Body *>(NXObjectManager::Get(body_tag));5 O9 H: @0 W9 p) B# k1 ^
- std::vector<Face *> theFaces = theBody->GetFaces();
4 i4 b2 H& |. z3 u+ x
2 x' k' I( j( y+ w- double bigArea = 0;- W Y! X J @5 l% t( X
- Face *bigFace;
, {* n1 F( x- O3 S - std::vector<IParameterizedSurface *> theFace(1);; H9 Y+ D/ B: e/ }( ?
- for (int ii = 0; ii < theFaces.size(); ii++)1 p4 W# O S3 s0 _ }4 E, B
- {
5 _5 a! @" U0 Q) q - theFace[0] = dynamic_cast<IParameterizedSurface *>(theFaces[ii]);
4 I! E3 X% o- u" y4 H - 5 c1 q: D& Q' c+ s. k+ ]4 R2 h, M' U* v
- MeasureFaces *theMeasure = workPart->MeasureManager()->; e; O- d; P6 }
- NewFaceProperties(area_units, length_units, 0.999, theFace);6 G! l) o/ o( B3 I+ Y5 c
# V4 L4 Y3 k F }- if (theMeasure->Area() > bigArea)
! K0 L9 M5 P: W* O - {4 q' H+ \. A- L; R7 j- \% u6 e
- bigArea = theMeasure->Area();
9 V/ h4 J% t' }& \ - bigFace = theFaces[ii];' Q# E0 u* a: w; C2 o" @; {
- }7 Q v+ Z, C# C0 K0 k' B
- }* _ T$ A% c& q1 G
- k! V- k' i4 j' l W
- return bigFace->Tag();0 N$ N9 z# F- q j1 b
- }
7 V( x7 k; w& l* d( n+ c
复制代码 + s4 J8 T! C" X9 h/ H; n. ^- B
! p, y! q. d# s0 f7 ], {: G, q! C7 N
|
|