|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
" Y3 i% Q7 G8 \9 Z
# D% c$ i. g( t3 H2 W* _- <P> </P>
复制代码
8 J1 Y# Z5 G& B- <P>void CreateCylinder_UsingUDB::CreateCylinder()
6 d$ c4 T# m8 ?6 P% w# E! n - {" V5 a; o G4 g1 V2 T9 z G5 H
- Part* workPart(theSession->Parts()->Work());</P>$ \9 J0 S) U/ [$ H3 t% ]0 q, G) B
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;! g5 f; h( v, F
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>5 t% {, s0 T6 r8 c& I
- <P>//Get the point+ t2 J* r/ k- E7 ?9 k
- PropertyList* pointPropertyList = point0->GetProperties();3 ^8 q' q' g. _# p2 @* q
- Point3d originPoint = pointPropertyList->GetPoint("Point");! v* ^* a P* a( h) x8 U+ I6 U6 Q# v
- delete pointPropertyList;) b7 B0 J0 w$ G
- pointPropertyList = NULL;</P>) v0 O w P- ~
- <P>//Get the direction
8 y' h: \% P9 e1 P& |, J! I - PropertyList* vectorPropertyList = vector0->GetProperties();& S* G. k& b3 O
- Vector3d direction = vectorPropertyList->GetVector("Vector");
" J4 l5 X$ ~% i. | - delete vectorPropertyList;' M; q7 {8 o7 J& w# e# F0 A: o
- vectorPropertyList = NULL;</P>
6 w/ d u, Y) \) E8 g - <P>Direction* direction1 = NULL;
# G: f8 I+ K$ g6 l! r' a2 a - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
% i2 j$ c% W* l$ W, E: q$ U# l( F - <P>//Set diameter and height( _- H4 `0 C H
- std::stringstream diameterValue;
9 o' \2 E" l6 R, \* F# [# N9 K& ? - diameterValue << diameter->GetValue();
' p3 i# T. ~6 j9 b! ?! @1 `9 L8 M - std::stringstream heightValue;
: i. o& j: J0 G3 ? - heightValue << height->GetValue();</P>
. h& g& _( L, l( C' t( Z - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
3 h" f4 \) K7 ? - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>+ h! N$ i1 B$ E7 e( C4 D/ ~
- <P>//Set the axis
, k0 Q& \# d' q$ A+ H/ r" m - Axis* axis1 = NULL;
. l3 ~! w+ x9 ?! g: c! q - axis1 = cylinderBuilder1->Axis();: d3 y9 q* q: H, z5 n5 R
- axis1->Point()->SeTCoordinates(originPoint);
0 f9 c% Z* y6 {/ Z% X - axis1->SetDirection(direction1);</P>
1 s8 b. i. P9 j+ R- ` - <P>//Commit0 H2 [, s+ ]0 X" V( b+ J# R
- cylinderBuilder1->Commit();
& x7 d2 N& s9 Z- z: `& K - cylinderBuilder1->Destroy();( p' z1 |- x: p, {5 o
- cylinderBuilder1 = NULL;4 @% _: R3 d }# [0 H$ k- w
- }
- U+ w* E( V# L - </P>
复制代码
& Z" J5 }( R6 g3 j |
|