|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
/ |/ f3 X. b Z- r B
3 f- ^) g/ D1 m1 X- <P> </P>
复制代码
1 O, w; T: p! }5 c* E0 l7 H' ]- <P>void CreateCylinder_UsingUDB::CreateCylinder()
% X! S: j/ d; m0 Z3 r, q - {
! t5 {7 p* C7 G8 D# m - Part* workPart(theSession->Parts()->Work());</P>
, L0 }6 ?; }# K. l- u - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;, `; {% N8 I: R* `
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
, P6 ^8 ?# @" F6 t. q3 a - <P>//Get the point
0 h5 G5 j: U8 P' L - PropertyList* pointPropertyList = point0->GetProperties();) v, A4 g. K$ w+ s
- Point3d originPoint = pointPropertyList->GetPoint("Point");
! K0 X: ?$ ]7 q. F% z - delete pointPropertyList;
0 u% r0 ]# [ e ?& q7 _( U - pointPropertyList = NULL;</P>
3 }7 ?# ?% q! \3 r3 g, S s+ \ - <P>//Get the direction+ q3 C: C0 O2 g' s/ p' k
- PropertyList* vectorPropertyList = vector0->GetProperties();0 f/ U( g) q" X
- Vector3d direction = vectorPropertyList->GetVector("Vector");
$ G+ \0 r5 h, Q! G$ M) k - delete vectorPropertyList;
M- X, V5 o3 A& {% g8 n - vectorPropertyList = NULL;</P>
/ I6 w, b- u- U& s4 ^ - <P>Direction* direction1 = NULL;
. c( n- h1 E2 p, Y* Q- t - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
2 O3 n8 F- x. D; Z4 y! T* @0 _( t - <P>//Set diameter and height* R: F" O; ?* O* L; U( M+ S
- std::stringstream diameterValue;: z0 C8 Y/ S& X/ o
- diameterValue << diameter->GetValue();3 e) }9 W2 i8 l" }- u3 M
- std::stringstream heightValue;
; O; |& |5 z2 F' I - heightValue << height->GetValue();</P>2 i4 `* k6 U9 l$ m
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());# [* _8 {+ }: d5 t/ g' ?
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
; v3 j- A( r, j! G4 M - <P>//Set the axis0 c. g5 m" x( Q5 Q
- Axis* axis1 = NULL;
5 L" M: j( ?& ]' X' u' n/ p - axis1 = cylinderBuilder1->Axis();8 n3 t( h1 ~' e( O+ z7 a( R
- axis1->Point()->SeTCoordinates(originPoint); s" a6 ^4 Y, A6 S( B/ d! a5 ^
- axis1->SetDirection(direction1);</P>
; v" P( _+ @* _/ ]& W' Z - <P>//Commit
, W( |# l* T x l) O( ~/ | - cylinderBuilder1->Commit();9 W- F2 W T3 X* M/ D0 t
- cylinderBuilder1->Destroy();+ |& f" b9 B( G
- cylinderBuilder1 = NULL;# U6 K5 x. H2 ~- i3 x- }. f
- }
+ d4 o4 p1 l; J" \* f1 Y0 k' x. I - </P>
复制代码 0 f- q: r" H v9 d/ h
|
|