|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# w/ v$ {- Q7 Y+ o
6 F& B4 b, R% l* P: {) q
% m+ b) z7 m- T0 WUG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves
, A/ H9 C6 v) b6 o
f6 b; `; d: T5 O此处使用的是 通过面的法向创建投影曲线,可以参考下!
( t3 Z2 ~. e7 _; |" F) s' d$ x
7 f' `3 \' t% ^2 H3 H/ w
6 ?2 e1 O @: n4 B, x5 m- M& {6 `6 a$ ^& B3 f
2 N8 y0 Z. ~2 }& V1 z7 [! c _( u
, i" n# b1 [" @, O) K# k5 U/ Z3 E9 P9 M
4 i1 [; Y& q1 w' Y6 `
NX Open C++ 创建投影曲线 project curves
$ ~; U' M8 j8 c! z; ^4 l
7 X$ @2 ~6 y! H: [2 C
% \; @8 Y# o& u8 v7 S$ R6 T* l
6 A6 y$ h; K+ ?- int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1). |% K: @9 i' H3 e# i+ m8 ~* [2 e
- {) y r, q7 b7 N) c) ?
- int errorCode = 0;4 F& W# }: y) S6 o
- try
8 X6 {! h6 @; S. t C. J+ U2 G - {6 W* p- }, x& c/ N; i4 O+ w
- // createProject curves2 M9 E2 ?$ F7 S; c. _/ m4 ^ i6 v
% a! K7 x H. W6 @: ?( X+ ]- Features::Feature *nullFeatures_Feature(NULL);
' E- s/ {5 k# T7 K/ z
* n) H; n' O/ e0 ^+ U' j- Features::ProjecTCurveBuilder *projectCurveBuilder1;
( B; H$ a1 Q' f2 F
0 ~( {' A9 K; k' [- projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);3 ?- e Y8 z9 Y& d
" i* W Q: p) k3 k8 l+ Z- projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);# X6 N+ b! z7 d. P1 c( ]
- ! \- h i0 S/ X8 G; B8 I+ f
- projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);
' E0 ~# g# h. s. P8 ^# j1 n' q. m
, ~1 R! Q$ F6 j& h4 t- projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);$ G+ F2 a- ?; ]/ p6 T$ L/ \7 O
$ |. ]* [8 W% T7 h5 m" y8 a; d- projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);/ ~5 d$ V2 i/ g& b& N
- 7 u" I0 X) w. O, V0 Y. g* }' o( u% ]
- projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);, B7 ?- P2 c4 H; e/ _# H" R( P7 S
# ~. G# ]( m' N* M5 `1 Q- B( O- projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);! l% J6 l' x3 k3 ~; W% U% w. G' t" |
- # E \! y9 E' Q. j n9 C$ j: |8 \* X3 T
- int size = (int)inputObjects.size();6 ?# H6 i, [! s4 K
- std::vector<IBaseCurve *> curves1;
: S/ i4 b3 E0 W; K: q4 P - for (int ii = 0 ; ii < size; ++ii)
5 n0 K }5 s$ l4 F2 z - {
! e/ e7 y, v2 x7 @. E - curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects[ii]));0 I! [4 O6 h$ R. J8 j
- }# m8 z) V$ U0 c9 }* ~% o
- - `( T% q) c0 u! K8 y
- NXOpen::CurveDumbRule *curveDumbRule1;
/ U, L, A$ j8 W
9 E1 j" a2 U3 O; ]) q: t- curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);" c2 @% h- { p+ c! {! v! | h
- 8 J$ V% R, y6 }; D
- projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);6 ^- `1 n5 O, K& \" v
- % L9 M6 i$ B% s# o2 C( |
- std::vector<SelectionIntentRule *> rules1(1);
) V0 r, V+ c# j7 |; ^, l& }6 `0 ^ - rules1[0] = curveDumbRule1;
% ^7 [6 J, W6 @ X1 n - NXObject *nullNXObject(NULL);2 G* } Q9 `/ Z/ _/ S
- Point3d helpPoint1(0, 0, 0);1 D9 g/ S# \' u# {5 G' T
- projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
' q% l1 x4 C7 E/ @# p! P0 N
% C* K1 S9 b, R$ E0 i- plane1->Evaluate();! Z9 h, F* o% c7 B, k8 r
6 {( S' C: }8 V* { g& k- projectCurveBuilder1->SetPlaneToProjectTo(plane1);8 i0 { K- M- z) k0 M
- / T( S8 n# X' |' @1 D3 ]
- projectCurveBuilder1->SetGapOption(true);+ V( h) q) V2 b5 j, \% _4 T
& L$ Y( N5 z- I8 f, A4 N- projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);: v$ R r/ E/ \" e# n! ^+ T
9 p) T$ `; W5 e4 v6 T) L6 V' @6 n- NXObject *nXObject1;
" P/ R0 B9 p; N - nXObject1 = projectCurveBuilder1->Commit();
1 d5 \$ A7 v' h - 6 Z9 F: L5 q+ t% k* w. a$ m
- projectCurveBuilder1->SectionToProject()->CleanMappingData();
% O' ~) E; s; } - # u0 ?- W; |& K3 |; b2 z
- projectCurveBuilder1->Destroy();' C; Z4 V+ w% G& F) [: I
, {+ S( v4 H" N" I6 W% B- }
* h# Q, U- z* }6 f1 K2 x* Q - catch(exception& ex)
- b( |5 i+ _ C% c) W- S - {
5 \/ f2 k% t: O' y/ C+ M8 s' c - //---- Enter your exception handling code here -----
5 u; W2 a5 T3 O; `& t - errorCode = 1;
, i" s! R) V0 |/ n# N/ h - trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());$ P/ x7 I* }2 @3 g
- } n4 M/ J( J" T8 ~
7 J2 i" n- B1 m* b% |- return errorCode;
( @; p/ ? X7 t0 n5 Z4 d1 \ - }+ A/ ^' @+ Q% }( N+ ^
复制代码
6 q( j% G( w# ]: [' K, u$ N3 j
( C: x6 g8 s) v. R4 J* N! ^0 F B6 g V, i& ^
|
|