|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 {! B5 O( v$ L4 E2 p, B; h! ~Dimension* plmhome::select_a_dimension()
! E: f4 W, t* h8 R( ^# ^1 ^+ _' f1 p{" ], r; C( X+ W }0 V
// ask user to select a label5 S# g' U: ^1 N: e% p2 S3 c
UI *ui = UI::GetUI();
/ `/ @7 u8 E$ q7 H6 G9 h5 b Selection *sm = ui->SelectionManager();
# n3 }6 P c5 G NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ R3 U, b5 y% `1 K& x, t
/ K) S/ V" w+ k- m NXString message("Select Dimension:");
, S* i! g# [. B B: a, `5 l NXString title("Select Dimension");
3 B, L6 D$ Q# _, ? Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;. @7 v6 \5 m. _$ {
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
* v7 L9 b3 j d& j d+ S7 d1 z bool include_features = 0;3 M9 S. s3 ]% p* u9 e# t" R
bool keep_highlighted = 0;8 t N5 T3 D2 v4 U S8 f% s2 I! k
% l3 m* f5 X* ~6 z. E
// Define the mask triple(s)
4 l' V/ {' R- E$ Z; ?; x9 L std::vector<Selection::MaskTriple> mask(1);
3 M$ K7 W6 C8 a mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );5 P, G$ Z0 A% ^0 z" H
Point3d cursor;
! ~ o- C5 ~$ | TaggedObject *object;
1 g" Q D G& b" F @3 a/ I9 j0 X" b8 S
// Select objects using filter defined by mask triples. K2 B1 \7 f$ W# U
Selection::Response res = sm->SelectTaggedObject(9 t. y* F' _, R# P8 B
message, title, scope, action, include_features,
/ {$ F' y9 t; |1 m keep_highlighted, mask, &object, &cursor );
5 o0 V, o2 O$ O2 _) N# g$ {5 l3 y8 t' \+ G8 ~" p* s
if( res == Selection::ResponseObjectSelected ): }. `- `; z9 Z( ]/ M
{3 c) g; w* b% w1 k8 G
Annotations::Dimension *theDim;: j& E+ n a9 u6 _
; O8 S4 r) A) c2 x- S1 } // this doesn't work and 'note' will be a zero pointer, see PR-1850850
0 M8 r% s9 b$ j4 t. P# w. O# [ //note = dynamic_cast<Annotations::PmiNote *>(object);
. R# Z7 j1 X3 G/ h& z; N+ s
5 t2 z @6 c( N // this works as a workaround$ h- B0 d4 L6 H$ P; C2 x
theDim = (Annotations::Dimension *)(object);
; ~) N+ P' }1 O) c5 E: v6 h: H return theDim;
/ K5 e2 M1 x3 m! a. s! x# P }
: p# W! p: Y- I& W* q: M* j. e% c( M
return 0;9 f, a3 p$ q' g( c: U. i
}2 \: O; Z% T+ T! ?5 [9 }; A# @
3 N7 D& F% _8 O/ [1 h
x$ v3 f4 W( w. H# B' J! A" z! w4 l7 j* u! z' v! h
& g$ W8 s# t0 ~" u& x8 Avoid plmhome::do_it()
4 P; Q* w% X9 h; i4 b# M7 s{
. V+ ^6 E8 ~ J+ {! s& k# j" o workPart = theSession->Parts()->Work();
) ?' n p, Q! {3 K& B Part *displayPart = theSession->Parts()->Display();
) s2 k* U9 Q2 A& s stringstream out;' x# b l! ~* [' S
Dimension *theDim = 0;
" J; J2 [& L4 T) r- d$ q* S* G6 N& R8 p5 d: {( A. S
NXString tolTypeStrings[] = ; E- V" U, G, Z( ?/ G7 S) B$ i
{3 o6 S" t0 w/ N
"ToleranceTypeNone",. t/ M* ~; B; b* I( d& d
"ToleranceTypeLimitOneLine",8 q# y& M- Q3 q; O
"ToleranceTypeLimitTwoLines",
& Q! t0 u4 W/ ?7 P "ToleranceTypeBilateralOneLine",
W, r, t; p( p$ _" n& E# p$ g1 ]! `; S "ToleranceTypeBilateralTwoLines",
Z+ ^* b% U1 ]( L1 ^3 f- s "ToleranceTypeUnilateralAbove",
7 I* C* {$ f/ S "ToleranceTypeUnilateralBelow", J5 m/ W+ w' S" a, ^
"ToleranceTypeBasic",
" z" D4 Q1 S( C3 S9 w7 f1 }4 _1 z1 g "ToleranceTypeReference",
/ N6 j3 n. U$ v' Y "ToleranceTypeLimitLargerFirst",! ~2 j% L! ^: j7 t2 v
"ToleranceTypeLimitLargerBelow",
8 N7 x7 `/ b/ a! l "ToleranceTypeLimitsAndFits",' D2 O$ B. ]' R3 X! |3 z Q
"ToleranceTypeNotToScale",2 _: X. f* a7 R+ m
"ToleranceTypeDiameterReference",, {1 x2 `$ s# E3 a
"ToleranceTypeBasicNotToScale" 4 W0 o- n& X) o
};
6 _ l; K4 v4 h) r$ i' U+ g3 P+ ^0 J. ^! G# ?
while( (theDim=select_a_dimension()) != 0 )
' j% d+ \- p/ b+ s {
% [* d4 L0 Y9 l3 P out.str(""); out.clear();
1 n7 P5 i0 d; X q" g$ ~7 G- Y6 N if(! lw->IsOpen() ) lw->Open();3 I+ A1 B# u: Q; y8 A3 ~
' n* c' E7 E" u1 }. x out << "Selected Object: " << theDim->Tag() << endl;5 p4 S% G7 M& W8 X5 F
, K( e/ a1 r! S0 L4 B% Y1 a/ E3 b std::vector<NXString> mainTextLines;
( W4 d; r+ U' b- g std::vector<NXString> dualTextLines;
4 E- I* C/ c+ x% W2 Q! \6 } theDim->GetDimensionText(mainTextLines, dualTextLines);# N& `0 j+ s# F2 m
for( int ii=0; ii<mainTextLines.size(); ii++)) l7 E$ U F) I0 D+ P2 p
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
, A6 v. f3 l6 X% f for( int ii=0; ii<dualTextLines.size(); ii++)* p7 E, A( G4 |7 c- k( F) i; O
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
: a* e9 V/ {) P
8 ~5 G- o2 O: Q: c, B bool refFlag = theDim->ReferenceDimensionFlag();
! r6 t/ A) i0 |. t out << " ReferenceDimensionFlag: " << refFlag << endl;* ~+ j) K/ `6 T) O$ v8 Q& _+ f
8 z( U* h6 E2 `! i; [6 F8 }8 M; }
int tolType = (int) theDim->ToleranceType();: @; D b2 q6 `1 o6 o1 e3 ?' w
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;. o( ~. e; q& s; ~6 }2 O
3 H/ F1 U/ p' g0 B ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);4 N- b* U* w8 B% w3 }- {
std::vector<TexTComponent*> textComps = theData->GetTextComponents();9 ^. z) {3 }7 Q' {" C
for( int ii=0; ii<textComps.size(); ii++)
8 r+ k- P: U4 K! l7 I- O/ | {2 y( a @0 S; `- G& X2 e9 L' Q
std::vector<NXString> compText = textComps[ii]->GetText();6 f6 `6 y0 @4 v0 b2 [
for( int jj=0; jj<compText.size(); jj++ )
8 k. r+ D: P7 ]" x1 l0 P out << " Component Text: " << compText[jj].GetText() << endl;7 ]7 c$ t# A" ~2 N
}: N4 B2 r. E5 {
: [' W) O/ V' x7 `5 t
int subtype;
f `* D! { j. \% F. j! O2 F double origin[3];
5 [) \! N3 T$ S5 @ UF_DRF_dim_info_t *info;4 w& `' P9 `3 J/ t* l
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
1 Y1 h+ `3 [, b5 x9 O! Y# s for (int ii = 0; ii<info->num_text; ii++)$ ?" Y$ h& d( l4 A4 u- ?( q4 l
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT): l7 {# C X+ s5 Y( u
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
; N" }3 g2 ^" I4 _' m" B out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;0 e9 O$ r3 B1 p. V
UF_CALL(UF_DRF_free_dimension(&info));; F& j7 a: `0 a4 ?5 c5 e& }4 ?) g
7 m1 Q/ U9 p# m1 N: z% p lw->WriteLine(out.str().c_str());
* U' t$ H6 k! V' T+ N( p1 G1 `% P3 s( g
} // while
5 A2 @; t& l5 X}: I2 z) J# o8 `9 |
|
|