|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 P- G- O! r% ]0 A! d) E# s, ^* I
+ Z! X$ f* x4 C) W! b4 w1 r! l1 X5 d# d# @( y9 e
UG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves. t x; z0 V* C$ _/ i
\0 [9 x! f% {$ Y此处使用的是 通过面的法向创建投影曲线,可以参考下!
5 j: p. F. M1 ~! p( S4 ]
# {5 M4 U2 ~6 b; x5 H& ~2 m# c. y4 g, l5 ]6 T: N: r$ b! r* T
* [6 q- C8 m" f, p6 H+ Y2 K' ?
2 Y0 E/ h/ V- s" ~0 I
, d$ F9 E$ Z! G/ |# n1 l$ C! Z. K
/ o9 Q8 ]2 _+ Q) N1 e
NX Open C++ 创建投影曲线 project curves
, `% N+ r, A6 Y
6 d6 _+ J$ K) o& r: B' d6 F7 y `7 _: o
, q, w8 l1 c5 o1 P- int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1)) E* t) T& f r( B: b& Y; J
- {
6 s) U8 g4 N8 ~- g: U" I0 E - int errorCode = 0;4 m/ K" `/ b$ F, L% _0 U
- try7 r# O1 M& w7 ^; A( a* |
- {1 H- {$ P: x D; J
- // createProject curves
7 ~3 ?8 N1 ]+ q% D% R - , {1 k% w7 j1 F; i7 N
- Features::Feature *nullFeatures_Feature(NULL);
, n# s, ?& Y4 u- t - ) I" a/ I9 J9 s- f5 f
- Features::ProjecTCurveBuilder *projectCurveBuilder1;
: d1 T% n' Z7 {; p- ^- }0 Z0 {3 c
?# g: ]- o9 a Q- projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);, @0 {. p) R2 E1 } W8 f6 y
- 0 [+ S8 _/ @/ v$ I0 @/ b7 i8 e: _
- projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);7 s1 r( p5 y* r5 U9 M' N6 t
- 0 p1 J5 n+ p. S. @1 K9 V
- projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);
$ v8 P/ W# R0 @7 r* J: t. p* z
; X, }( M/ }$ x X& a. r0 ]; w- projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);
) Y6 Z9 M- q F6 c* q& e& f' v - 2 |! }& E% P- K1 ~2 w
- projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
* s9 s9 R* e% ^ N
. W( v( ]/ W5 d) J7 `- projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);7 T* v; R7 c0 K0 X
1 y: S( f& x: [. d! p8 p- projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);
. v2 g! y- I3 }3 _5 S
( u, s6 U: c+ i6 H- L2 u G- int size = (int)inputObjects.size();% Y' {, X2 q+ S& S% J2 q9 a2 P2 _
- std::vector<IBaseCurve *> curves1;) n z9 b5 |/ R( m. ^3 \) `$ R8 n
- for (int ii = 0 ; ii < size; ++ii); d: I8 M" o/ Z
- {
% n# [& j0 [6 J- O- z0 T& n( ? @ - curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects[ii]));6 q" r% S& x6 K$ W) d
- }
2 k) C* A3 ?( G- e - + m# S1 X4 B8 P
- NXOpen::CurveDumbRule *curveDumbRule1;( I3 u6 U c% q" V& e) o7 j3 ?' y# K
- : t3 a* M. e% O
- curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);
& Z, _, S- v& i" R/ }% S7 N - . `& e8 c" [; W& a
- projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);+ l2 K6 t( g2 r4 g* b% V
6 c/ X# t8 ?: p$ N: a0 h% k- std::vector<SelectionIntentRule *> rules1(1);$ }# O! p( d& b: V, b2 Q
- rules1[0] = curveDumbRule1;
& P6 ?( f. Z1 _( W& f - NXObject *nullNXObject(NULL);, A( S. i! H( N. l$ T3 E
- Point3d helpPoint1(0, 0, 0);/ f2 q, t1 q- Q5 b8 V9 Q: f' a* @8 i
- projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
4 k G# O1 t( L e - / ~+ V& `$ J* g3 z
- plane1->Evaluate();
. d( D4 w) H0 z, s0 a5 [* C% o
1 j' z2 S4 o) q2 G P2 u% e* }7 I- projectCurveBuilder1->SetPlaneToProjectTo(plane1);) Z* C7 `" s9 G ]( w ]. o. s1 V
- 1 @9 M/ P7 P4 W! F; W, ^* e
- projectCurveBuilder1->SetGapOption(true);
+ r" F G7 \" z! ~
N9 f! J" C1 M4 y4 C/ I0 c1 k- projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);
0 i U! k) `. t8 m1 O) S - " O: ]7 i( Y5 |+ e O2 g& D- C
- NXObject *nXObject1;0 [3 v+ ?' O, t; q
- nXObject1 = projectCurveBuilder1->Commit();
* N4 k Q. M! \1 k, D - 6 P7 a O. X7 h: l( R' b! t
- projectCurveBuilder1->SectionToProject()->CleanMappingData();
/ ~( X) D- L. W" [" } I8 H
9 Q* [" W' L6 i$ X1 [$ T7 ^- projectCurveBuilder1->Destroy();; ~ }0 l- w7 P$ p( N9 z) ^
$ ]/ b" m* @9 o% L) A' e- }
0 _) B9 d1 b( Z0 F4 N - catch(exception& ex)( i0 p8 q% a* v1 ^$ j& M+ [9 z% [
- {) m- Z7 k! z, y) z
- //---- Enter your exception handling code here -----+ [1 m' n$ h8 D
- errorCode = 1;6 p, X/ b2 J$ c5 k# {$ E, s% K
- trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());- R! Y; [( V. ~; r/ Q
- }
- P, ?3 c- ]5 P
& C# @5 C7 h t2 q) k A$ ~# b- return errorCode;
6 `" X# O" H4 e; T - }% j$ |% P% |* j
复制代码
) `, j2 K T; H/ J; {! c+ n; X7 \
* U, o, f; Y: s4 D6 Z- y! r) ?9 b0 v, d, b9 }
|
|