|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
0 k1 k1 h! d+ Q' p+ s3 V- 0 y8 M* ^( @, \; K+ e; \& i
- <P>void CreateCylinder_UsingUDB::CreateCylinder()' T2 ^* K! D+ n$ h0 T& Y
- {
$ Q% x* `8 H/ J* L8 c9 O - Part* workPart(theSession->Parts()->Work());</P>5 s7 T0 {6 ^( q& k/ J% n6 Q
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;* S/ i& X+ G6 V p, ]9 H2 Q
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
0 f: q) S( N- \* V3 Q- W4 ?* O - <P>//Get the point
4 A' b8 \/ Y1 s8 l& R% g - PropertyList* pointPropertyList = point0->GetProperties();
; T! {5 x% p6 L; S - Point3d originPoint = pointPropertyList->GetPoint("Point");1 m6 q- y U9 w/ V0 S: ]
- delete pointPropertyList;6 ]; Q1 O! E( X% G) B& B0 T
- pointPropertyList = NULL;</P>) M I3 b+ B6 G/ I6 m
- <P>//Get the direction; L4 L5 G, @! A& u- z
- PropertyList* vectorPropertyList = vector0->GetProperties();" [* E3 E2 F0 z; R0 U3 O; t. |
- Vector3d direction = vectorPropertyList->GetVector("Vector");' o( @, d1 N, N' b2 N
- delete vectorPropertyList;0 ^) J' K$ T- v- {, Q2 F( w
- vectorPropertyList = NULL;</P>
6 X2 W- f5 x7 m6 t2 ]2 N( j4 q - <P>Direction* direction1 = NULL;
1 O N1 i6 l, n* ?. @ - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
/ m+ @& J# f2 E9 B4 _" n V - <P>//Set diameter and height
& y3 y% W; ~0 _$ P# l, B9 X X - std::stringstream diameterValue;& D; P4 M8 O8 g* k5 K) T% N4 Q
- diameterValue << diameter->GetValue();
* c4 o* A2 C( |& d4 J - std::stringstream heightValue;% J+ \* e, `6 V# y
- heightValue << height->GetValue();</P>
J: [4 d( O) t+ J- X - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
3 r& z/ M, E& B% }4 i0 F9 H - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>! t# |7 _3 M# E; V# I
- <P>//Set the axis
2 a: w. Z8 [4 p - Axis* axis1 = NULL;
7 Z6 w# g( Z- Q- }3 |& W/ U( \ - axis1 = cylinderBuilder1->Axis();
* d4 g% [9 G# D+ b9 F+ g8 W - axis1->Point()->SeTCoordinates(originPoint);( S( H5 v5 s% X" V
- axis1->SetDirection(direction1);</P>
' Q6 X' A6 y5 v0 H( [* q - <P>//Commit( K! j% g& u- O3 r
- cylinderBuilder1->Commit();
/ w. v# W; S- A K# z D3 c - cylinderBuilder1->Destroy();
7 }+ E p: T0 t9 G - cylinderBuilder1 = NULL;
! R \0 d' T9 q+ t) U5 R1 e# y - }
2 s: M( o2 [* A# J+ H - </P>
复制代码
* X, |0 R( N, h" Q! P3 Y ]) f2 m |
|