|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
9 t/ G) t" Z; @0 A; h! x% O& P$ S& X- 3 I! }+ q; U9 _, X' T
- <P> </P>
复制代码
+ P- k' s/ N. M+ [% A/ y1 F- <P>void CreateCylinder_UsingUDB::CreateCylinder(): T2 `& p" V$ t2 p+ R
- {3 v P5 a; X( t% }
- Part* workPart(theSession->Parts()->Work());</P>% w# l: b( w. F' z
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;4 q7 Z" M/ N% I
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
/ h# A: o5 l1 Y4 z) `% P2 N! v, r - <P>//Get the point! m* x% s7 _7 o9 d( C
- PropertyList* pointPropertyList = point0->GetProperties();
% e; \( ^. D K1 H8 } @' i - Point3d originPoint = pointPropertyList->GetPoint("Point");
5 ]# d8 ~! f- p5 a& N7 T - delete pointPropertyList;
- D" f# a. N6 ?5 m8 R7 T2 d - pointPropertyList = NULL;</P>7 b# V3 _ H6 d! K( T7 ?
- <P>//Get the direction
2 B$ p# x9 ?: Y) ~! r - PropertyList* vectorPropertyList = vector0->GetProperties();8 R) f5 u/ R7 O/ ]
- Vector3d direction = vectorPropertyList->GetVector("Vector");
+ ~* K1 J( g0 V% @7 z* i - delete vectorPropertyList;
3 G; |$ T: i" B1 W. N5 F - vectorPropertyList = NULL;</P>
* z6 g4 W7 |$ \ - <P>Direction* direction1 = NULL;5 p7 D! L6 C" R9 K. I" Y, M
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
) u. }; \, ]% R7 Z - <P>//Set diameter and height
( [7 B5 {# f% r - std::stringstream diameterValue;
" j2 ~; g: {, m: S# F' m - diameterValue << diameter->GetValue();% D9 c) |+ G, h( g) Q I: S {
- std::stringstream heightValue;6 M* H4 [: p& U# F# A& }2 d5 z& W
- heightValue << height->GetValue();</P>5 ~/ k5 X+ N, J- v0 `
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
3 P# Y3 k6 _$ K! H* u - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>) J& s1 S1 b) ?+ @" s9 Z* F
- <P>//Set the axis
: C8 u4 K, Z& f8 d - Axis* axis1 = NULL;2 J0 \: V5 a+ k0 n( j' W1 A. p/ M1 L
- axis1 = cylinderBuilder1->Axis();$ N& @/ S: f& g6 k- r4 d( b
- axis1->Point()->SeTCoordinates(originPoint);( d) X% d1 Y: q: F* a" E. ]
- axis1->SetDirection(direction1);</P>: L, N' }" e+ }' o" V0 t/ u
- <P>//Commit; ~% U0 {, h' V7 w. ~& p5 B3 Q+ m
- cylinderBuilder1->Commit();
- M; y ~7 N# u' k3 r - cylinderBuilder1->Destroy();! d# p/ o) }# Q& E
- cylinderBuilder1 = NULL;
, H+ z8 g( B# H) X6 q! Z6 i. b - }
, M" j* H: {- [# X3 c) I - </P>
复制代码 6 e- H) R+ Q" S6 l3 S. |8 U
|
|