|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
7 h" k9 |) Z" E; p, ]2 G$ N U
4 g# D& g4 Q. _1 d1 p- <P> </P>
复制代码- 9 ~+ n) B/ Y/ u
- <P>void CreateCylinder_UsingUDB::CreateCylinder()
1 F3 C1 w' s5 i3 ] ^ - {
8 z6 }% {0 w3 }0 p5 E x - Part* workPart(theSession->Parts()->Work());</P>
* m: x" y; j: M# W/ O- Q - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;, V, K, G+ F2 W7 a$ w
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>- `. v( G4 o& T; |6 u7 N5 `
- <P>//Get the point
+ R! C1 v6 m. k' H( j4 }0 H- n! @- _ - PropertyList* pointPropertyList = point0->GetProperties();3 O& P; i, y7 @% U# x4 D0 `
- Point3d originPoint = pointPropertyList->GetPoint("Point"); V5 a% z0 a8 n5 j! L/ G+ ]0 y
- delete pointPropertyList;
5 ^% m6 A1 J8 Y3 d8 q- I - pointPropertyList = NULL;</P>
/ A" I* z6 `, [# M6 R - <P>//Get the direction
9 x2 R: P$ N8 V, B* J9 w* t - PropertyList* vectorPropertyList = vector0->GetProperties();& T9 R" f% j8 L; I0 J
- Vector3d direction = vectorPropertyList->GetVector("Vector");7 P$ R5 m6 o- p) D5 p
- delete vectorPropertyList;* s" ~; N& z4 c2 M" |
- vectorPropertyList = NULL;</P>9 s/ J) X& O, V$ p% c4 A% u
- <P>Direction* direction1 = NULL;
) w) c( b1 s6 Z9 N% ^4 N - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P> ~' Q/ c7 C7 ~# K. Y! o: R- J2 Y
- <P>//Set diameter and height1 U3 J$ l0 y8 F
- std::stringstream diameterValue;
: o1 A ~5 A, x+ ]$ r$ C - diameterValue << diameter->GetValue();
5 O8 Z! [% g: S2 w - std::stringstream heightValue;8 i2 W0 e$ B* n
- heightValue << height->GetValue();</P>
1 O! S& I6 }) g; q+ `4 t4 } - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
0 T; l1 E( V: g6 y/ y0 a - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
7 o3 i3 y7 y! h: K, g. l0 x' L* X* @ j - <P>//Set the axis3 w( `8 L+ W; Q$ E# F' G
- Axis* axis1 = NULL;. E4 ~9 b) X+ r% u3 L
- axis1 = cylinderBuilder1->Axis();2 J3 i" U! a9 x) ]
- axis1->Point()->SeTCoordinates(originPoint);: {# ?7 c" Z g
- axis1->SetDirection(direction1);</P>8 r( v8 o, a# ?4 v5 {" p! Q2 ~
- <P>//Commit8 c/ i3 M$ _& }+ {4 H- L
- cylinderBuilder1->Commit();* {" p4 X3 [: K0 |8 @7 i
- cylinderBuilder1->Destroy();9 Z- O: C% o' n4 u) @/ |- [' M5 H. u
- cylinderBuilder1 = NULL;& K4 ?2 I8 [; K8 V+ D( {% f1 B
- }
- x; L0 @# m! ], u9 m5 ^2 z - </P>
复制代码 " S& E$ H# a* K) i) @+ i
|
|