|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" n( `% T7 V9 _, [NX二次开发源码分享:查找体中最大的面积
% a) r4 J; L4 e/ D通过MeasureFaces 下的area方法可以得到面的面积进行遍历查询
1 a: }, u$ f' E9 D: U) F' K* N- q$ b2 R& @* G
3 U% W/ D C, Q6 S( p4 v4 `& `
- #include <NXOpen/Session.hxx>
; Z" b8 L6 o7 V. d* z - #include <NXOpen/Part.hxx>2 _$ e2 u- ^8 D: r8 n! o
- #include <NXOpen/ParTCollection.hxx>
- F% ]) q# i; @' } - #include <NXOpen/MeasureManager.hxx>
, G( i7 I5 a3 T - #include <NXOpen/MeasureFaces.hxx> t {( ^5 e) h4 C5 P) T: r) k! m
- #include <NXOpen/NXObject.hxx>! Z5 n7 v; r' P' [
- #include <NXOpen/NXObjectManager.hxx>
- a& i# \) `; z- G8 G - #include <NXOpen/Body.hxx>/ R; X- t& s1 j( |1 z
- #include <NXOpen/Face.hxx>! Y1 Y; w: `, D
- #include <NXOpen/Unit.hxx>- E, \) V% d4 M
- #include <NXOpen/UnitCollection.hxx>( M8 Y G2 q5 b1 I/ m
- using namespace NXOpen;( h/ o4 l; T9 U# R# a; v- S
+ v- O0 G J6 v- static tag_t ask_largest_face_interop(tag_t body_tag)6 M. i7 L' V" o! E7 N- M
- {" T0 \: N/ v/ K- a- z
- Session *theSession = Session::GetSession();
6 \( O5 v$ e$ l6 I4 M - 7 y4 I; s! ` w% e9 K
- Part *workPart(theSession->Parts()->Work());: @' ]& c. n9 X, @1 @; i
* k: l! `2 ~; T% C% d3 w s3 n: q1 `- Unit *area_units = workPart->UnitCollection()->GetBase("Area");
/ p2 S* v. Y' |6 a - Unit *length_units = workPart->UnitCollection()->GetBase("Length");, f7 N8 e8 J9 f/ [; h. B
- ! Q/ A$ r. d8 u$ N% F# Y( `6 W
- Body *theBody = dynamic_cast<Body *>(NXObjectManager::Get(body_tag));
2 ]% l2 N' N' l# t2 X - std::vector<Face *> theFaces = theBody->GetFaces();, m4 a* L. q6 E6 G h4 _+ [# o; A
/ V# i% R) u6 \/ a- double bigArea = 0;: s1 W( o, C5 H* P- t
- Face *bigFace;
7 }' T( a3 S+ J r# C$ V - std::vector<IParameterizedSurface *> theFace(1);
! N, y9 Z2 S, H4 O; \$ c - for (int ii = 0; ii < theFaces.size(); ii++)
# x5 }/ |$ B' ?+ [ - {
$ T# s: o" K' w2 E - theFace[0] = dynamic_cast<IParameterizedSurface *>(theFaces[ii]);+ n, Y; v: C7 u9 q: y
- 9 a, M# V F3 |! Y& z5 q% @& z
- MeasureFaces *theMeasure = workPart->MeasureManager()->7 x y1 ?! b3 L. w" d% r
- NewFaceProperties(area_units, length_units, 0.999, theFace);6 G# L5 n1 S- _1 G
8 h) V. {+ ^* s0 O( ]- if (theMeasure->Area() > bigArea)# L9 y! i! x9 i+ x( H/ N5 V
- {" Y; c) m: N3 z/ f8 j$ A
- bigArea = theMeasure->Area();
$ F1 v/ ~7 Y- k4 ^. C8 B4 s% [ - bigFace = theFaces[ii];3 U: X, t2 f! g0 _ S1 P/ P
- } k; @* a( O0 O% d% |
- }! x7 t& G1 _8 M- O) T3 A4 u
0 G% F/ U9 \2 w* q4 F$ I7 |4 h. }- return bigFace->Tag();- M6 N2 P% P; p6 O) ~, p
- }
& n/ N: q Z8 ~" \0 F
复制代码
% `" J# _8 m" B# i6 k P5 Y
5 c) U. Q, a# Y0 ^6 {& W# g; P2 _- m: z1 l. c& f l7 T% s9 Z0 a
|
|