|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
& `0 e$ k( Q7 m" Z
]+ H& x' x2 V6 Q' W- <P> </P>
复制代码
, ]. _5 [( T% ^% q7 x' Q% I- <P>void CreateCylinder_UsingUDB::CreateCylinder()
; Q6 e: \; m: d - {
; n3 X& x3 B$ m f6 |, _ y" p - Part* workPart(theSession->Parts()->Work());</P>! j- N. H$ [: C' f6 p3 v b
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
, J6 t i8 O# W$ Q1 I - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
0 ^- X& K! T% b! @ J9 w | - <P>//Get the point3 E' `3 z, w; P$ u9 Q
- PropertyList* pointPropertyList = point0->GetProperties();$ ]& k2 H) @$ ?$ K" d! j5 V
- Point3d originPoint = pointPropertyList->GetPoint("Point");
4 j5 J2 l u4 ~- U( _& d - delete pointPropertyList;, @+ _2 f- x% f+ M, \
- pointPropertyList = NULL;</P>
x" I C& Y/ e4 g6 A - <P>//Get the direction
7 e/ e! @$ q9 X) E j: U - PropertyList* vectorPropertyList = vector0->GetProperties();
5 K4 {. G) B4 l/ ^3 E* T - Vector3d direction = vectorPropertyList->GetVector("Vector");
; u) n1 j' ~/ ]& x - delete vectorPropertyList;
5 X' Z. P, d+ ]1 \" b1 Y- c6 | - vectorPropertyList = NULL;</P>. e q) a( [% M
- <P>Direction* direction1 = NULL;9 h( J* A* x; d
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
% q0 \2 Q: [- m0 C3 U - <P>//Set diameter and height( \6 l5 k" U6 ^7 K+ t! t! O
- std::stringstream diameterValue;
3 b) b$ X' k+ x' t - diameterValue << diameter->GetValue();
1 x! q! x6 H: r' G* i0 [ z" ?& F - std::stringstream heightValue;
5 w+ Z! R K4 @0 }1 x, w - heightValue << height->GetValue();</P>
" W4 ^' R" L9 C, j - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());9 n8 q* y _9 e5 s% x$ n; s! E
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>6 `% s' Q; K" o5 D4 ^& T
- <P>//Set the axis
# v' n9 y- j/ M& ]+ U7 ~0 F - Axis* axis1 = NULL;& p/ W6 a: N1 t% _1 Z/ B
- axis1 = cylinderBuilder1->Axis();
/ `- a) K s) y - axis1->Point()->SeTCoordinates(originPoint);
. g ~$ E# O! Y, Z0 G2 ? x% R& a - axis1->SetDirection(direction1);</P>* U! O d, i) o6 }! [3 j9 W2 W
- <P>//Commit) O* i0 c. n4 x# W7 h3 @# D
- cylinderBuilder1->Commit();
6 {, [% q% _' j6 r$ { - cylinderBuilder1->Destroy();
0 x9 o' F6 K3 |% ` - cylinderBuilder1 = NULL;
% h- a% k$ r V4 U6 ^' i8 N - }
5 Z3 ?% p; X- ]8 c - </P>
复制代码 ( {( _+ G& t4 m9 J
|
|