|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( E5 r3 i$ ~6 F( P I7 t
. B5 I% g0 x" I% K& a4 C3 y
7 |. ^( p, a! G6 l; g4 m7 x/ }UG NX二次开发源码分享: NX Open C++ 创建投影曲线 project curves" f) R9 J8 F' _4 Y6 Q0 k- @
% u$ i. q3 S7 b! Z
此处使用的是 通过面的法向创建投影曲线,可以参考下!" G; N# s. b5 u5 Z
; R2 k' I3 X7 D z
0 K; N2 o) S6 O2 ^" {
( O$ b& B$ `1 ^- ~/ J) }3 r% p/ O. Q2 }& `, i& I# ?
+ \. d G/ [4 C! r% i' i! \3 _, l/ K7 ^+ J
" v3 ^% F+ W6 D& L
NX Open C++ 创建投影曲线 project curves
2 i- {! \3 R" {2 O* ?1 i
3 v4 [& O+ [9 C# T
* u/ d5 R& M1 ~6 p0 V3 r
) y5 S$ ~1 |* @' O0 A/ Z6 W" Q- int trimSteels::project_curves(vector<TaggedObject *>inputObjects,Plane *plane1)
( U+ Y) P: s4 K+ }# y - {
3 `7 ~ G5 t5 [9 ^3 \9 q( I* ]7 j - int errorCode = 0;
/ t# J9 l2 g# `5 v$ \ - try
# O j. O. a: s - {
6 ^% e" h2 F V0 I* t! Y - // createProject curves; t6 | F: s4 {2 z3 y$ t
- 9 V0 l* K: c4 y
- Features::Feature *nullFeatures_Feature(NULL);
" p& n f4 p! ^2 P6 v: S - # D3 I* a/ V7 D, H j& `4 Y
- Features::ProjecTCurveBuilder *projectCurveBuilder1;1 h, \$ C9 N/ d# |4 S v; O
0 F: F" ]0 M! _9 v8 N/ n- projectCurveBuilder1 = workPart->Features()->CreateProjectCurveBuilder(nullFeatures_Feature);
- O2 V; n. i+ g/ Y4 R5 k0 H N" Z& q+ ] - . |3 F' }: |: W( m
- projectCurveBuilder1->SectionToProject()->SetDistanceTolerance(DISTANCETOLERANCE);, M( r; s- \0 k4 w! }8 E. I6 ~
5 k& N+ M8 T: i4 e- projectCurveBuilder1->SectionToProject()->SetChainingTolerance(CHAININGTOLERANCE);
9 p8 }$ e8 K5 k - 2 o E2 h/ }2 T
- projectCurveBuilder1->SectionToProject()->SetAngleTolerance(ANGLETOLERANCE);
# g0 j9 d6 h5 y/ D1 u - 9 g# Q2 A7 g) ? ^3 z
- projectCurveBuilder1->SectionToProject()->SetAllowedEntityTypes(Section::AllowTypesOnlyCurves);
- U! U0 d; V0 N. {6 y: ~9 r - & M; C; V3 `% s/ }8 T
- projectCurveBuilder1->CurveFitData()->SetTolerance(DISTANCETOLERANCE);
' w/ K: N+ r$ }& u" {: r2 [
' ]7 c& }$ T( g: E3 V% X# l) X0 M$ ?- projectCurveBuilder1->CurveFitData()->SetAngleTolerance(ANGLETOLERANCE);
F Y; s) g; Y8 r
3 i2 |! t# n) b t5 ~- int size = (int)inputObjects.size();1 W' t- M) t4 {' m* G
- std::vector<IBaseCurve *> curves1; m4 _3 Z0 ^9 w- t, N
- for (int ii = 0 ; ii < size; ++ii)
8 N$ T' n0 S, q - {/ u }0 S2 B3 y, u7 S4 _+ t M
- curves1.push_back(dynamic_cast<IBaseCurve*>(inputObjects[ii]));
6 }- p; C& X# b! ]6 E0 Y$ | - }
7 ]* f$ ^* B! T0 Y: x( u
1 f* H* ]4 g" G c- \5 S- NXOpen::CurveDumbRule *curveDumbRule1;" z& k8 u3 c5 L1 s3 D9 Y7 X
- ) T' \. N' k! b0 k. X% P5 u+ w
- curveDumbRule1 = workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(curves1);
3 O) h4 W7 H) T& e
/ u) B' J" o. l( b- projectCurveBuilder1->SectionToProject()->AllowSelfIntersection(true);5 [- \# |) T- p) L4 [8 a
- 8 g' T" b$ t, C v) ^% B% \! h0 o
- std::vector<SelectionIntentRule *> rules1(1);
& d* ~/ I8 W. @ - rules1[0] = curveDumbRule1;+ r& H: _( r+ f5 k
- NXObject *nullNXObject(NULL);! A! H o; j4 E+ n: y! q
- Point3d helpPoint1(0, 0, 0);. r% X, E! z1 R: ]) V3 y, [
- projectCurveBuilder1->SectionToProject()->AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1, Section::ModeCreate, false);
& H# @' j& {- _( f
( T J7 Q7 d+ D; b0 ]- plane1->Evaluate();7 O1 p0 Z. |1 \& N3 b! w
- * N" A6 N5 Q* Z$ P
- projectCurveBuilder1->SetPlaneToProjectTo(plane1);
5 \2 J' j, H+ \, g0 L8 ?9 n
8 z6 i4 {* z0 c- projectCurveBuilder1->SetGapOption(true);
$ y5 E8 C# \% f4 b
/ q8 s7 Y) k! R0 V3 T8 d1 u1 E7 b- projectCurveBuilder1->CurveFitData()->SetCurveJoinMethod(GeometricUtilities::CurveFitData::JoinGeneral);/ B/ P1 e1 E% v
6 S5 [, D& _% s3 `0 F( @) E6 Q- NXObject *nXObject1;. [, x/ b w1 [; F; x6 C, S
- nXObject1 = projectCurveBuilder1->Commit();. d, D3 p: u* h! i, z* b
- ; S$ W4 v- z, f- l. h; o+ C# g
- projectCurveBuilder1->SectionToProject()->CleanMappingData(); i) i* @( j, s* F5 [: m( ?6 Y
' [# d6 a! J- s/ Z, J- projectCurveBuilder1->Destroy();
x# a: x5 o! H7 B/ S3 O9 t6 }& {
# v! R( `2 m2 w- }1 D2 A' @$ M: e7 M" J6 w1 e1 J
- catch(exception& ex)
# x7 N+ L- e$ n4 B8 e - {
. \/ ?1 Q+ i' @+ m - //---- Enter your exception handling code here -----
' z5 n( Q- D2 F' P1 B: d - errorCode = 1;
3 {" ^% ?4 s- \* [; c - trimSteels::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());; d. U3 r. Z& o( T& T' L1 m7 d# C
- }
" h7 l* L3 I& t5 e# B( o& K1 B
7 F* L" K4 [& Q$ V- return errorCode;" a- V$ Y) g; A- T2 W* h1 _
- }
! W+ e+ _ x% ]! [' P# W- ]& `
复制代码
( D6 m E0 I# S. \) J9 \$ z1 y3 Q5 Y" N2 y8 k
; T+ `, r" ?5 O# E/ z
|
|