|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
* n% f; s; f( Q+ l- , z# D: w6 Q2 H, O/ Z
- <P>void CreateCylinder_UsingUDB::CreateCylinder()
8 t. R& m5 X3 v6 E# g - {' o$ ~! `9 T* y4 X
- Part* workPart(theSession->Parts()->Work());</P>0 |/ J% {$ @- o3 F+ G. s
- <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;8 L& Z* n0 i3 ^6 E0 l1 | D
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>& L( U1 k/ H" J3 c3 R/ |7 v
- <P>//Get the point2 c1 ~; Y9 J7 `# M& \' e) x6 h
- PropertyList* pointPropertyList = point0->GetProperties();
, \9 }( U; |/ d; C6 P8 Q7 q* v4 V8 v - Point3d originPoint = pointPropertyList->GetPoint("Point");
8 `) S3 M, h+ ^) p - delete pointPropertyList;
+ J* ?8 ?* E$ u% i" d8 M) r. M6 E - pointPropertyList = NULL;</P>! n# `; `# s( [# _7 _
- <P>//Get the direction
% {1 J1 w* `# X/ j6 l2 Y" a - PropertyList* vectorPropertyList = vector0->GetProperties();
/ v, d2 O1 ~4 ` H - Vector3d direction = vectorPropertyList->GetVector("Vector");0 c& M0 G& V7 Q7 Z5 t7 E
- delete vectorPropertyList;
* g- U% X& [% @# f- r - vectorPropertyList = NULL;</P>2 p- X4 ~0 M# B1 I8 t* _' a
- <P>Direction* direction1 = NULL;3 D+ `/ H0 _! D+ E9 o( \( i
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
! L% f9 |. R) C: Y - <P>//Set diameter and height5 u$ d5 |7 n5 W# g
- std::stringstream diameterValue;
5 ^9 c% p7 K8 N! T" U. r - diameterValue << diameter->GetValue();
' M) y [; A3 W - std::stringstream heightValue;
' z% Z% F' F. f; [ - heightValue << height->GetValue();</P>
8 {# }" F& i3 o( |6 G; O - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());* @2 Z2 y4 Q; {# `3 q, [
- cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>3 O4 {/ w O9 ~
- <P>//Set the axis" }) B. @- m7 {& B6 y3 P m8 r) |
- Axis* axis1 = NULL;
8 i5 i+ v" T; b: f5 K/ ]6 i - axis1 = cylinderBuilder1->Axis();
, w' s1 J' z- a% G9 q - axis1->Point()->SeTCoordinates(originPoint);/ O D. \# R& Q% w3 c' m7 |+ W
- axis1->SetDirection(direction1);</P>
) G/ `; u: s9 p+ x& d - <P>//Commit5 [; p" g( R3 ^
- cylinderBuilder1->Commit();
# D q/ c6 G; j1 o ?6 L8 c# k - cylinderBuilder1->Destroy();
6 l; Z: A+ r( Y6 u2 R) ^ - cylinderBuilder1 = NULL;7 S7 e" G( w0 G) l9 e
- }5 }+ }& g) o/ n* I& `0 T" o$ N+ J
- </P>
复制代码
4 H f0 Q) ? {3 V9 M+ H |
|