|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
7 v; k+ c" l& @" ^6 |5 v) W5 x- 7 v" t' p" g0 Q* e' u; U7 o
- <P>void CreateCylinder_UsingUDB::CreateCylinder()
" E* r4 B* E5 G7 Q, S - {
% v0 l$ H4 {$ G# n( \) S - Part* workPart(theSession->Parts()->Work());</P>
1 U1 N: j. X! f/ ] a8 W/ E0 K - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL; k' C9 y# D5 @! @6 C
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
# h3 ]5 g, |5 }: z3 X9 N - <P>//Get the point# p* ]/ f; L$ S7 \+ ?
- PropertyList* pointPropertyList = point0->GetProperties();
1 K4 n# g# C6 v2 `; P - Point3d originPoint = pointPropertyList->GetPoint("Point");
/ T+ {. `) n6 P& Q6 J+ E - delete pointPropertyList;4 }6 `2 L9 {5 \( {4 Q
- pointPropertyList = NULL;</P>
+ K+ p- @; U" P: P - <P>//Get the direction
R& m5 @4 ^! l - PropertyList* vectorPropertyList = vector0->GetProperties();; Y/ i: X2 S: V' T" R
- Vector3d direction = vectorPropertyList->GetVector("Vector");
0 ?1 B/ n/ T+ g) r& w - delete vectorPropertyList;1 H* s ?/ s, |* c$ K+ k- t9 Q
- vectorPropertyList = NULL;</P>( v$ M4 k9 G1 Y* p5 v, d
- <P>Direction* direction1 = NULL;
" S, m" t0 m3 b! \ - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>7 n4 k' c4 c6 q( v# G2 }
- <P>//Set diameter and height
8 `3 V- g, B, k* L V% a7 ] - std::stringstream diameterValue;5 ?1 y/ a# G: i0 b0 }, j
- diameterValue << diameter->GetValue();
, P8 b4 ]9 T& \9 T" J& t - std::stringstream heightValue;% H2 t! k2 {- [3 t" u& M5 _
- heightValue << height->GetValue();</P>
8 r0 R9 ?; m+ s9 u ]! T - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());# ], L9 c4 p, F) \3 R2 `; h) ]: r
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
1 h7 O+ a( f9 M$ l& g/ f6 _/ I - <P>//Set the axis5 r/ b* V7 K; t |
- Axis* axis1 = NULL;+ w! }) L7 n1 H0 @
- axis1 = cylinderBuilder1->Axis();
& h8 ]) _! c3 T( q' c- J% U - axis1->Point()->SeTCoordinates(originPoint);/ N( M; S0 F1 ^' p. |& V
- axis1->SetDirection(direction1);</P>3 Y- [4 K( m0 V5 |
- <P>//Commit
( j- S+ A! @# u% I0 T& o - cylinderBuilder1->Commit();4 T3 ?2 }+ I6 q9 j+ \4 E, @
- cylinderBuilder1->Destroy();
0 d: F/ y7 G/ H+ f. E% Q' t - cylinderBuilder1 = NULL;% ]" u3 L) l* {0 o! x# k
- }
2 w% l& r3 L/ E [$ s4 s* r' q: L - </P>
复制代码 + W! R' X W* e( l# j
|
|