|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
. ^0 Z, m8 `0 F! P
$ w* b. L$ |% }% t+ H Q7 |0 m) Q- <P> </P>
复制代码
% d3 j7 c- J9 @( _2 A- <P>void CreateCylinder_UsingUDB::CreateCylinder()
0 y$ w+ z F8 ]2 Y - {$ O* P6 }/ u; k+ a
- Part* workPart(theSession->Parts()->Work());</P>5 J @' e4 K6 E3 n* @+ I) |! G1 o
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;! i! @, i: o g) ~4 @
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>& f9 u' x- N2 G' Z+ R3 r( y
- <P>//Get the point; K6 l/ ?9 [- q
- PropertyList* pointPropertyList = point0->GetProperties();* [1 y h! m% ^+ ?& T
- Point3d originPoint = pointPropertyList->GetPoint("Point");
& }9 A# y, c, O0 s# T. Z - delete pointPropertyList; N7 d- M/ @- D {0 U' A1 V2 a" J
- pointPropertyList = NULL;</P>
& w/ a: V- @" u4 Q - <P>//Get the direction0 U& g3 V9 [5 X' Q" G$ v! [
- PropertyList* vectorPropertyList = vector0->GetProperties();; L5 ], {1 y& U0 b: V
- Vector3d direction = vectorPropertyList->GetVector("Vector");2 y, m( p/ Z5 M9 a4 \& C( I. y
- delete vectorPropertyList;, R$ ~: S5 B& u. U
- vectorPropertyList = NULL;</P>
- `6 i$ k% Z0 F# C+ L7 [3 J - <P>Direction* direction1 = NULL;3 F! _- [8 g* X E# }# J
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>1 y7 G& }% M& {, S$ I
- <P>//Set diameter and height; Z; n4 R5 v3 Q- `/ t6 j
- std::stringstream diameterValue;
) u8 I8 a; ?3 F+ I - diameterValue << diameter->GetValue();; A3 {: W1 `1 ~+ T5 M/ m
- std::stringstream heightValue;
( m4 e! G5 P: q) q$ g& Q/ v - heightValue << height->GetValue();</P>! P+ Z. A: A) B9 D
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());! g$ B% `& q2 q% y' H
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
3 D. A% L( _6 [9 u+ c4 g - <P>//Set the axis2 z8 k2 R1 J1 S, T( _! R) z5 F: R
- Axis* axis1 = NULL;
, n( n/ e* V3 Q. q% d - axis1 = cylinderBuilder1->Axis();
& t* N( _3 g F - axis1->Point()->SeTCoordinates(originPoint);
& t+ F3 o7 D" F: ]9 f% C! b - axis1->SetDirection(direction1);</P>
& z9 U. S" m: p8 q- K4 e) S - <P>//Commit
+ I Z$ r. D$ o3 R, V m0 ] - cylinderBuilder1->Commit();
6 V) m1 _! {: o/ [' c: }; Y- r - cylinderBuilder1->Destroy();7 U" r8 [- i$ L5 ]5 V6 B8 w
- cylinderBuilder1 = NULL;
6 V- J/ t8 {" X% [4 b - }, F g) N% V: f1 f$ o* S+ m
- </P>
复制代码 ( c2 J6 W' ?$ b) j6 ~
|
|