|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
6 A( U) |8 W5 K8 F- ) @1 p1 G9 i" `, C
- <P> </P>
复制代码
' U7 d! H+ u6 v8 |; b; y- <P>void CreateCylinder_UsingUDB::CreateCylinder()
/ B( v% _, H' f0 c0 f) p" v - {7 U$ |4 D, L9 ~! {/ ~! e8 y
- Part* workPart(theSession->Parts()->Work());</P>, w3 C6 d. R% } H: \+ f
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
1 q9 q- ]+ G* c" C$ c# N* Z - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>/ r. `7 ~% p- t. F
- <P>//Get the point; t$ o! d6 P+ ~$ S5 I7 ?. G8 x" h
- PropertyList* pointPropertyList = point0->GetProperties();+ b) F5 Y' x) c3 y, s; G- C' T# B
- Point3d originPoint = pointPropertyList->GetPoint("Point");5 D: Q. }. Q2 }$ L1 S, v* o% M
- delete pointPropertyList;: ?/ w* S6 B, ~( \5 j X* U5 f5 _
- pointPropertyList = NULL;</P>3 c+ i0 I$ K1 r( S3 g& f$ ` s
- <P>//Get the direction
9 w! q+ S0 b; g3 K - PropertyList* vectorPropertyList = vector0->GetProperties();
' M3 k' \# V# t" B( b9 j" Q: \ - Vector3d direction = vectorPropertyList->GetVector("Vector");2 i; s* G8 o3 M1 q* Q
- delete vectorPropertyList;; w6 f# o6 {+ b/ ]: p0 O" | I/ H, F
- vectorPropertyList = NULL;</P>$ N* h' V$ @: M0 A6 C
- <P>Direction* direction1 = NULL;7 R3 D( N2 d4 z8 o, _+ H
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
1 [( u& M$ k9 C) Q G# c - <P>//Set diameter and height' w8 X0 g1 Q# R4 j3 I0 \: m# m# q) }0 ^
- std::stringstream diameterValue;
Y- d; r& k; V# s; T" b# U: j - diameterValue << diameter->GetValue(); N' u* }. L9 p; Y+ U
- std::stringstream heightValue;
- F& N" q L0 | - heightValue << height->GetValue();</P>7 T; p! E) E3 b
- <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());- h/ o4 d& a/ G5 w3 I
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>% P3 R8 a: M5 V$ Z4 }! R. W
- <P>//Set the axis0 o5 g8 T) w9 O; b6 |5 M a
- Axis* axis1 = NULL;* C% Q. w2 T+ t& W1 \7 a/ T; I
- axis1 = cylinderBuilder1->Axis();
) r4 W5 L9 Z' H - axis1->Point()->SeTCoordinates(originPoint);% M* r& O" \+ ]: f2 ~0 \4 O! I
- axis1->SetDirection(direction1);</P>
! w" z9 f5 ^* ?$ ]" F5 k2 f - <P>//Commit
, I( r& }+ _/ |, Q9 O" g/ y - cylinderBuilder1->Commit();) I: u2 ?. {9 _7 u
- cylinderBuilder1->Destroy();
+ q z0 m9 y# f! n! {# S" x8 W - cylinderBuilder1 = NULL;; V1 t1 D! a5 o5 J. f9 r9 L
- }+ T9 m; @1 m2 B( u4 I9 o% I' Y
- </P>
复制代码
7 N# ?3 t; U9 y/ n; B |
|