|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
/ n, h; M1 _# `, [" j
A0 |8 K8 t3 ?" |0 k" G8 a8 e- <P> </P>
复制代码
7 i8 q5 t+ G- R- <P>void CreateCylinder_UsingUDB::CreateCylinder()
' k3 c5 c+ K& x7 |$ v+ M - {
; f" ~7 @+ [% {( q - Part* workPart(theSession->Parts()->Work());</P>
- f9 k( J/ J6 M8 p - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;/ X! Y- j! \6 E
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>* N- C" i- S5 s
- <P>//Get the point! O$ M: V! O3 }& r6 p# a
- PropertyList* pointPropertyList = point0->GetProperties();
7 c8 {! L* q6 Z( X1 G3 ?1 X7 a, G0 w+ ? - Point3d originPoint = pointPropertyList->GetPoint("Point");
# b9 ?% ]0 t! B3 U n* O. j$ c - delete pointPropertyList;+ F! W2 F6 z d% y3 w4 `! s
- pointPropertyList = NULL;</P>
7 w* Z+ Y: ^8 _3 k- {+ o - <P>//Get the direction! M$ ^: |- q- M: Y3 C
- PropertyList* vectorPropertyList = vector0->GetProperties();
( i& j) }. Q- d2 i/ {* S0 O& ` - Vector3d direction = vectorPropertyList->GetVector("Vector");
) I' [0 H7 k. Y) Y - delete vectorPropertyList;
2 s* W& L9 N( R+ L7 ~3 M - vectorPropertyList = NULL;</P>
3 u: ^) k$ P7 D1 @/ R, w+ P - <P>Direction* direction1 = NULL;; v7 }) \( z7 l
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>" ~8 B& H1 g- I8 P$ l m7 g
- <P>//Set diameter and height4 o w V0 r4 ~% s% P6 `
- std::stringstream diameterValue;; `* R+ h$ o% B% `4 Y ]2 [
- diameterValue << diameter->GetValue();
4 a2 G# b O& l$ ^ - std::stringstream heightValue;1 J4 j& e2 f2 _7 \/ J
- heightValue << height->GetValue();</P>9 i7 @& R; N' y9 f# U# t0 v
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());3 S4 k# j d# s- V+ `0 Y
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
& Z ]! G7 L! N; H - <P>//Set the axis" l/ m: ^' G4 |+ p( J
- Axis* axis1 = NULL;& j7 B2 l: P+ J' D1 Q0 G; k: O
- axis1 = cylinderBuilder1->Axis();: q$ D* v8 g1 U. t: I |) J
- axis1->Point()->SeTCoordinates(originPoint);/ h; H1 g& f3 _0 Z+ S! y
- axis1->SetDirection(direction1);</P>
1 i4 G! a/ k+ R! D - <P>//Commit! f# l8 C' s8 A l# `+ v5 F
- cylinderBuilder1->Commit();/ [# {6 [ K. ^+ q, J
- cylinderBuilder1->Destroy();
$ d) n1 z( W$ @' Y7 n - cylinderBuilder1 = NULL;4 A+ `0 }; k; H$ v
- }
. Q/ h: I# ]9 x - </P>
复制代码 1 U" \$ _, W2 ]2 h- J
|
|