|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" [$ c: a5 C& i/ W
" u2 M) q8 C3 K' ^: ]+ U; R
UG NX二次开发旋转特征代码分享
/ J- s) _" }& q' r# ~, i- `
' {& ]4 D) ]9 @4 O! L" y% E+ I如何使用NX二次开发进行旋转
! U" S T- P3 }+ h9 k r1 k) ?! x9 j( G0 V
- void lesson33_createRevolve::createRevolve(SkeTCh *sketch)
( B0 X; g- d0 L7 A$ A - {/ a4 f8 f5 D! Y, M$ x5 ~/ X7 {7 j
- Features::Feature *nullFeatures_Feature(NULL);
; j$ f2 A ]9 }8 e3 D2 z) m( g - - q/ P j# V0 w$ [5 u$ O
- Features::RevolveBuilder *revolveBuilder1;) d0 E4 ^. k& T, B
- revolveBuilder1 = workPart->Features()->CreateRevolveBuilder(nullFeatures_Feature);. G' C+ k4 E( I: @+ g
- revolveBuilder1->SetTolerance(0.001);& O/ {& z' s8 G! i5 I, g& p
- Section *section1;5 r$ U9 J* P8 M: n) }3 y' W
- section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);
" [8 t# B% K1 ]% w4 Z9 D4 y - revolveBuilder1->SetSection(section1);- q* R4 |. x7 M% x: ^0 i. v
- std::vector<Features::Feature *> features1(1);
, T! Z) s, V3 ?7 N# S, B9 n$ z8 j8 t - features1[0] = sketch->Feature();
9 M( U5 }: M {: q& Q - CurveFeatureRule *curveFeatureRule1;
3 e; F1 g+ H" l! F/ l - curveFeatureRule1 = workPart->ScRuleFactory()->CreateRuleCurveFeature(features1);
, X- V& K8 U% Y7 l. G3 Q - std::vector<SelectionIntentRule *> rules1(1); F1 ]) T' F* T4 ^+ n% E5 y
- rules1[0] = curveFeatureRule1;# R3 s2 F/ _) o _5 V5 x/ D' M# i
- NXObject *nullNXObject(NULL);6 u* c2 @% F5 H% w+ O' Q
- Point3d helpPoint1(0, 0, 0);
/ c" P% A5 K7 y, E - section1->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);2 Y* B' U x! T) v: |' S
- revolveBuilder1->SetSection(section1);* G9 x S+ A4 L, \! T
- // get UI value9 ^4 q2 Y% E% K! f y, l$ Y
- vector<TaggedObject*> selectedObjects = this->axis0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
5 a& K6 i% d2 x: L - Axis *axis1 = dynamic_cast<Axis *>(selectedObjects[0]);
: I5 `) b! G" c* O ? | - revolveBuilder1->SetAxis(axis1);
) O+ f( t8 F; l5 U - double startValue = this->expStartAngle->GetProperties()->GetDouble("Value");
3 z- p5 B; d; ` - double endValue = this->expStartAngle1->GetProperties()->GetDouble("Value");$ ~1 z+ O% ^8 P" ^+ o
- stringstream s_startValue,s_endValue;
" K0 W; k( _5 n# o, N! _! f - s_startValue <<startValue;/ P) M, w5 q5 ^8 h' N' G
- s_endValue <<endValue;- R2 R4 a' `) A
- revolveBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(s_startValue.str());' p* ?) L4 v' v% F
- revolveBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide(s_endValue.str());' v3 B; @6 w, \
- Features::Feature *feature1;
4 y1 q: d% y5 e5 i1 k - feature1 = revolveBuilder1->CommitFeature();& F6 `) B. L0 f1 f) C y" p3 }
- revolveBuilder1->Destroy();
i5 I7 ]! _9 ~" a; g8 e - section1->Destroy();& ?* K8 M1 F1 P7 m" B3 O I
- }
复制代码 5 F' J: f& Z( S3 P; m
8 }( A3 g3 P( |
" c R5 |* Y" b
|
|