|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
) x0 }' D- |! `. ?* |
/ m' N; n* ~, J5 D n- <P> </P>
复制代码- 0 o5 R6 u; k7 K; D" L* ^
- <P>void CreateCylinder_UsingUDB::CreateCylinder() v5 K1 o) h! [9 A
- {" X4 _& m+ g: J* G" r% a
- Part* workPart(theSession->Parts()->Work());</P>5 \8 w9 ?) D7 l/ N8 k7 f1 U- X
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;6 ?" P( n F# i* y* E
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>$ R- c9 g" Z* `, V0 ]9 i, i/ b w" ~$ Z
- <P>//Get the point4 s; m; @3 G$ C5 ~
- PropertyList* pointPropertyList = point0->GetProperties();
2 Q' k* e- p) p2 C- K$ j B' ?# g4 Q - Point3d originPoint = pointPropertyList->GetPoint("Point");
4 _9 n+ I' X' ?; A( `6 w$ X/ p& t- J - delete pointPropertyList;5 l, s) K1 s4 L
- pointPropertyList = NULL;</P>! A& V1 L7 O9 N( o* E, {
- <P>//Get the direction
U- X) h0 R# q) O5 H! @ - PropertyList* vectorPropertyList = vector0->GetProperties();
: p) c5 Z2 F8 a! _ - Vector3d direction = vectorPropertyList->GetVector("Vector");
6 Z0 e; Y7 z+ { - delete vectorPropertyList;
7 c3 |! J, t) o9 s# P - vectorPropertyList = NULL;</P>
! h5 L S! ` M- e- [7 ` - <P>Direction* direction1 = NULL; X+ c& p4 k" Y
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>+ ^/ C% P. R! `$ C$ \
- <P>//Set diameter and height8 ]; I0 p7 K4 A. @
- std::stringstream diameterValue;) @5 y0 ^# W' z7 ?' X. u- r
- diameterValue << diameter->GetValue();
- n' O1 @: \. Y - std::stringstream heightValue;) N) v7 v F0 Z% W( M* Z# z$ A
- heightValue << height->GetValue();</P>
1 \, e0 |: o+ k$ ~! T - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());) n3 o8 f0 c; M( r" t' u0 b: |6 f$ b
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>9 Z6 e- p$ x- u, I; Q2 I
- <P>//Set the axis( m- x& E# s6 B- i
- Axis* axis1 = NULL;) ]) j; U ~! w# n, Q/ k
- axis1 = cylinderBuilder1->Axis();
. R) I' V( i) Q# X. \ - axis1->Point()->SeTCoordinates(originPoint);
: W/ I$ t& ?' G8 k* Y$ g - axis1->SetDirection(direction1);</P>* i c+ v8 y1 i( s! x* H
- <P>//Commit
& K' n" R% |5 Q0 s - cylinderBuilder1->Commit();0 @* K! X; A% A# N. J4 Y# G
- cylinderBuilder1->Destroy();' L" w. N( \7 P+ l0 i' |" N! d
- cylinderBuilder1 = NULL;
1 [7 \. A1 f- t8 s! j! z - }
" i8 | k' [# s3 b - </P>
复制代码
2 r( L1 N/ P, j% V+ z* C |
|