|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
. ]4 A2 n% x+ O9 s3 j2 l: n
- o* W" w, c$ I, G: I- <P> </P>
复制代码- : E3 v- [6 W: C% W$ z
- <P>void CreateCylinder_UsingUDB::CreateCylinder()
' h/ E, A4 R* Y/ w5 I - {
4 x! r' b/ R8 s* D - Part* workPart(theSession->Parts()->Work());</P>
- T, H4 x% V! k5 c8 D, i' t' l3 A - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
7 u2 z3 |; o4 z% ?8 q - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>4 ?, Q8 y; P0 |% w& B
- <P>//Get the point- m4 w: F) |% _
- PropertyList* pointPropertyList = point0->GetProperties();! B& n& m+ Z" }
- Point3d originPoint = pointPropertyList->GetPoint("Point");* t/ ~( z: d+ b2 b
- delete pointPropertyList;
6 R7 i) t0 N/ b - pointPropertyList = NULL;</P>
5 q5 q8 h( t6 H# ^ - <P>//Get the direction& ^' z N; J+ {9 d9 r- Z2 V* U
- PropertyList* vectorPropertyList = vector0->GetProperties();
) v+ _& t" s! o9 }7 O - Vector3d direction = vectorPropertyList->GetVector("Vector");
8 M2 r% \! o% W/ h, E" n - delete vectorPropertyList;1 |' d# k. G: Z+ X6 ]
- vectorPropertyList = NULL;</P>3 g9 J5 j0 M5 C/ e2 k
- <P>Direction* direction1 = NULL;9 a2 v; T4 [- h, t+ y
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>* h7 Z; K/ [: I( R- }7 v4 J$ ]
- <P>//Set diameter and height7 [: G& [$ W8 f( ?
- std::stringstream diameterValue;
: M, E) t1 B# P% C8 D3 f8 d - diameterValue << diameter->GetValue();$ z5 k! S! g9 a; S- w {
- std::stringstream heightValue;
4 ?+ f8 \2 F+ b7 F; I - heightValue << height->GetValue();</P>
2 b* J, |- N. S# \; a6 r: B5 p4 D* N - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
$ [2 ~: ^5 B+ m$ y, c - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
% s, `) ~/ F! ^4 Z# v8 { - <P>//Set the axis; b$ H; {, m' z0 p
- Axis* axis1 = NULL;: y! `) Q( Q5 K' H3 x; }( Y
- axis1 = cylinderBuilder1->Axis();5 Z" K7 Q+ s" S9 N
- axis1->Point()->SeTCoordinates(originPoint);" ~- Z2 }) P" c$ v. U. i: A) c
- axis1->SetDirection(direction1);</P>
7 W: x; k) c' ] - <P>//Commit
+ b0 M* V: N6 v# ]* X5 S4 e0 @ - cylinderBuilder1->Commit();
! w# f+ P0 G- [ - cylinderBuilder1->Destroy();) N" s$ j4 X# P
- cylinderBuilder1 = NULL;
* k: |- C, u8 y8 @8 O+ h - }
& m3 E9 o; |2 D D5 { - </P>
复制代码 ! ] d6 [4 M% p7 c
|
|