|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
4 s+ a; |( ?1 O- U/ d, e- 9 |3 u' X* c8 A- W
- <P> </P>
复制代码
6 ?4 d5 x" V. H4 V+ s3 v' w3 b$ `- <P>void CreateCylinder_UsingUDB::CreateCylinder()# v5 {" A6 P* N% }- i' X; V# J
- {
- i! Y9 S( J: L4 c g& u - Part* workPart(theSession->Parts()->Work());</P>
; h8 ~# ?, a3 M3 X- G - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;6 Y3 U f( i# ~7 f. T) Y5 x
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>; p6 t$ W, B p7 ^; Q# o: @' M
- <P>//Get the point! Q% E- V4 U) O- Q; U- O( O% L/ @- J
- PropertyList* pointPropertyList = point0->GetProperties();- F9 L1 X8 Q/ X
- Point3d originPoint = pointPropertyList->GetPoint("Point");
: }) H8 Z; I) d& `; D$ P - delete pointPropertyList;. }9 W5 O2 j) [4 M3 ~
- pointPropertyList = NULL;</P>" W# I" v8 K/ Q1 C' p3 G& g( R
- <P>//Get the direction0 e& r' v& [2 B2 `" h
- PropertyList* vectorPropertyList = vector0->GetProperties();+ m( a3 A' u9 o
- Vector3d direction = vectorPropertyList->GetVector("Vector");
- A" X; l1 Q, t$ V. h0 G$ V - delete vectorPropertyList;
3 `* q6 c0 J6 l# B- ~/ [ - vectorPropertyList = NULL;</P>5 k" G5 a# f) X& I& q
- <P>Direction* direction1 = NULL;
3 l" O( w6 X2 A: U y - direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>* d4 E6 k- `5 }! O$ O( f
- <P>//Set diameter and height
) t& {. j$ |3 C7 @8 u" g* J3 y - std::stringstream diameterValue;" l$ o, a6 J7 B) K3 d8 D' W" z) _
- diameterValue << diameter->GetValue();
* {$ l8 _2 a z& }+ n7 C6 s3 I - std::stringstream heightValue;
7 F. F$ C# b- _1 @ - heightValue << height->GetValue();</P>
8 k& l! y) w/ B+ ] - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());- n1 w$ b9 @1 j+ }+ {2 t
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
% I- G7 K' T6 a6 a! E! x - <P>//Set the axis% ^. f! `3 K9 ~$ Q% @, J2 `' w1 ~
- Axis* axis1 = NULL;4 T) u% l5 ~7 |, I% l! J
- axis1 = cylinderBuilder1->Axis();: f7 B6 \6 i2 Q& {
- axis1->Point()->SeTCoordinates(originPoint);. g5 M7 T) D/ T/ }$ t* L' F
- axis1->SetDirection(direction1);</P>$ Q2 b; b6 G9 n" v. G& F
- <P>//Commit
; Q% s0 b) M: b3 o& _ - cylinderBuilder1->Commit();) M" I" M- Z& o1 K
- cylinderBuilder1->Destroy();: A8 d+ S. l- }
- cylinderBuilder1 = NULL;' X+ i9 R. o/ ?* z! @; t
- }
& n% b s# @4 z q% j& s. i - </P>
复制代码 % l+ z9 }1 s! \% `& O6 E. i& z
|
|