|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 B8 g* q: g; H$ S- h9 `6 {) f4 P
Dimension* plmhome::select_a_dimension()
& p0 ?- Y3 Q! k+ ?{
$ [4 r; D1 t' ~4 z( M // ask user to select a label# _5 C: i! M% X$ N( D
UI *ui = UI::GetUI();0 Y9 I3 L0 `7 V" n, \5 O* ?
Selection *sm = ui->SelectionManager();
2 C1 M# s3 m3 E; x: S NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
3 t$ i( }! b Y/ u# `, _
) M! ~5 E5 u8 U* N* j NXString message("Select Dimension:");
* I! J# _5 x1 K6 K F NXString title("Select Dimension");4 I }& u N% B. w( K( d# I- G7 f y; b
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;5 N7 b7 e& l. ~! D2 p& Z& F! h$ ~9 }
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;8 S6 _) e# n3 I3 }3 J [
bool include_features = 0;( K+ R& I* W: \
bool keep_highlighted = 0;, R9 p: }4 T7 v% x# `
8 M6 @! `# B1 P1 f; R7 D# J
// Define the mask triple(s)7 o% i0 F3 _1 {6 F
std::vector<Selection::MaskTriple> mask(1);
* m% n/ v: o8 a8 d! H) D9 u mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );7 ]/ \2 R8 {: A3 b3 T' j( y
Point3d cursor;
' b, D0 B4 M) }( t: A0 o TaggedObject *object;1 W; ^. t1 k1 j
o' Q6 A) T: _* k: ~ // Select objects using filter defined by mask triples
+ B1 w$ W9 P" l Selection::Response res = sm->SelectTaggedObject() o: E" ?: C" C# A
message, title, scope, action, include_features,
% v0 o9 y5 `4 W$ }2 e7 B2 a keep_highlighted, mask, &object, &cursor );3 z U8 p0 |8 G% f5 ]4 r* Z! [0 D
+ I2 ~5 F- d7 e; M& s/ _
if( res == Selection::ResponseObjectSelected )
, p. i! s# z4 c& t9 f: | {
, b5 n) i- s% v3 s$ d- j% b Annotations::Dimension *theDim;- r( s3 S! g# U y, | B
G. F# z% u1 P // this doesn't work and 'note' will be a zero pointer, see PR-1850850) N; F7 p" I' j M* W. R8 M
//note = dynamic_cast<Annotations::PmiNote *>(object);" | H# Q# }" X' a; E# f) G
0 O' ^8 y1 b. l' t // this works as a workaround2 Z' t, z! ]( Q% x
theDim = (Annotations::Dimension *)(object);, Y8 m$ T( S2 I# N d
return theDim;. v! Y+ m8 [8 L6 [' Y( i! j
}% |/ P( P# p- i$ v$ K# o) I
% m5 j. _3 ^9 a- x3 P return 0;
2 N& ]9 |4 _7 r9 X8 G}
0 | ]! b- Z2 Y# @
& Y1 Z) O3 y; L$ y K% Y$ v
5 f6 C2 T" ^3 I
* k" u% n& p4 w1 z$ _2 z/ ]/ T
% Q2 a/ A2 c+ j( r1 R. R2 l0 }void plmhome::do_it()
z$ h; k1 \0 e9 Y$ w; u x( Z3 _. u{$ c& K' {* Q3 f/ ?1 V% a
workPart = theSession->Parts()->Work();
, t& Z/ z# u" S7 J! U Part *displayPart = theSession->Parts()->Display();
2 \: g- y. H0 s. W. L b stringstream out;/ |9 u+ n8 k; a, M' \, {4 [, R9 o4 P
Dimension *theDim = 0;
; E' q" I5 T' a- Z; g/ v7 x7 q. Y9 a' e" c9 C7 K- K
NXString tolTypeStrings[] =
: q' o5 J7 N5 l! o% ~+ }/ M9 k {
: }, `# ^- o* A) J% \: z4 d- I "ToleranceTypeNone",, V( n+ f. s& M' {8 T2 v. V" u
"ToleranceTypeLimitOneLine",& E1 p* e. m+ A# D
"ToleranceTypeLimitTwoLines",. U2 a" E: C7 a0 T7 Y$ E
"ToleranceTypeBilateralOneLine",! u/ F" d" i4 \! g
"ToleranceTypeBilateralTwoLines",
/ D/ u: l7 x# u- P/ f "ToleranceTypeUnilateralAbove",5 l& e: P! q) Q' J0 [
"ToleranceTypeUnilateralBelow",7 i6 r+ |$ _! s
"ToleranceTypeBasic",9 y! R6 n( H. n" c
"ToleranceTypeReference",1 x6 D7 x) t/ f% P; C% V+ m
"ToleranceTypeLimitLargerFirst",0 h3 R. ?& |, J' K. N8 M! h
"ToleranceTypeLimitLargerBelow",3 M, f9 ]4 p# }" |% F: L2 R$ p
"ToleranceTypeLimitsAndFits",
* R4 B* i1 B0 a5 X "ToleranceTypeNotToScale",/ G$ y7 m3 j' L! p% d& i
"ToleranceTypeDiameterReference",
0 q: c# E6 o/ H "ToleranceTypeBasicNotToScale" ; Q' G6 h9 R* [3 Z2 K5 Z* Q- o
};+ G% ]9 e" S9 u/ M8 B
2 f9 U, s7 v7 A- x5 b! t# \: y while( (theDim=select_a_dimension()) != 0 )
' v# t% t9 M& {1 H3 n' s {
: a9 @7 d+ y! h a( h7 M! V# D out.str(""); out.clear();
0 Y9 B) |9 b# G if(! lw->IsOpen() ) lw->Open();
9 I) M9 Y! c: L0 t" n$ x! ]+ V) ^: S( W* K- _# u- h+ Z0 }+ D
out << "Selected Object: " << theDim->Tag() << endl;
/ q1 r; ~* s+ M9 x* A1 G% k+ _$ x7 Z8 ~9 ], _. s2 T
std::vector<NXString> mainTextLines;
+ f3 c* M& ^( Y0 G; b6 b1 A" V std::vector<NXString> dualTextLines; ' |; q- u- b& h% } [* u) v
theDim->GetDimensionText(mainTextLines, dualTextLines);
$ q9 h* m" |4 J9 \ for( int ii=0; ii<mainTextLines.size(); ii++)
7 M% a7 Q: n5 R8 L; [$ |; _ out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
2 N7 o: W* M- K' i+ b* \ for( int ii=0; ii<dualTextLines.size(); ii++)9 [- }7 K# u& e+ p- F
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;; W0 h3 _2 w B# a+ L. S
. c6 W/ T0 D' S2 Q5 {$ `: i; K9 G bool refFlag = theDim->ReferenceDimensionFlag();
9 N; m; D& Z; }' P: l) c out << " ReferenceDimensionFlag: " << refFlag << endl;
& S7 D+ Q) p- {+ P1 z/ U# u* P# X$ I8 J% Y3 E1 L1 D2 _7 q' {
int tolType = (int) theDim->ToleranceType();: w3 m& v! v @" ?7 Y e
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
+ v. i: `$ t2 M* V1 [1 I, b5 ]/ S8 i+ v# S! ^
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);" O# q) L+ W- _5 T
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
0 _ u4 @1 C! s. o$ E. D for( int ii=0; ii<textComps.size(); ii++)( _3 g$ k0 U: s* v# _/ F- s' n8 ^
{
+ i5 K) Q$ W# x3 f7 |" e2 y, W- T std::vector<NXString> compText = textComps[ii]->GetText();: ^" v/ \" v9 c0 Z4 H! w
for( int jj=0; jj<compText.size(); jj++ )9 R+ D3 A- K9 q- W4 o' o# @, l
out << " Component Text: " << compText[jj].GetText() << endl;
0 S, X9 h2 ~5 b& W/ C% S1 m3 M }$ {8 s; G! `' e/ z! f$ A/ \8 s
: ]; @( {9 t) q7 x$ o int subtype;( w5 h$ K( K, }) ~6 Y0 J: j
double origin[3];1 p% n4 k2 N* P. u+ w' ^9 D
UF_DRF_dim_info_t *info;1 G1 K$ ] e, u* C8 {* O! t
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
# C! R) ~$ E D) j; Q2 z4 ^* [/ K for (int ii = 0; ii<info->num_text; ii++)
4 X- d/ n, d+ q3 d m if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
9 J8 `5 }% u3 T5 l for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)5 C) ^& ^3 h9 j
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
) j- w/ E, e6 F: L' a: t UF_CALL(UF_DRF_free_dimension(&info));0 g. e# T1 z7 f, e+ {# {; n
+ o$ |( z& J" d6 w2 |( d lw->WriteLine(out.str().c_str());
3 @( b( e/ b3 \+ J: r2 I7 K+ u: q! ^' ^" `3 q: X* Q
} // while+ }) o5 v. B$ r
}
1 o' F% s3 S/ z& ]% O |
|