|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 s/ `1 `" }. \4 B; A8 |, jNX二次开发源码分享:查找体中最大的面积
, g4 v$ h' s- q/ x通过MeasureFaces 下的area方法可以得到面的面积进行遍历查询3 N4 ~# U: w& K
" V+ u4 f. g0 `9 M* Y
! ]0 e9 r& R; X: m; l- c- #include <NXOpen/Session.hxx>* r$ s) w0 P4 d
- #include <NXOpen/Part.hxx>3 ?! o; p" ?7 |
- #include <NXOpen/ParTCollection.hxx>, Y% o+ T/ l, |
- #include <NXOpen/MeasureManager.hxx>
6 y6 h- @8 L8 P- T6 j - #include <NXOpen/MeasureFaces.hxx>8 j9 d2 f s1 w v2 R$ r
- #include <NXOpen/NXObject.hxx>
, U6 }' E' a' ~( G7 M - #include <NXOpen/NXObjectManager.hxx>
# F' t! J2 N5 B) H8 {$ p t% J - #include <NXOpen/Body.hxx>
; [ X" p$ n4 S: P - #include <NXOpen/Face.hxx>+ U6 J. d7 ]# i5 I
- #include <NXOpen/Unit.hxx>
0 C- Y' x0 b* v - #include <NXOpen/UnitCollection.hxx> U- V9 V% L: @# Z* i4 j
- using namespace NXOpen;* e' g- ~* j: I" ^
- 6 O, g2 ?: |6 K; G4 f+ K
- static tag_t ask_largest_face_interop(tag_t body_tag)( [1 } h; Y- H' | J0 W& p
- {
" x1 e, r' g# s2 j( y/ f- V M G1 P - Session *theSession = Session::GetSession();3 X+ S, W3 q5 m+ e0 X
- H: [: w ?5 a9 W: i2 q
- Part *workPart(theSession->Parts()->Work());( M) \: P9 K( s/ s& M
* A* L2 k4 S2 W- Unit *area_units = workPart->UnitCollection()->GetBase("Area");5 k1 k' ?/ A# J' }
- Unit *length_units = workPart->UnitCollection()->GetBase("Length");: r+ z8 W% k. U2 F5 t0 y
7 m' J$ G: f0 ^, p$ z- Body *theBody = dynamic_cast<Body *>(NXObjectManager::Get(body_tag));, x& N* C. }6 E4 ?$ Z+ D2 F: @
- std::vector<Face *> theFaces = theBody->GetFaces();
! z/ U# w6 y) j( V - 4 ^. l4 o( K! ^. g) P
- double bigArea = 0;
3 y0 I9 e" `8 T% v6 q. Q4 q - Face *bigFace;
; w7 ]. `9 `) e' x - std::vector<IParameterizedSurface *> theFace(1);
4 Q4 U; U7 ]: D3 s! Q& x/ S% U% m - for (int ii = 0; ii < theFaces.size(); ii++)# x& e8 H- _/ X9 L5 m" O
- {
# n( n- f# r2 w H: Q% B+ B5 { - theFace[0] = dynamic_cast<IParameterizedSurface *>(theFaces[ii]);
2 t; M& o) H; Z7 `: N& N, r% o F
; U/ s C+ A! }( t$ Z A! v- MeasureFaces *theMeasure = workPart->MeasureManager()->" y) e: B* i3 w# F! _
- NewFaceProperties(area_units, length_units, 0.999, theFace);
( P$ p9 D; l5 i, g" y - a, x( o( R( _$ j( I
- if (theMeasure->Area() > bigArea)
" Y8 ^$ a" S& ?% ] - {
7 B- R3 i1 s8 U6 j, r1 K! N7 q - bigArea = theMeasure->Area();
$ g* ~+ w! }4 h9 c8 K8 n5 Q - bigFace = theFaces[ii];$ F, D+ c, M( |+ G: W9 U/ a6 p
- }5 d5 w' w! {" n
- }) R6 j" f* \6 W9 ?& _7 k
- / w Z2 I+ y: ^/ w9 ~
- return bigFace->Tag();
- _8 ^' l1 W4 h" `5 k& ^$ Z5 Y - }" r$ |4 G; C/ }8 z; d! U0 [
复制代码 * M3 g# p9 @. g3 ]# }. p, b
8 }7 \! y& v: M( `! O9 ?& q
1 x& ?/ l/ J+ S6 [2 B7 P
|
|