|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
& T5 F) u( S- Q6 S- ' {; o. e* O4 _! W. s: f
- <P> </P>
复制代码- 7 v9 Z. R; h3 U3 N$ F' [8 W8 x
- <P>void CreateCylinder_UsingUDB::CreateCylinder()( E8 `5 c$ ]/ A, R
- {, I8 i4 Y* I' P/ `6 s$ r0 p
- Part* workPart(theSession->Parts()->Work());</P>+ X3 S Y3 ?! Y4 R2 H
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;6 [$ H1 z5 Z$ q. ~ p2 B
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
1 z' U7 e) X( Y% u; J- w - <P>//Get the point1 A% Z0 e! I. I
- PropertyList* pointPropertyList = point0->GetProperties();
9 l# |% L7 }, b' G* S - Point3d originPoint = pointPropertyList->GetPoint("Point");; s! U# e' _6 G8 |$ ]
- delete pointPropertyList;1 j' O3 y8 _- Z
- pointPropertyList = NULL;</P>3 x! {8 l4 T4 G
- <P>//Get the direction
2 {; Y6 b B* O1 p/ _9 N, U - PropertyList* vectorPropertyList = vector0->GetProperties();
8 R+ h/ [8 o) U2 p - Vector3d direction = vectorPropertyList->GetVector("Vector");
7 K2 D4 c4 M# W1 P+ B+ j$ Z4 \ - delete vectorPropertyList;
9 y) c& u+ l% j# x# @) V" _- Q - vectorPropertyList = NULL;</P>7 N$ _1 Y; W) e% Y! H M
- <P>Direction* direction1 = NULL;, R: b: }. e, {) Z7 Z8 Y. \
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
8 `+ ~) ?; D8 t( W8 ~5 O. L - <P>//Set diameter and height
% N! ?, f k( q z - std::stringstream diameterValue;
( O$ f1 W( e$ f1 a, w8 s - diameterValue << diameter->GetValue();7 V) r Z/ N F0 |1 Q
- std::stringstream heightValue;
% B4 G$ a( s- g - heightValue << height->GetValue();</P>
" |- x* i3 q: q0 X2 k - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
% u! N# O, P$ S t1 H - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>6 \8 Y b+ Q z7 O
- <P>//Set the axis
. a, N! J) ~. c - Axis* axis1 = NULL;$ A, J- a! ?: N# H+ ~* q* F* K
- axis1 = cylinderBuilder1->Axis();
' y0 n9 U5 T3 `5 m, V! S- y! _2 u - axis1->Point()->SeTCoordinates(originPoint);
" T" m, R) S! X ]7 k. K - axis1->SetDirection(direction1);</P>/ i7 N! K( b$ V5 H2 ]1 V
- <P>//Commit# [; Z* C0 C4 D1 ^$ I
- cylinderBuilder1->Commit();
6 _& `+ ^" W; O2 C& v0 ~ - cylinderBuilder1->Destroy();
: `; e1 J) h( }4 A& P; f5 o5 z - cylinderBuilder1 = NULL;
0 `! y2 e. E2 z- E. H7 U - }' `# y% Z4 D1 V
- </P>
复制代码
/ C4 w. S' M! r% J, m2 b |
|