|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
* K( P; E& A; n; f
" b; U( _" T% p7 @* ^; h- <P> </P>
复制代码
" b! m2 h: ^6 X; i: K: m4 j- <P>void CreateCylinder_UsingUDB::CreateCylinder()
( Y7 s! q/ o- u9 H% C8 e - {# p! X2 ]) {) i0 Q$ I
- Part* workPart(theSession->Parts()->Work());</P>; i: Y: H ^: e) M2 O+ H8 I+ r- c# {
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;! p% ~; T, K J$ b
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
' O5 V/ F1 T0 l4 D6 q - <P>//Get the point- Q( E7 S6 y' f
- PropertyList* pointPropertyList = point0->GetProperties();
# j- I9 Z" g; z. f. W - Point3d originPoint = pointPropertyList->GetPoint("Point");
! L2 I: Y) k* u9 s1 J# s; C - delete pointPropertyList;1 T' Q& h2 M* C. ]
- pointPropertyList = NULL;</P>
3 @- Z" A4 L$ N$ s5 e4 T( Y - <P>//Get the direction
# R* E: B# V: K7 l) q$ ^ - PropertyList* vectorPropertyList = vector0->GetProperties();5 J* D, n+ z9 Y$ E9 C4 n9 b: B
- Vector3d direction = vectorPropertyList->GetVector("Vector");1 G% f! {6 p" X4 \# F
- delete vectorPropertyList;. e/ E% T; o( ^0 p% I
- vectorPropertyList = NULL;</P>! O4 k; J. l( w6 t7 {4 j' O# y
- <P>Direction* direction1 = NULL;
! t& `, d' a1 r: q7 n, U6 z3 ?* W# d - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
+ g) E5 R$ ^) R1 \$ M - <P>//Set diameter and height
( H4 i7 P) p* M( j - std::stringstream diameterValue;7 X5 a: I" C6 z- |. S
- diameterValue << diameter->GetValue();9 K# _! `& l7 O0 R
- std::stringstream heightValue;3 r3 Y! {# i- V/ R) s
- heightValue << height->GetValue();</P>5 W1 l* H. v( n. Z& j% q" J0 U
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
" ^( a, S$ D' M% p4 { - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
8 I% v% K& X8 W; C4 p) ~ - <P>//Set the axis% r0 c& i& }: `- y3 _( T5 X+ f0 q
- Axis* axis1 = NULL;+ f/ Z/ T2 L# D6 a( C
- axis1 = cylinderBuilder1->Axis();
; x% ~& I% S w7 b6 _, H - axis1->Point()->SeTCoordinates(originPoint); m0 r4 J3 K( l9 m3 H# m* F6 N- b
- axis1->SetDirection(direction1);</P>
6 Z/ A/ ^$ x } - <P>//Commit6 U% J* o0 d7 b# c$ g
- cylinderBuilder1->Commit();
( _+ h. S F; D$ A% V - cylinderBuilder1->Destroy();5 W4 W: Q3 D1 y: h% y0 w
- cylinderBuilder1 = NULL;8 Q' ~- r6 ?. ?+ @) u. E- ]* K
- }
2 F) D* x; A! ?3 E - </P>
复制代码
. l8 e- Z/ b, k [ |
|