|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, |/ X: v( A9 n7 U5 N( e* F
6 o$ n& g% M+ D, T+ k% e- f
UG NX二次开发旋转特征代码分享
1 H" f: Q9 b! \# i. i9 n' g) Z% p4 `5 U+ m6 l" S
如何使用NX二次开发进行旋转9 N6 L- E) V e" u
* V8 B9 @* E4 ], [2 ~' N4 O; O
- void lesson33_createRevolve::createRevolve(SkeTCh *sketch)
1 f: @+ `. r1 d0 `5 w, u2 d% p - {
; N" }9 d( k8 V9 @9 S- U% ` - Features::Feature *nullFeatures_Feature(NULL);
9 t/ F T( H, q- |# P, A: F( V- h
) _& p# r2 `* O. W- Features::RevolveBuilder *revolveBuilder1;4 z7 W( C1 h) u- I
- revolveBuilder1 = workPart->Features()->CreateRevolveBuilder(nullFeatures_Feature);# m+ b% i4 K; B. p. }) I7 O
- revolveBuilder1->SetTolerance(0.001);
+ T9 I. f. ~/ I - Section *section1;
# u8 w2 D1 k \, \ - section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);
9 ?6 p4 a+ V/ U4 u - revolveBuilder1->SetSection(section1);9 y6 _/ k% R' s; _
- std::vector<Features::Feature *> features1(1);, T# Z2 n/ G. b3 y& V* j' E
- features1[0] = sketch->Feature();/ ~1 f j2 B) X0 b. H3 f
- CurveFeatureRule *curveFeatureRule1;) ~6 x8 p' H( T# C% W J3 b) e( q
- curveFeatureRule1 = workPart->ScRuleFactory()->CreateRuleCurveFeature(features1);1 j/ t2 h# \- s& k- I% {
- std::vector<SelectionIntentRule *> rules1(1);
4 R* S& X* O2 M1 }/ F+ e4 c - rules1[0] = curveFeatureRule1;
% ^/ a+ n+ y/ D( {1 Y - NXObject *nullNXObject(NULL);1 x4 ^# c' d4 k; e- ?
- Point3d helpPoint1(0, 0, 0);
4 o7 o& F) M, I: {) Z - section1->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);* f9 e ^" ?- T- c' k
- revolveBuilder1->SetSection(section1);
0 g$ n. c5 b* V. q/ P( @+ p" H - // get UI value
, p5 c# ]% E" v - vector<TaggedObject*> selectedObjects = this->axis0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
/ y3 ]1 n4 n- i" X - Axis *axis1 = dynamic_cast<Axis *>(selectedObjects[0]);
% q' N! B8 g& n" I) Z8 v9 N5 @1 J. A8 B - revolveBuilder1->SetAxis(axis1);
8 U& C+ [& S: p* d" F& l- ]6 Y - double startValue = this->expStartAngle->GetProperties()->GetDouble("Value");
7 k R9 j( G& K, ~ - double endValue = this->expStartAngle1->GetProperties()->GetDouble("Value");
' F* F1 J' m3 W5 O6 e - stringstream s_startValue,s_endValue;
& I$ \5 T5 Q8 p/ u; @# y - s_startValue <<startValue;
/ {; |2 |: s4 H* f; r, U5 x9 y - s_endValue <<endValue;8 L2 e& K* Z7 N4 b7 b6 f
- revolveBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(s_startValue.str());
3 Z. n3 L! z4 h& {6 a4 t - revolveBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide(s_endValue.str());7 v8 k* @* e* g; j' p1 k: s# E
- Features::Feature *feature1;, b. C$ d$ U! ]2 [4 t/ F, ?
- feature1 = revolveBuilder1->CommitFeature();# x' f. f! O4 M# i
- revolveBuilder1->Destroy();
& s6 q# k; ?: S3 C: {- m - section1->Destroy();- h9 ^ X9 _% I8 h& ?
- }
复制代码
6 Y2 [ y, |+ @3 L0 `6 k
, \( A$ I; e1 j, Q9 i" [6 l7 W
0 r) }, d. V6 o3 C* U |
|