|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ _. M2 v/ y1 G. j$ }: q$ m
7 N4 L* \+ U4 v6 i" f
UG NX二次开发旋转特征代码分享
* a! j! ?5 l) D1 W, n) }1 H
' b4 _ D4 q7 d4 I, _1 g如何使用NX二次开发进行旋转
" f! ^# N# L# W7 E" }4 b W4 L7 n9 Z* a, N6 N% r0 o
- void lesson33_createRevolve::createRevolve(SkeTCh *sketch)+ {' m7 r @$ ?
- {) f2 s& a/ \# w
- Features::Feature *nullFeatures_Feature(NULL);5 U! p# S* Z5 I5 g
- 6 F( O& z u7 j+ W
- Features::RevolveBuilder *revolveBuilder1;
. Q& T" C' i1 P+ o; }9 `$ G. J - revolveBuilder1 = workPart->Features()->CreateRevolveBuilder(nullFeatures_Feature);
n0 {4 Z+ x) Q+ U+ Y" N) a# e& j - revolveBuilder1->SetTolerance(0.001);
3 ~( W5 j$ h9 S( a - Section *section1;/ i/ l- [6 W; j ^1 R( s
- section1 = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);' O$ j E W* E' F2 V4 u
- revolveBuilder1->SetSection(section1);" V- B2 G! s2 n" T5 Y" p8 O
- std::vector<Features::Feature *> features1(1);
^/ }: K4 K1 y7 K, t6 L - features1[0] = sketch->Feature();
1 }- F) C' ~5 {" L6 b" H - CurveFeatureRule *curveFeatureRule1;
1 J5 |- S5 d& J/ C - curveFeatureRule1 = workPart->ScRuleFactory()->CreateRuleCurveFeature(features1);
8 T0 H7 d+ m" ^! V - std::vector<SelectionIntentRule *> rules1(1);
: |2 g$ Z+ [) D- E6 N; o$ ]/ S - rules1[0] = curveFeatureRule1;
' s2 P. G/ ~9 q, e5 k/ a - NXObject *nullNXObject(NULL);
4 \- l' K- A7 x( Q - Point3d helpPoint1(0, 0, 0);* A: ~0 d; E' I. H3 n
- section1->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);- }4 ?6 Y7 x2 r, L/ C' y
- revolveBuilder1->SetSection(section1);5 P$ G* Q; ~7 h- f n/ @, x6 z
- // get UI value5 R+ b& v& y; f1 h) `0 k
- vector<TaggedObject*> selectedObjects = this->axis0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
0 I- S8 t. G2 P4 {8 f4 e5 w3 t - Axis *axis1 = dynamic_cast<Axis *>(selectedObjects[0]);0 O) L! ]% ]2 K( C2 I7 S6 a* j- s- n
- revolveBuilder1->SetAxis(axis1);
1 B6 M7 Z8 D0 S" x - double startValue = this->expStartAngle->GetProperties()->GetDouble("Value");
. Y8 v+ ~) b& E; p4 o/ a - double endValue = this->expStartAngle1->GetProperties()->GetDouble("Value");7 A E" B5 M) g6 f1 k
- stringstream s_startValue,s_endValue;2 o" ^, |1 O& ?! t( g
- s_startValue <<startValue;
$ F8 w0 w ~+ G3 B G: ?4 o5 S( M( N+ A% X - s_endValue <<endValue;+ G' u4 ~: E8 p' i# V. A" v% t
- revolveBuilder1->Limits()->StartExtend()->Value()->SetRightHandSide(s_startValue.str());
( C) ^4 {7 M6 ^' t3 v5 g0 j W - revolveBuilder1->Limits()->EndExtend()->Value()->SetRightHandSide(s_endValue.str());
, k* [( }( R% e9 t, t' W M - Features::Feature *feature1;
- B r) x3 [# e7 J5 \9 F - feature1 = revolveBuilder1->CommitFeature();8 l7 k1 ~+ D- Q5 r0 c, E
- revolveBuilder1->Destroy();
# e- Y7 k+ T7 ~7 {$ X; q7 \7 @ - section1->Destroy();
2 b5 q; m2 L- E l - }
复制代码 5 [$ U& X9 h! L4 Q, k: s7 t( I+ J
( D' k8 C9 c* \) w
# c6 ^7 ~+ P' K% g! k3 X |
|