|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征# n$ @1 B. W& y4 h8 t* c
- # b2 n* J+ v. ]7 ~5 A |( v7 M
- <P> </P>
复制代码
/ d- h4 t* w$ \- <P>void CreateCylinder_UsingUDB::CreateCylinder()
, X1 Q, @3 h G; W( n+ d - {
1 c, D7 b( z" @; m9 l- S - Part* workPart(theSession->Parts()->Work());</P>' P5 z7 Y2 p% E1 n6 M7 b
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;2 y8 J, q& }/ k* I/ T5 `1 V( [: ^* K
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>/ ^. X( B$ l- B$ D" Y
- <P>//Get the point
" q: a4 i X3 W: L' g9 H# N - PropertyList* pointPropertyList = point0->GetProperties();5 c0 i8 Q$ s" k3 x @& O2 Y
- Point3d originPoint = pointPropertyList->GetPoint("Point");
6 Y1 T7 r# r" _: E! B% \; a - delete pointPropertyList;
* `2 B5 Y% c _( T; C9 \ - pointPropertyList = NULL;</P>+ Q+ _; E+ c7 l# ?/ I+ K
- <P>//Get the direction4 B( P6 y( M: b$ J
- PropertyList* vectorPropertyList = vector0->GetProperties();
4 Z! C2 \# C6 x - Vector3d direction = vectorPropertyList->GetVector("Vector");$ h$ \0 K6 V, _2 D1 X' t! m3 r
- delete vectorPropertyList;+ J8 a! z! P( l1 l2 E
- vectorPropertyList = NULL;</P>
7 |; u) l5 r f& p3 G5 g - <P>Direction* direction1 = NULL;7 H, F+ ]0 i0 r, m2 R P
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>4 M9 p0 A2 M5 T/ ^" n# U
- <P>//Set diameter and height
! M2 w, M+ b2 H8 L - std::stringstream diameterValue;4 R: e. _+ x* {1 y$ f0 \5 k
- diameterValue << diameter->GetValue();& ^6 y6 ~5 I. L
- std::stringstream heightValue;+ U( L: l$ ~+ \# d$ t
- heightValue << height->GetValue();</P>
) D* w2 `/ |1 u" g - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());# n* M; ~4 B O- X* F1 _) h
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
5 U! a* @) h8 Q- T5 |- ~ - <P>//Set the axis
! J8 S7 y" N! W( @* M6 b- z - Axis* axis1 = NULL;
" L" F, W; _/ u' r' e: Y% L - axis1 = cylinderBuilder1->Axis(); j n$ V+ _/ Y* ~
- axis1->Point()->SeTCoordinates(originPoint);$ K) |7 s U0 } Y% X" ^4 B* O
- axis1->SetDirection(direction1);</P>
, X+ I/ Y5 B* Y9 D' `$ S2 N% k - <P>//Commit
! z7 e$ t/ i4 S" J' B- @, m - cylinderBuilder1->Commit();) L+ j: [9 [0 v7 e" i
- cylinderBuilder1->Destroy();% g2 D( a7 t. m4 B
- cylinderBuilder1 = NULL;7 f/ [+ C2 L) t) q
- }
+ X1 `% M8 @. r4 o" v2 w T% ~ - </P>
复制代码
/ z- S# f6 m" T; Z |
|