|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
/ O) h* n$ Y6 z; D0 R. y2 f% v
【PLM之家-NX9.0二次开发实例视频】17 Block UI创建圆柱体特征
Block Styler创建圆柱体
% `8 D( B- q& Y! q 6 x* k0 D6 J7 K
本视频主要讲解,圆柱体的特征创建,以及使用Block UI中的点,矢量构造器进行获取用户的输入,通过使用表达式控件获取圆柱体的直径和高度值,从而创建一个圆柱体的过程!' W6 D" n6 }5 B; B
5 ]; j* H K' R3 |- `6 Y
视频中设计到控件的使用,赋值,对话框UI的创建。
" k) J' \+ ^5 v+ d L特征的创建方法基本上相同,通常情况下,创建一个空的特征,构建一个featuresbuilder,通过这个featurebuilder进行相关值的指定,最后通过commit进行特征或者对象的创建!
0 v; T; W$ e1 Y8 B
/ T; K( k9 o7 `4 ]1 U视频分三部分:
`/ `& K$ d0 }& M
7 H; V& p& T' w# b4 l4 l# x' i/ Y0 K* M! C/ a& ^
# R, h7 k! G9 ^5 _# _, DPLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(1)对话框设计
7 l" V g$ c- B8 ?( L, H3 Z8 ^PLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(2)获取UI值& a/ |$ J4 m# B5 l: J1 o
PLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(3)程序创建完成8 U4 r7 ^# ]5 e. }9 g
9 y& R0 K0 w+ b2 L. G关键代码分享:8 N4 r5 b+ M7 a& x2 f2 [
9 d' {- B5 y" S$ P, A9 J! v: I5 [
- <p>5 `3 U4 W1 I, x
- //get the UI values;( {' b2 y6 ^3 h) Y' P
- NXString diameterString,heightString;
' H* Q6 q4 A! _, h( \2 [7 Z6 Q5 W - std::stringstream ssdia,ssheight;
6 a3 \% E1 w+ S# G+ j7 @ - // get vector . {: J. ~+ ]" x' A/ ^ h! t, B
- BlockStyler::PropertyList *vectorProperty = vector0->GetProperties();6 t- c# I6 q7 e. v1 d
- Vector3d vec = vectorProperty->GetVector("Vector");
) L# e/ U- p- I/ H% \, z( H2 Z7 j - delete vectorProperty;" Y4 e. o" E6 B5 W1 I3 @
- vectorProperty = NULL;</p><p> // get point
5 @* ?! C; j' l ~4 q - BlockStyler::PropertyList *pointProperty = point0->GetProperties();
0 L9 r2 @( p+ m7 f6 t7 x- P* H, F, ^ - Point3d point = pointProperty->GetPoint("Point");
( f2 x! W5 h) K& v1 t6 f - delete pointProperty;1 D* w6 z6 N/ c, g; y
- pointProperty = NULL;</p><p> // get diameter4 C. ?" e% y( W9 a) `
- BlockStyler::PropertyList *diaProperty = expressionDia->GetProperties();8 t2 u# ?+ J6 B+ m
- double dia = diaProperty->GetDouble("Value");0 M- u o) N* F% q- m
- delete diaProperty;
5 }% ~, Z8 X' Q6 ]2 l' t( D - diaProperty = NULL;</p><p>, A* U6 Q, Y% G9 q& u* C
- //get height</p><p> BlockStyler::PropertyList *hProperty = expressionH->GetProperties();3 r) m* T6 g" t$ ^0 h
- double height = hProperty->GetDouble("Value");! S! n) z( f$ D- S e; G/ M( h
- delete hProperty;+ Z& K& {7 r; Q2 j
- hProperty = NULL;</p><p> //convert values to string
7 D7 {' M5 s- i ]2 D ~: S - ssdia << dia;7 T2 |6 r5 L; X$ w3 A
- diameterString = ssdia.str();</p><p> ssheight << dia;
$ M) w* q$ C# Z# l1 j8 E7 @, ] - heightString = ssdia.str();</p><p> //create cylinder feature;</p><p>
! v5 C2 A7 {2 u. N$ g+ x2 Q" o. u7 S - Part *workPart(theSession->Parts()->Work());
" ^' O$ W3 a. a i& K - Part *displayPart(theSession->Parts()->Display());</p><p> Features::Feature *nullFeatures_Feature(NULL);
3 r6 j& n) m B9 q G3 | - ) z: Y+ Q* A8 P N) d( T) ~! J
- Features::CylinderBuilder *cylinderBuilder1;$ J" O P# V; u2 c: `4 L
- cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(nullFeatures_Feature);</p><p> cylinderBuilder1->Diameter()->SetRightHandSide(diameterString);
1 J- w% g$ x* V% U" a- N) V3 f - cylinderBuilder1->Height()->SetRightHandSide(heightString);
4 P* W( r5 V& N1 r3 F - cylinderBuilder1->SetDirection(vec);9 L" r# H4 i$ p9 X
- cylinderBuilder1->SetOrigin(point);</p><p> cylinderBuilder1->CommitFeature();8 H4 K( _ H' }! @4 Y$ f2 |
- cylinderBuilder1->Destroy();
) h7 l- ?& z# W- s0 g6 V9 H - </p>
复制代码 ) `* y0 _& }( m
高清教程见楼下.3 O+ t& `% |6 B* {2 }
0 ~) Y: H9 c- Y a8 u |
|