|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征4 C- X& X3 I( H5 e
2 s* ], E& j" _1 H: k- <P> </P>
复制代码
8 L: b7 ?7 q8 @$ U- <P>void CreateCylinder_UsingUDB::CreateCylinder()5 g9 e- v. g9 b0 h) p
- {+ h8 F9 J% T" r. Q
- Part* workPart(theSession->Parts()->Work());</P>& D; x# ~8 ?, k
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;: l9 U* T B1 E
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>7 ]$ p3 ?. o! R, e! ]& O0 P8 J
- <P>//Get the point
% W7 G; q- ^6 q4 a8 M - PropertyList* pointPropertyList = point0->GetProperties();
: \' U3 N2 d# O3 V6 d - Point3d originPoint = pointPropertyList->GetPoint("Point");
/ ^/ T9 A1 E! J - delete pointPropertyList;
* v- J) {% n8 |1 t- `! i4 V - pointPropertyList = NULL;</P>6 ~' }" N! ]3 i( y f: i
- <P>//Get the direction* `- m0 [. P: L5 L# j1 ]* {
- PropertyList* vectorPropertyList = vector0->GetProperties();
) O) b, R: L4 S$ _/ P! _6 u - Vector3d direction = vectorPropertyList->GetVector("Vector");1 F. F3 Q$ o* Q
- delete vectorPropertyList;) [* t. F. t2 W0 g0 d4 l0 Q
- vectorPropertyList = NULL;</P># i7 E5 s: V3 }( j6 }
- <P>Direction* direction1 = NULL;
4 ~3 L6 ~% Q" H; |0 A8 ~ x% D - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
) A3 N8 V1 x# `0 P/ W+ E" K - <P>//Set diameter and height
; R) h& E4 R" B( t - std::stringstream diameterValue;, u' v+ v1 C% N* K% \3 u
- diameterValue << diameter->GetValue();* b3 J7 A) e' h1 G3 y- \
- std::stringstream heightValue;9 z' L4 T* _& S# w$ r
- heightValue << height->GetValue();</P>
* K6 T ^7 J/ r7 S4 f - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
, k& O# O1 l1 [$ } - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>: f' v/ M& G0 O! Y2 q; S
- <P>//Set the axis/ }3 X, I+ r) S
- Axis* axis1 = NULL;( ~$ c4 H- B% c' ]
- axis1 = cylinderBuilder1->Axis();5 h( Q$ h% J2 I, M+ r6 z5 h
- axis1->Point()->SeTCoordinates(originPoint);0 A* Z- u1 |3 u' P( J
- axis1->SetDirection(direction1);</P>
( ?! Z s) c; B3 {- K" c% { - <P>//Commit
1 l/ C# i U0 \, } - cylinderBuilder1->Commit();
) {% R& a4 O* _ t% v7 A: l, d - cylinderBuilder1->Destroy();: |+ V5 O. m2 ~4 v! d7 Z% Z- m
- cylinderBuilder1 = NULL; j# p: S' T2 s, U( h) k
- } ?3 |3 F: M3 |3 A' `
- </P>
复制代码 , ^9 o& W1 M# z, g
|
|