|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 f3 X+ B& B) l7 u9 G
7 [% S1 K( |0 r$ d/ K+ j5 n$ x$ I) |
) i" H4 y# c. l' y* K7 ?9 {/ [, jUG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves
% G7 [' v, H- R( @$ z/ f2 @
# p" F8 e, ]: x. u% T5 P此处使用的是 通过面的法向创建投影曲线,可以参考下!, [2 `: k- L8 t( Q0 }2 r
1 x5 Y1 L' f- J, j
9 m& J3 @) R- F
& V3 {( _0 l- r8 r9 \8 p
; v: I& J0 L' q y+ s& y
0 d7 a7 V$ N2 |9 _8 b5 H# O1 n1 V! ]7 z, t) e, }9 |
+ |3 E1 Y; Z( L+ O9 Z0 C
NX Open C++ 创建投影曲线 project curves
8 F6 D3 S# U5 p# _: _7 f+ W' I* B7 u+ g; E v, r$ o
% |$ f% L; d: M- S8 `- W
- ( p: q0 N7 [0 F$ O! S
- int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1)
! ]' o0 _1 } w- Q; C5 S9 R - {
% ^/ ~) |6 ^8 U( d% j - int errorCode = 0;" s3 D" x( J0 ^( o
- try0 j+ w: l- z3 W
- {
P; ?3 {0 U7 q - // createProject curves
8 o9 E' N: u* Y: R; ^ - % R, N( f- z$ R9 I A0 P
- Features::Feature *nullFeatures_Feature(NULL);
, j' x; f* K) ]- [! [
. B+ P, w3 Z9 k& `% N9 [5 ~- Features::ProjecTCurveBuilder *projectCurveBuilder1;1 D" d9 x) k4 f7 g) J
- & e* ]4 R2 D1 y$ @- f
- projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);4 Y. W1 o. m/ P# Z* Z" J4 @2 ^
+ V5 ]" Q. s: E, M0 y/ N- projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);
8 q; {( k% ~9 e& h8 n6 g$ h* v
D l& ]7 m0 r p" _* I9 L- projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);8 u3 r" a# C6 v h' Q
% D) U5 x& o" @ Q- projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);' l6 n9 S# G$ C" ?2 E# t0 V
- % O0 Z/ [. _) F0 U0 ]
- projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
! e* p) `; ?/ \9 l- F$ C
; l( |& K1 d$ \. j/ A- projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);% h5 |5 s5 S) }. B/ C
5 P2 E* z- x! T* v- projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);2 I3 W* h8 N! H3 `
- , n7 k, L( _$ h" @$ |( _( c
- int size = (int)inputObjects.size();! Y# H% N) D) e- `7 B
- std::vector<IBaseCurve *> curves1;8 e4 z J/ J& u' n: x
- for (int ii = 0 ; ii < size; ++ii)
( n& _4 i0 k' N - {
; I) V& V; O# M( X - curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects[ii]));
6 D/ [1 R) z4 |; d) N4 M8 ` - }
" x" ?' H) Z2 }
. C, B' L" P, b6 s+ k- NXOpen::CurveDumbRule *curveDumbRule1;
7 R1 @* j1 ?3 [2 W' D4 | - : H: X3 ` |$ {8 a, ?* `8 |5 `
- curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);3 G1 Q1 X; u7 O4 y# o- K# U+ D- q
# R# M6 s0 x0 a; y! M: P8 R- projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);
$ q3 n, \& ]8 w
! ?& @/ U9 f) b1 o* z; t) l$ a- std::vector<SelectionIntentRule *> rules1(1);- q5 m# R: }; a6 S! c. u
- rules1[0] = curveDumbRule1;* L4 }( C. o) Z) l
- NXObject *nullNXObject(NULL);
" k9 Z. n# I6 Q$ K - Point3d helpPoint1(0, 0, 0);
7 i9 V; }- V+ W; V% i - projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);# U6 b/ W" \% U* [% N
- . k+ R, ^8 o+ ?4 {* b7 _7 A# N4 h" C
- plane1->Evaluate();2 B, [# W# y( e" s1 Y! L- l6 H2 x$ e, d
/ y, R3 M& m2 k& F- projectCurveBuilder1->SetPlaneToProjectTo(plane1);
9 f; x: I6 M9 i! k
5 R c' X/ n1 A: K. Z+ N- projectCurveBuilder1->SetGapOption(true);
5 ]9 ?* F; {$ Z2 k; _
, N& A$ }! V$ |" b+ C0 c- projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);) ?7 W& ?& e5 G/ e8 }8 `% A
- ' _! z! `8 D% M7 y
- NXObject *nXObject1;
5 K% R6 n E B8 Y* [0 D - nXObject1 = projectCurveBuilder1->Commit();
3 i$ s/ p6 b6 {' f2 o - ) Q+ N4 j, |1 R+ h/ P
- projectCurveBuilder1->SectionToProject()->CleanMappingData();6 l% Y5 }3 E- [; O5 W9 ]
2 ]- r- r( V* x- projectCurveBuilder1->Destroy();
1 M7 y2 `1 M; c* f3 V
( P' q7 D) z {/ Z- }
# G. o+ Z& ]; @* {5 P - catch(exception& ex)
/ y6 @ z$ l! W% K( a( l) }% S - {: v% l; l E, X
- //---- Enter your exception handling code here -----
; G' }. J; [. `, |7 ]+ j3 C4 X - errorCode = 1;
# f* l. f; Z3 U& Z# j) z - trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());7 o& D: K d7 Y4 J2 {$ b1 V
- }$ R8 B( j+ X0 q
# L# P! a& f* o6 D. \" I6 ?# j- return errorCode;
3 k" W Q# _: g" U; Q - }
- j6 Y* g5 j2 M5 r, j- |( E
复制代码
8 f- p6 F, c/ c, i/ s, p% O/ ^( q' n
& e+ A* G6 n. L. f* \ |
|