|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX二次开发源码分享:NXOpen C++创建圆柱体特征& j& z# A, q2 M% m- p* o6 ?: _; c
- ) n9 I4 O# n+ I: X/ P6 X
- <P> </P>
复制代码- - F; w6 m3 }5 g# }$ g
- <P>void CreateCylinder_UsingUDB::CreateCylinder()2 W$ [0 A4 ^) d
- {0 e& i- `9 Z* O% {/ Y
- Part* workPart(theSession->Parts()->Work());</P>
4 ]( o1 [& ]6 q! j" `+ B - <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;* y( g. q `$ x$ P8 S
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>% g, l0 J5 K+ R6 X1 e( d
- <P>//Get the point
0 @: z( p9 y" w+ @3 ]7 G - PropertyList* pointPropertyList = point0->GetProperties();
, M1 N0 [+ g; C; L3 k8 u - Point3d originPoint = pointPropertyList->GetPoint("Point");
& O3 T) w+ y: m: G - delete pointPropertyList;* D+ {, G3 \( m
- pointPropertyList = NULL;</P>
5 U! G/ M: k/ k. q - <P>//Get the direction
8 i+ `$ N$ [4 y - PropertyList* vectorPropertyList = vector0->GetProperties();
4 h8 a2 A6 Z( R5 ] - Vector3d direction = vectorPropertyList->GetVector("Vector");- x7 |0 b8 G& b3 E% p
- delete vectorPropertyList;
/ T. a5 g6 ?* g" S$ j - vectorPropertyList = NULL;</P>& q5 @. ]' I: C1 p% |1 ?
- <P>Direction* direction1 = NULL;/ N, U+ Q1 y0 ?1 b# b- ]
- direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
% g1 z) z% Y& _2 h - <P>//Set diameter and height
, _, W" v# Z- N$ V" o9 w( [% n, q - std::stringstream diameterValue;
8 B5 G- s# a* v) l+ k+ X1 Q1 [ - diameterValue << diameter->GetValue();
% l: r* H9 X/ F; N' g - std::stringstream heightValue;
" q7 t) X8 H4 M( P - heightValue << height->GetValue();</P>
& X* T7 |6 m3 d3 v4 _# ^: h3 E - <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
2 m6 b8 y H3 y$ m& e J - cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
5 n; g+ L0 }8 \0 z8 G% P - <P>//Set the axis. I- F9 H( r! G
- Axis* axis1 = NULL;
& z( P! ?4 A' u - axis1 = cylinderBuilder1->Axis();7 \/ i9 r9 I, {
- axis1->Point()->SeTCoordinates(originPoint);
8 U6 v: K' ? \. \5 d6 [ - axis1->SetDirection(direction1);</P>& E: A Y$ j, i
- <P>//Commit( {5 w- Q, a6 G, f/ a* K6 f+ e' W
- cylinderBuilder1->Commit();" ^6 H! a/ j. z0 Y0 v! x
- cylinderBuilder1->Destroy();
. m, X, [7 o: d* Q/ Z - cylinderBuilder1 = NULL;
# ^& E0 p! _5 t7 |) i - }( g) ?+ Q$ t3 g; j* P1 x6 A7 \4 t+ Y
- </P>
复制代码 " Z1 r, O# T2 C7 k8 c
|
|