|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
$ C) r( c; T" Y3 V【PLM之家-NX9.0二次开发实例视频】17 Block UI创建圆柱体特征
Block Styler创建圆柱体
4 H; A( A1 {! v
: J" [9 e* Z, ?本视频主要讲解,圆柱体的特征创建,以及使用Block UI中的点,矢量构造器进行获取用户的输入,通过使用表达式控件获取圆柱体的直径和高度值,从而创建一个圆柱体的过程!
' J- e$ l3 e6 O. `; P 1 P2 L5 ^0 A& L+ ]0 v( w4 b+ n
视频中设计到控件的使用,赋值,对话框UI的创建。( U% ^6 c% ]) G* V! z
特征的创建方法基本上相同,通常情况下,创建一个空的特征,构建一个featuresbuilder,通过这个featurebuilder进行相关值的指定,最后通过commit进行特征或者对象的创建!& h! I) l& X5 P, G
4 {5 F, x: x: S: Q5 x- R视频分三部分:
8 I7 ^8 y+ l/ `; l" w0 C7 G2 P% L, A
) ^( W9 J* Z/ O7 O# R3 z* M& x! c \' D' \2 \
; B* H3 r+ P8 x h, N
PLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(1)对话框设计" e. ?$ Y6 S( |0 ?- u
PLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(2)获取UI值
* F- { n j( Q% |5 a8 FPLM之家-NX9.0二次开发实例 17 Block UI创建圆柱体特征(3)程序创建完成
5 p* P( z6 e: X& x+ i/ B/ k' K- l
关键代码分享:
& j4 X' i9 l7 B, \/ w P
5 v1 A* g$ l. t5 h- <p>
q- n, T6 w% Z! U8 q) I - //get the UI values;. W2 U3 |. G: [8 e( w
- NXString diameterString,heightString;
9 J8 T: g8 n: |3 Y( m, H - std::stringstream ssdia,ssheight;
0 Z z. M& T4 @: @6 q6 k) J+ x, r; D - // get vector
( s- }6 C) [' s8 }* y; v5 r- R - BlockStyler::PropertyList *vectorProperty = vector0->GetProperties();
, c% j8 w) ^4 T9 ^ - Vector3d vec = vectorProperty->GetVector("Vector");
/ c$ {: t- ^0 T1 G. S, ^ - delete vectorProperty;& N8 G8 F& f! n" u$ E y
- vectorProperty = NULL;</p><p> // get point / b5 X" \* ?' C O1 d9 q" y
- BlockStyler::PropertyList *pointProperty = point0->GetProperties();
" f3 p& {+ S. v1 { - Point3d point = pointProperty->GetPoint("Point");6 g3 h0 f! q* s
- delete pointProperty;- S9 I2 A; G. B- ^4 |; n6 R2 r
- pointProperty = NULL;</p><p> // get diameter4 o3 W" e4 i$ F9 T8 Z0 [
- BlockStyler::PropertyList *diaProperty = expressionDia->GetProperties();- {; ^5 h" X5 f4 Z# h+ w
- double dia = diaProperty->GetDouble("Value");3 [/ @# ?- ]% {! @' C
- delete diaProperty;% A% C8 {# D9 b$ w I& o6 s1 j
- diaProperty = NULL;</p><p>
: I0 Y7 Y8 S# g1 q) @4 X - //get height</p><p> BlockStyler::PropertyList *hProperty = expressionH->GetProperties();
6 E: f a5 O% B/ d! t& I - double height = hProperty->GetDouble("Value");+ t% L: r3 A% `, A: j4 K
- delete hProperty;
4 {1 o3 n' `% \ - hProperty = NULL;</p><p> //convert values to string X, C& @8 k$ r, a B
- ssdia << dia;
5 u% f. J; c, u% J; p6 i - diameterString = ssdia.str();</p><p> ssheight << dia;2 l7 i: b2 ^- H" Y3 x
- heightString = ssdia.str();</p><p> //create cylinder feature;</p><p>& I8 U- D9 Z* D' Q: |' b
- Part *workPart(theSession->Parts()->Work());
, L8 Z/ V% f! e' i) V - Part *displayPart(theSession->Parts()->Display());</p><p> Features::Feature *nullFeatures_Feature(NULL);
4 l3 k2 V/ _2 S/ n# J, n -
/ ?, d4 w( i0 d( c) k - Features::CylinderBuilder *cylinderBuilder1;
. K0 d; c' \6 o" f - cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(nullFeatures_Feature);</p><p> cylinderBuilder1->Diameter()->SetRightHandSide(diameterString);
7 m0 R# Z- C) U3 b1 |8 I+ I( m - cylinderBuilder1->Height()->SetRightHandSide(heightString);' N9 w3 F1 P) a2 c" M# u& V
- cylinderBuilder1->SetDirection(vec);
/ A/ V7 n) _' F& ]$ { - cylinderBuilder1->SetOrigin(point);</p><p> cylinderBuilder1->CommitFeature();) K, k, L1 n5 ~5 d" K, ~: Z1 y7 K
- cylinderBuilder1->Destroy();
; s2 ~+ s+ O( K2 k2 z, M; Y - </p>
复制代码 / K1 X- C* _6 ?: X: V5 Q' m) x6 v
高清教程见楼下.
$ R5 \6 u; v9 I @% i$ e. x, o [; ^: z6 _3 i
|
|