|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
) o% I6 S+ l. O% _/ i* p ?0 z- ! k0 x; p _# K: n9 j3 p0 p
- <P> </P>
复制代码- 5 P% U, L( j# N7 y
- <P>void CreateCylinder_UsingUDB::CreateCylinder()
X! H) R% l: q( |; N+ D - {! C# w: k2 B$ Y! X' G& u9 q
- Part* workPart(theSession->Parts()->Work());</P>
- L6 |9 w& Y. B6 j& N, M - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
4 i2 u+ C6 r% k5 c. O - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>* |# ?& h: Y6 _. f* \; h
- <P>//Get the point
! U) j: ^. \! k; P4 p% }4 q+ T# ? - PropertyList* pointPropertyList = point0->GetProperties();
( M6 C6 q" Z, z& c. G - Point3d originPoint = pointPropertyList->GetPoint("Point");5 e6 o n! K* O
- delete pointPropertyList;
# c8 F% B! `- Y- _ - pointPropertyList = NULL;</P>
- e* J1 E$ ^; j' u8 t - <P>//Get the direction
0 u. M t# ~8 ]8 E: W) I% E" u - PropertyList* vectorPropertyList = vector0->GetProperties();
8 R" C* w$ ^, L* \6 s - Vector3d direction = vectorPropertyList->GetVector("Vector");
5 o$ k- O% L8 K$ W/ j9 b - delete vectorPropertyList;
- _# `" u4 J1 Z- z. d2 b - vectorPropertyList = NULL;</P>" K9 `0 Q% E( p+ K, b/ d
- <P>Direction* direction1 = NULL;
( T h7 q8 x% Q% w) g- a$ N - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
2 n/ I/ u. _. _ - <P>//Set diameter and height) ^; u$ B$ W' A, `2 J+ C( p7 U
- std::stringstream diameterValue;
+ w r$ w/ c% t0 p* g) \ - diameterValue << diameter->GetValue();
! t+ W: [0 C- l1 `, \ - std::stringstream heightValue;7 Q! E r) J; R% O. |
- heightValue << height->GetValue();</P>
3 G* d( s/ B1 g - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
' W1 a5 J+ Y0 g1 F& w - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
& ?& |8 W1 [, `4 o - <P>//Set the axis! \7 g) F' d( V& X6 w/ S- H$ S Y6 H
- Axis* axis1 = NULL;
: m3 e1 \7 a m S ] - axis1 = cylinderBuilder1->Axis();
& L: Y" A. h g; G0 l) M) A! Y - axis1->Point()->SeTCoordinates(originPoint);3 z4 s0 y! g1 |& T$ n/ K
- axis1->SetDirection(direction1);</P>! L# V7 T2 m9 ?; S0 X5 R% ?
- <P>//Commit9 `2 Z0 u i7 N9 Z0 c. p" h
- cylinderBuilder1->Commit();
9 ~1 H- N5 h6 Y - cylinderBuilder1->Destroy();1 K6 `1 B+ \! c1 P* x; t
- cylinderBuilder1 = NULL;- Q( z7 M5 H$ X( P
- }
0 ^4 O% a8 |7 h+ l( [ q/ M - </P>
复制代码 . ^4 @4 _* Z* D+ C0 l5 K
|
|