|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
, R0 O+ r! f0 [) l- 9 o' M- I! s; `2 K# U1 ^& Y
- <P> </P>
复制代码- 0 a3 H* g( M1 w5 w- l4 H
- <P>void CreateCylinder_UsingUDB::CreateCylinder()! u* L8 D9 v2 `- Q. R2 V
- {
; K9 k) N+ f" Y/ K0 m4 C! ] - Part* workPart(theSession->Parts()->Work());</P>
) F }4 \2 M# s A9 {/ x; F - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
_" Q1 V- |/ x. ^ - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>, K% f9 D* u% E) c
- <P>//Get the point
: L" d4 t" V, A' G- a - PropertyList* pointPropertyList = point0->GetProperties();
2 e4 I" n6 h; J- A% y - Point3d originPoint = pointPropertyList->GetPoint("Point");; m# p: Z5 ]' L& k( w- E- a
- delete pointPropertyList;7 C3 r8 u( D- e6 H) d
- pointPropertyList = NULL;</P>$ @4 P# G4 O/ }# P7 V; t/ o+ ^% I
- <P>//Get the direction
4 j8 t' N2 g7 H" q- l' h - PropertyList* vectorPropertyList = vector0->GetProperties();9 o% [; ~, l7 [# K* S; J3 V
- Vector3d direction = vectorPropertyList->GetVector("Vector");/ G8 C- `) w* p
- delete vectorPropertyList;/ ~8 s! f: b8 x3 F8 Y- C
- vectorPropertyList = NULL;</P>) M- K* D8 B$ y
- <P>Direction* direction1 = NULL;' N v% l' g+ n
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>! t2 D9 a5 p8 g# |
- <P>//Set diameter and height
0 _3 H5 E0 ~6 V* M - std::stringstream diameterValue;
% C7 @! W% t: x! r( ~7 e9 D0 z - diameterValue << diameter->GetValue();
. A: H9 ^. Z. R4 C; S2 ]0 h - std::stringstream heightValue;
& i( }& {* j6 X$ _0 x - heightValue << height->GetValue();</P>
, L9 J* \& |9 W9 |8 j - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
3 D7 C2 o3 n1 b* F, l v - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
V( t' `0 }6 O3 G( A" [8 S - <P>//Set the axis' |3 z# _6 } L1 c" A7 F* h
- Axis* axis1 = NULL;7 v# P3 n* K9 q$ O8 E- B2 r
- axis1 = cylinderBuilder1->Axis();
0 C* \# w1 q3 J - axis1->Point()->SeTCoordinates(originPoint);! |2 W" G& n* ?: a- J& ~1 Y. @
- axis1->SetDirection(direction1);</P> @# y& e. j) p* Z; I
- <P>//Commit3 |6 K; v/ F9 Q4 ^) v" T
- cylinderBuilder1->Commit();: [- P; V) ]# _. W1 m- b
- cylinderBuilder1->Destroy();
# L2 K9 e0 e3 ]5 G' Y: c/ b' D - cylinderBuilder1 = NULL;
% Z& J7 l$ G+ X2 O! f5 B- a - }" x5 g- L- ] f: G4 f
- </P>
复制代码 ) B$ I. l4 W% S; ^+ h
|
|