|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
' A% z1 K8 V3 b3 I- " ~5 \! q5 a9 v( p: d! A. e8 R5 R
- <P> </P>
复制代码- q8 s5 C$ p( A! k; c4 e6 U
- <P>void CreateCylinder_UsingUDB::CreateCylinder()$ z$ k" [! Y5 U* R6 |) Q% p. p
- {' Z0 U5 N# l: J. t
- Part* workPart(theSession->Parts()->Work());</P>
! V5 b' e, ~# Z9 s - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
" U, a4 z& s } s$ m$ ~ - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>) S) b0 O* W- s1 a% t$ x6 b3 U
- <P>//Get the point
, F- B. ]7 g ^ - PropertyList* pointPropertyList = point0->GetProperties();: t1 ]1 p/ X5 C' |
- Point3d originPoint = pointPropertyList->GetPoint("Point");, x7 h# O7 O; o" ]( ~6 E
- delete pointPropertyList;0 Q0 U e0 v$ P
- pointPropertyList = NULL;</P>
% [# A; o! ]0 e7 o4 Y - <P>//Get the direction
0 K+ }+ ]: O0 V/ ?9 E; H& H - PropertyList* vectorPropertyList = vector0->GetProperties();
1 e$ ?5 B* D1 m' ~ - Vector3d direction = vectorPropertyList->GetVector("Vector");
+ T. R3 u* J0 o2 B: I. S - delete vectorPropertyList;' s& U4 E: C" b% h/ W9 |
- vectorPropertyList = NULL;</P>
2 _+ A* O$ A8 i8 n! g# p - <P>Direction* direction1 = NULL;
: Q9 m: q" @9 O ?) v% K! ] - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
6 a6 H) B H& A - <P>//Set diameter and height$ l7 K1 e% Y+ R m, |, s7 b
- std::stringstream diameterValue;! w; t' S) n/ s y2 m3 `1 a( W) y6 p
- diameterValue << diameter->GetValue();* b1 [+ c+ k5 w: `; @
- std::stringstream heightValue;3 H1 W& R% C3 q7 s
- heightValue << height->GetValue();</P>
% L1 _* I* \% \2 P - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());) z/ n ]# y- z+ p" L& B) G8 _5 m
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
( N& x& M+ @; [7 R8 B - <P>//Set the axis) ?3 A0 _( S: m. P
- Axis* axis1 = NULL;
" |8 m" k5 N* j( w# Q' n - axis1 = cylinderBuilder1->Axis();
! g. X9 _$ K \: M4 R - axis1->Point()->SeTCoordinates(originPoint);
. d3 o: c x/ I! X7 {6 n9 l - axis1->SetDirection(direction1);</P>: w9 k9 X* c5 ?
- <P>//Commit
I. G7 k- b+ c7 \3 h - cylinderBuilder1->Commit();
. t" D- z3 E, p7 H - cylinderBuilder1->Destroy();* X" ?. i. w x! D
- cylinderBuilder1 = NULL;
( Q$ R: x0 Z/ K3 r) q. d) t - }
- Y7 N% V* O1 `$ K, d* F6 U+ \$ y [ - </P>
复制代码 $ L5 s, {' j( ~( n- P! T
|
|