|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
3 k& A8 K% T( t( E5 G- 8 k" |4 h2 T4 }1 C' k
- <P> </P>
复制代码
2 F- |! I& B- k s- <P>void CreateCylinder_UsingUDB::CreateCylinder()! k7 e- c$ p9 Y5 R! {4 x1 ~; F
- {% U4 z8 a3 C8 G) T+ ~* k
- Part* workPart(theSession->Parts()->Work());</P>- }# b' {$ \. e1 j* C @
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;% T' W6 ?/ q+ H% Y
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
. \3 M1 i! `# E; I7 S6 d& Q7 z - <P>//Get the point7 } m, q6 a+ x; Z% ?
- PropertyList* pointPropertyList = point0->GetProperties();
8 i/ Q# F2 b3 G* \/ I# t0 Q - Point3d originPoint = pointPropertyList->GetPoint("Point");, r0 @/ {# Y+ J \% `, C) B
- delete pointPropertyList;3 B3 r3 C; u0 W, F( T1 i6 O* Q. b
- pointPropertyList = NULL;</P>* [2 w6 N' N; H9 ]$ r/ P
- <P>//Get the direction! f3 {" M# z- }3 ~/ F
- PropertyList* vectorPropertyList = vector0->GetProperties();
" y5 p. U: t; M0 X& M+ b - Vector3d direction = vectorPropertyList->GetVector("Vector");
5 T9 ~- s" t6 B! Y - delete vectorPropertyList;
! }# U& f! P2 k1 V8 k - vectorPropertyList = NULL;</P>
' o0 T& ]6 l# ?5 H* b1 e F - <P>Direction* direction1 = NULL;2 J$ A* t. P7 y% W; U
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>3 C( }( I9 U; U8 j- T3 l' R) X+ [
- <P>//Set diameter and height
; P- ^$ u, n; A1 ]- i- c - std::stringstream diameterValue;
$ c1 @+ X7 O9 P/ s/ |, d - diameterValue << diameter->GetValue();, h! J9 c1 Q+ L& r
- std::stringstream heightValue;
' k/ E w% ~3 V - heightValue << height->GetValue();</P>
7 E' h4 b( F$ k- G+ G0 I4 G - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());- S& f, ^$ V: f! e
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
; H2 u0 o" e# u# p - <P>//Set the axis
( u# M7 ~. X5 M5 q: X - Axis* axis1 = NULL;
0 P5 P, b! f3 R8 E - axis1 = cylinderBuilder1->Axis();- J( W4 K/ B3 t2 {3 C$ x
- axis1->Point()->SeTCoordinates(originPoint);, k8 A1 V$ i* h; L
- axis1->SetDirection(direction1);</P>) l! Z' y( q: I% P0 d2 b
- <P>//Commit
2 Y, R# q/ C' R: u( N - cylinderBuilder1->Commit();& d. @9 F; K4 y( P
- cylinderBuilder1->Destroy();
* X8 Z. T% {9 T/ k0 s8 C - cylinderBuilder1 = NULL;8 f G; ~( `1 Y6 @3 n
- }$ N: L6 u; W' j3 H5 W
- </P>
复制代码
% o( Y6 R1 G1 L5 b |
|