|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征( _! R; t) O' q: V* R
- 7 r/ Y! b+ J% @) ~# f
- <P> </P>
复制代码
# r$ [) J! M+ D- <P>void CreateCylinder_UsingUDB::CreateCylinder()# ~9 U: `& B+ r* r- a% o& M$ c
- {
5 _4 a' k' h$ N% L$ v - Part* workPart(theSession->Parts()->Work());</P>
* N" H0 B* r6 c - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
. m! t6 A( E1 B5 v - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P># ^& M1 L* h. t
- <P>//Get the point
0 Q/ x6 O! S3 _5 q [6 w - PropertyList* pointPropertyList = point0->GetProperties();$ j7 k# F! N+ P5 ?
- Point3d originPoint = pointPropertyList->GetPoint("Point");
T3 q! X) j0 i, [' A - delete pointPropertyList;! v4 g7 W. j( j; E. L; ?4 O. N
- pointPropertyList = NULL;</P>
* _8 P3 b$ a7 ^ - <P>//Get the direction. w6 M6 h. L: k# p9 c% o! p
- PropertyList* vectorPropertyList = vector0->GetProperties();) b; c# U; A" f7 w3 I U
- Vector3d direction = vectorPropertyList->GetVector("Vector");
" }- X( C0 _# m1 |2 c0 @) e, B - delete vectorPropertyList;3 @% B& I$ V2 |$ a5 l
- vectorPropertyList = NULL;</P>
7 z* y; z. d( W# m/ T! Z - <P>Direction* direction1 = NULL;
3 r4 w& C- R0 q7 G: i9 ~ T& F - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
0 D" M0 I! K8 k6 M+ g# G - <P>//Set diameter and height' d/ v0 V! v( e1 B
- std::stringstream diameterValue;3 s& f v7 ~1 B' x4 c7 o( i, G
- diameterValue << diameter->GetValue();5 f3 f! p& ` C( u- F7 G
- std::stringstream heightValue;
, `% T$ | x0 g6 d - heightValue << height->GetValue();</P>7 W: v2 k1 Q* {, S; p: \
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());+ |: h& ^. ?# C$ | p
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
$ @0 ?% t/ P1 s% K - <P>//Set the axis" n& _0 r D1 k% ]$ }- ]+ y
- Axis* axis1 = NULL;, W! d: p' G! `2 v3 e
- axis1 = cylinderBuilder1->Axis();1 N/ L2 U) f/ A5 ]
- axis1->Point()->SeTCoordinates(originPoint);. s% R; G' S W! E
- axis1->SetDirection(direction1);</P>
% L2 q1 m. q4 O5 q. V - <P>//Commit
l* [, D& N+ I) `& g N0 |: x9 z - cylinderBuilder1->Commit();
( t6 ?3 r1 h1 q4 w - cylinderBuilder1->Destroy();
7 j* [) Q- g# y6 h5 a" o" A - cylinderBuilder1 = NULL;
1 d* @/ ^ n0 g1 |* y- k - }
8 a5 L# _0 R4 o& z6 Z - </P>
复制代码
L( V' `% n% R, T |
|