|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, y2 w! b+ B( k# PNX二次开发源码分享:查找体中最大的面积3 w- t9 {" g) @! P3 X4 F
通过MeasureFaces 下的area方法可以得到面的面积进行遍历查询
9 R, `0 E% m; k& r/ F# p5 U" A1 Q' T; h
8 g' H# F. `- z8 I& l/ N3 i7 U
- #include <NXOpen/Session.hxx>$ r$ x" k1 I0 c5 _' Z% D# s
- #include <NXOpen/Part.hxx>
6 s+ U: v# @9 V$ @, t; g# y0 T - #include <NXOpen/ParTCollection.hxx>9 |. z1 s0 \6 W: d' f
- #include <NXOpen/MeasureManager.hxx>6 ^/ A- ]$ D, G( F4 Q$ }: G
- #include <NXOpen/MeasureFaces.hxx>. Q8 a* J) y+ T" l, {
- #include <NXOpen/NXObject.hxx>' _: D4 b6 e5 X4 A
- #include <NXOpen/NXObjectManager.hxx>
8 j% T$ A2 u3 T+ ]( o - #include <NXOpen/Body.hxx>
% S. D/ Q& K7 O* [ - #include <NXOpen/Face.hxx>; E0 e7 h$ G& m# ?/ M
- #include <NXOpen/Unit.hxx>
) j0 H7 ]/ W6 t1 o/ W - #include <NXOpen/UnitCollection.hxx>
! j$ r2 `8 O: l* M4 z2 X' w - using namespace NXOpen;
$ y. T6 J; k) o
+ U1 `9 H. Z: c. E, R5 {- static tag_t ask_largest_face_interop(tag_t body_tag)
8 x8 Q1 i9 p3 L* f' `7 f+ Q2 Q - {- @, n# P( a% @' i0 H" s6 h
- Session *theSession = Session::GetSession();, n0 d' J0 U0 y' Y4 r/ Y% l/ g8 p1 M7 U
( r; V5 c, T. y7 `5 |3 M- Part *workPart(theSession->Parts()->Work());
# F' P% V& B7 Z3 N5 h. d
+ B) Z1 S; D2 i0 H, [- Unit *area_units = workPart->UnitCollection()->GetBase("Area");6 l+ ~. L5 d c
- Unit *length_units = workPart->UnitCollection()->GetBase("Length");& _* ?5 X) j7 Z6 P0 ^! T8 h
- % d$ M, n2 D' N% M; A1 f; M- l H
- Body *theBody = dynamic_cast<Body *>(NXObjectManager::Get(body_tag));% g$ k6 o& C. v" c( ^$ A2 x
- std::vector<Face *> theFaces = theBody->GetFaces();3 m7 [: L) R% s3 _( Y
- ; l9 S# \ D5 W
- double bigArea = 0;. h, J1 r% P U$ R; R
- Face *bigFace;& k% B$ q! ^# ?1 A" w; N5 h' I5 P8 ]
- std::vector<IParameterizedSurface *> theFace(1);; j. Q& S# u( z5 i- J
- for (int ii = 0; ii < theFaces.size(); ii++)
' h+ n+ g) H$ Y8 v/ K( L( E - { e: ^2 ?* f% |: F% ]$ e2 }& y
- theFace[0] = dynamic_cast<IParameterizedSurface *>(theFaces[ii]);
+ i+ q; ]9 _. S! I
6 D+ s3 O# `- `4 o1 R/ n b3 ?- MeasureFaces *theMeasure = workPart->MeasureManager()->
|2 a% T! I+ H$ w/ ` d - NewFaceProperties(area_units, length_units, 0.999, theFace);+ f8 j9 x/ _8 _5 e3 ^( E0 [
- : q$ @4 z' h6 ~7 `& B0 E
- if (theMeasure->Area() > bigArea)
9 r! B* K' M: m2 t5 ?( [ K3 U& P c - {. `' P( [; I$ X1 i: [# J* E
- bigArea = theMeasure->Area();0 J" Y; G' X, @3 s) O% p v* Q
- bigFace = theFaces[ii];
+ j. w& J- ~; V v9 `* N9 ~ - }# F. c$ P: l6 }7 |8 P) b0 Q% x9 q
- }4 p& y' `0 a3 \' G' D1 X0 A2 `; }7 C
- ( Q! l: x$ |% q) B8 v+ R0 O/ @0 H
- return bigFace->Tag();
4 {3 F$ o: b) c2 }8 } - }4 G1 ~" g; O/ s8 U
复制代码 4 N- r5 |8 z0 @
8 r, ^# Z- K$ P4 X$ U
2 D- V1 | z: ^6 D2 n& f
|
|