|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 F7 b5 b1 h# G3 X6 ^1 C* y# P
UG NX二次开发旋转特征代码分享
' @7 |3 _, @8 p% [0 g1 S U
5 A4 p9 g, L; R* X. \& K% f如何使用NX二次开发进行旋转5 p2 C ?- z3 R# x8 x W
( n+ M. ~' I2 j! O! X" e- void lesson33_createRevolve::createRevolve(SkeTCh *sketch)
$ ?. q, a- g: ~, T4 _; D/ X - {
0 T6 d# [1 ~* v - Features::Feature *nullFeatures_Feature(NULL);
# I8 X( W' ^* e' f; m) A: X8 B' w
; R( b0 Z! ?3 J- Features::RevolveBuilder *revolveBuilder1;
1 k/ C1 v% {% M9 ^ - revolveBuilder1 = workPart->Features()->CreateRevolveBuilder(nullFeatures_Feature);
- B! S. s% m. A- W" O4 ~ - revolveBuilder1->SetTolerance(0.001);
0 ^5 y6 ]& ^0 z# k - Section *section1;$ m. i" `' L" @# u$ R9 p
- section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);& U% {* z' ~; L; N; E: m! [
- revolveBuilder1->SetSection(section1);
1 {5 A5 g, M$ Y3 ~0 k - std::vector<Features::Feature *> features1(1);
2 j9 y$ P4 j" }( E. I - features1[0] = sketch->Feature();
5 k/ |& x; W: y3 F4 y - CurveFeatureRule *curveFeatureRule1;# I8 f5 ~- A7 {# ~# ~
- curveFeatureRule1 = workPart->ScRuleFactory()->CreateRuleCurveFeature(features1);
7 k: _* w# Y" }9 T5 a, X* X - std::vector<SelectionIntentRule *> rules1(1);3 E. U: Z# F7 Y- s; H5 T3 O
- rules1[0] = curveFeatureRule1;
- N/ i( w3 k( c, A6 | - NXObject *nullNXObject(NULL);4 r/ M# K% ^! N% I) l5 N) y
- Point3d helpPoint1(0, 0, 0);& A7 t! x% O3 P# t* H3 i
- section1->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
/ H! |0 {$ P% r; S( m7 v; R - revolveBuilder1->SetSection(section1);9 y1 q& Z- C; e7 n% }
- // get UI value
! v% H& m$ N; E' d - vector<TaggedObject*> selectedObjects = this->axis0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
6 ^- ^/ G% z# m$ { - Axis *axis1 = dynamic_cast<Axis *>(selectedObjects[0]);
) o. y0 I& r% o2 N: O - revolveBuilder1->SetAxis(axis1);
! `3 p) h# W! L7 ]( D3 s - double startValue = this->expStartAngle->GetProperties()->GetDouble("Value");7 r$ X- w" o: A
- double endValue = this->expStartAngle1->GetProperties()->GetDouble("Value");
8 O, ?( b9 s0 [% r4 T5 Y - stringstream s_startValue,s_endValue;8 O: S/ r8 @, g
- s_startValue <<startValue;
* R& X4 y" h/ U0 f% [3 H - s_endValue <<endValue;: P" |4 K/ ~- j; P3 U& r3 Z
- revolveBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(s_startValue.str());- p4 I# H& {0 ]' h" a
- revolveBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide(s_endValue.str());
. p: b7 ? C3 [7 ?9 l L- C9 c - Features::Feature *feature1;, J5 s/ c: u, H9 ]) |
- feature1 = revolveBuilder1->CommitFeature();
8 q# [- d! q+ V! ^8 | - revolveBuilder1->Destroy(); n$ G( G' ]& Y0 t+ s$ j( K
- section1->Destroy();
a, {' q) N y* U - }
复制代码 v1 V4 h3 A) @- E0 L) ^: w2 v7 Y
6 L' A# I% \- k8 e |, m
7 N8 r1 ]3 I( F+ J# N& s: P |
|