|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 Z7 x' Y: z) h4 J1 p( I
; O# a' ]% d* c4 U0 Q
' W3 H! U0 X1 s* Z" e$ a; o$ CUG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves' \! c7 _2 A$ }1 g9 L; R: n
0 g6 k- n0 n& Q& k# V. _9 x, P此处使用的是 通过面的法向创建投影曲线,可以参考下!
. e" j$ c i+ C& \7 [, t, B( X" ~4 `' Y8 ?# Q. S- P( i
1 E. B! ]$ h$ N) |
( [ Z* _* w; Z8 H8 T. ^6 s$ ^; D5 u" E8 W
5 ^7 ~/ ?( U$ Q* T4 B5 U; |% I. B1 }. j
+ O9 S3 I, Y) @$ j% c; L) Q
NX Open C++ 创建投影曲线 project curves
& ?+ |, r g. D0 Q1 _: m
4 O; v3 K) }& M0 x6 M. ` A7 [6 _4 ?0 G2 Y. A1 }! F6 Y7 @
- $ @1 u) `1 b ]3 e0 @
- int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1)
# P1 R& C- ^6 Q2 j# G1 [/ X8 R - {: X, k) S# h. S
- int errorCode = 0;
9 W& c+ k# }2 }* H' @ - try& D" p: F3 x! ] H( ~
- {* P4 \* q) |. J C; c& k
- // createProject curves& j6 y5 |- K+ U- N. `
- " f% x5 v' D% K) v: J/ N
- Features::Feature *nullFeatures_Feature(NULL);
: u3 c3 V" h, k! d5 d - & ^' Z# Y1 p) s! I' C2 M' l, b
- Features::ProjecTCurveBuilder *projectCurveBuilder1;
! B8 H3 i) V a) d: F0 a3 V - : h* I0 T, T8 q8 ^& @* {
- projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);& A( K' K/ t& T& ]% e# p
: B0 P1 y+ h9 R" }, {- projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);
/ A1 ?' a' a+ _! J - 4 @/ O) ?0 H+ c. M! u) A
- projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);
( V& C6 J$ ?7 s4 {& n
" N7 K! W9 A3 i |8 X- projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);4 [" M/ o/ p2 [# M
; t8 D% E% }1 _2 {1 Y: W- projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
2 L5 m1 G* j; n5 _! e - $ @# ]0 y8 K9 K0 ^7 l. l
- projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);
9 _6 s9 O; d+ T8 |5 g, K
1 D6 \: |" c1 H% q7 R- projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);
2 |3 M; H" U0 w5 @
0 ]0 C) M$ X* X% c1 q; |$ d- int size = (int)inputObjects.size();6 M! J& ~( n3 U
- std::vector<IBaseCurve *> curves1;' E; z+ C# A7 \
- for (int ii = 0 ; ii < size; ++ii)
$ K8 o7 n3 K9 a$ b; d% G# T - {. ]+ \. n8 L; P0 s6 O+ _
- curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects[ii]));4 Q% k$ y. z1 ~$ y+ M. H
- }: O6 W, J9 ~+ D$ Y, }
- / }) X ]1 ^/ V
- NXOpen::CurveDumbRule *curveDumbRule1;
! M" t( T! ], X- V* F* i
# P, O9 w6 X- g: V2 r1 J- curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);
, Q5 o8 l# b/ B/ i# l
# {* L5 t* `- ^% f3 E" B% h- projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);7 H2 A/ Q0 d6 s' o9 b
- 5 n8 o7 O+ |/ [
- std::vector<SelectionIntentRule *> rules1(1);$ C2 K- a) Q. e& P# S6 Z4 ~
- rules1[0] = curveDumbRule1;
; \% R" p4 W; ^7 x - NXObject *nullNXObject(NULL);
P1 I9 G" U& g9 J# P9 m t% A - Point3d helpPoint1(0, 0, 0);! H2 J& w" Y9 z5 h
- projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
: J/ G( b, G! q" r" B2 n8 d - & e) @' @1 U- Z. A: B
- plane1->Evaluate();' C) w* z6 C3 Q0 \8 Z! f, g( e; C' M
- : B0 X7 m5 d- ^/ [' M
- projectCurveBuilder1->SetPlaneToProjectTo(plane1);
+ \* x$ Z9 k8 ~! y0 f - & D. q6 w- ?/ x3 E- m
- projectCurveBuilder1->SetGapOption(true);) I0 D/ p2 }2 ~) ^. S" J4 {$ x6 z5 C
' R- G8 d- u& j( w9 F- projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);% d) T6 Z& P; B9 [- @; X3 n2 ]& N
- 9 o/ ^7 ^) d4 c$ k& j
- NXObject *nXObject1;
, ?: P& F2 P: C9 ?6 x7 B - nXObject1 = projectCurveBuilder1->Commit();
* @( M# D2 a U; ~! e, p% V3 V - & g6 q& b6 M8 u1 e3 |4 m& o/ \
- projectCurveBuilder1->SectionToProject()->CleanMappingData();
4 O2 r# L2 x" T1 T - , {8 \2 m; m% R4 Z/ C
- projectCurveBuilder1->Destroy();3 G+ ?: g3 f! r. m) k' p
- ' S! [) I& a0 g( H& R' |% |- x
- }) X# O9 E7 y6 R- d
- catch(exception& ex)
- \* t7 Z5 R$ C* o. y! E7 ^ - {- S, Q7 z2 Y% S! d2 m
- //---- Enter your exception handling code here -----* q9 v) D9 X$ j
- errorCode = 1;, o" p3 K# b4 J5 @9 G
- trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());1 S$ y( C- K v! i5 f6 `
- }' |, o0 W6 F+ r8 u
; A; r7 v* ^4 Z- return errorCode;+ I$ A ^+ T7 U' J4 ^3 I, q# u
- }
; H7 d9 M( W. p6 }# l7 _5 N; J
复制代码
6 w+ Q" _+ n. J5 E [6 T ]2 f
* k2 E7 l7 x v* Z9 F# D! B
7 }9 V3 [% T# C, P |
|