|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, J+ Q. O3 v5 ^5 K3 T' o. o) kDimension* plmhome::select_a_dimension()
7 p$ @/ l+ R. m: T8 W& {{% b) n' ~/ |9 O$ {* D
// ask user to select a label: i. t4 \+ d6 E i! e8 D
UI *ui = UI::GetUI();
( w+ {+ ^- @/ c3 _- A# _ Selection *sm = ui->SelectionManager();
% v7 d* M% _, I! c NXMessageBox *mb = ui->NXMessageBox(); // as of NX5, }) k5 t9 k, O) q+ W0 A
( A6 k' a8 I# X; e" V NXString message("Select Dimension:");
/ [2 T- p, O3 D NXString title("Select Dimension");' d' K! f. }( G' Z' l! n; B' J
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;" t! h, c; A% _* O4 Y9 G8 W
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
, k$ ~' l% ?+ \' V bool include_features = 0;
) A; J: S1 R1 D8 ]+ n# { X2 {- z4 Q bool keep_highlighted = 0;# G8 O! n! [7 k* P. D+ B+ G
2 H8 t) e. e. c( V) `' Z // Define the mask triple(s)
1 W7 l0 l) Z5 U( s) L0 @/ T% o8 Q std::vector<Selection::MaskTriple> mask(1);
. m0 M1 r# \6 @3 C2 V6 ~# c mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );+ a; V4 S- w& u- ^7 h( v: g+ f( K
Point3d cursor;( B! u% K; _4 d9 [' F
TaggedObject *object;
& o& A% ^7 p4 H9 j2 M5 ?$ [1 d# ~* H% V/ b2 m" R! |
// Select objects using filter defined by mask triples
- {3 P$ M- [& Z Selection::Response res = sm->SelectTaggedObject() `* g5 ^% p$ a5 k
message, title, scope, action, include_features,- G$ W* O, j! W& }
keep_highlighted, mask, &object, &cursor );" F( a0 I5 c6 m) \9 i( E( j* T7 R
3 j. @- X' d; Q if( res == Selection::ResponseObjectSelected )+ z; X1 W+ D: m8 n7 v
{" ~$ F. h/ V& }: ~1 v! R
Annotations::Dimension *theDim;! d, F4 a0 K/ L0 v1 g
6 @ {- c. v( S f' w4 L/ K* J
// this doesn't work and 'note' will be a zero pointer, see PR-1850850, s& G* m* [* m0 E6 S* d3 v
//note = dynamic_cast<Annotations::PmiNote *>(object);4 W( B! F+ y- E2 M5 o4 P
7 h( G0 E5 p5 u, w // this works as a workaround# s) `( F1 R" G
theDim = (Annotations::Dimension *)(object);
. ~. O7 R1 X2 \& q7 p return theDim;+ ^ W0 |: n$ W$ U1 h7 O; ]
}
6 x0 z% I; r! i9 S1 _7 R* x% j+ w: ^$ Z3 Q
return 0;; x( F' j6 j# m- H) P
}# H5 U/ J0 q# [4 Z# N; [
# E9 f. @, Y% n7 O! f$ X
- j# f' R% T& J* I! D. g! z
! _# a" s E1 O4 I" t/ l
- q5 @9 T2 c+ |
void plmhome::do_it()
3 L ^3 j; b4 ^( B{
! C2 I$ q: c4 T. g6 K2 g! s/ p0 t) d workPart = theSession->Parts()->Work(); H# o/ T3 K8 Y# g! R
Part *displayPart = theSession->Parts()->Display();
' g- b$ O7 \! S: _, x _- n3 N stringstream out;# R: R5 B1 o4 w% Z. ]. F/ T1 E$ t
Dimension *theDim = 0;
/ y; }; D* ^, z% F j# \' o: X2 y" W; |, S9 D
NXString tolTypeStrings[] =
, l& J1 T! b7 L5 h! x {$ G" G i- l( p4 t$ [# z/ ^
"ToleranceTypeNone",
2 X* [2 [0 d1 m; w# @ P" E "ToleranceTypeLimitOneLine",
; G2 {2 ?# Z" [0 K) C, D "ToleranceTypeLimitTwoLines",7 h9 K5 w* k E% [ m
"ToleranceTypeBilateralOneLine",
" |; j5 k+ O5 `6 X "ToleranceTypeBilateralTwoLines",) B" C) j; n& v; e+ N d
"ToleranceTypeUnilateralAbove",# ?6 m% U% Y* @
"ToleranceTypeUnilateralBelow",3 a: f7 O$ P* c% K$ ]2 F$ `9 B
"ToleranceTypeBasic",
1 ?: u5 V; J# o% ]" R: u& Q "ToleranceTypeReference",2 b; s/ D$ Z* H: C3 \1 X
"ToleranceTypeLimitLargerFirst",
( i0 I8 s# r5 M! o0 u "ToleranceTypeLimitLargerBelow",
# F8 W% y% X/ D- n' } "ToleranceTypeLimitsAndFits",
' n( b6 b9 d0 [, Z9 P "ToleranceTypeNotToScale",
. T6 c" w/ o( H "ToleranceTypeDiameterReference",
! Q. k6 X9 e6 _. o4 ` "ToleranceTypeBasicNotToScale"
7 R" d6 f% ?7 a };8 I1 o' h, h3 A% _/ S
- g1 p @- d6 W& l+ ]+ X2 N
while( (theDim=select_a_dimension()) != 0 )8 c! C0 I; d* f& m( F5 a
{% J5 J( y" m; s& q: F( H
out.str(""); out.clear();
9 k3 J& a! T( x' z' v if(! lw->IsOpen() ) lw->Open();9 |5 B3 z$ E/ \: g
, L: S" S2 b) f out << "Selected Object: " << theDim->Tag() << endl;; l1 Z- W- a$ X. a3 d9 C5 L; J, h
' `0 o/ |5 @, _" n- G std::vector<NXString> mainTextLines; 4 Q t1 B6 o# b' d
std::vector<NXString> dualTextLines; 8 u, z! B/ w7 R8 ^, G: i6 L
theDim->GetDimensionText(mainTextLines, dualTextLines);) `0 M3 x0 d8 G7 ^# C3 x- F! J" [
for( int ii=0; ii<mainTextLines.size(); ii++)
8 [2 d- c5 A! T C8 R out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
' F/ v/ e% w, l! v% j' q$ m for( int ii=0; ii<dualTextLines.size(); ii++)
# k' y; K9 V5 C out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;. @8 j) O! p2 |" ?
7 c* D$ T8 f- Y3 W bool refFlag = theDim->ReferenceDimensionFlag();
6 [0 y- W5 w6 a5 M7 w. j) Q9 h out << " ReferenceDimensionFlag: " << refFlag << endl;
" T; F$ b2 q L9 s# o6 {5 r
& U# }7 _$ \! H int tolType = (int) theDim->ToleranceType();
) d( w1 R* R' m% h$ E4 e7 R out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;. u( l- F3 p/ N: b: U9 L
! j: B! h. n. _9 u: [* j) W0 x ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
- n8 m, T9 K( x; O std::vector<TexTComponent*> textComps = theData->GetTextComponents();6 ]+ U- e% @7 Z# N" ~2 m0 w. J: _# }# p
for( int ii=0; ii<textComps.size(); ii++)6 |7 ]% n C" s
{4 Q* N6 h2 f* o
std::vector<NXString> compText = textComps[ii]->GetText();, }, i0 A3 t* |6 X6 Y- M" L
for( int jj=0; jj<compText.size(); jj++ )
6 Y' m3 a# ]7 X& p/ }1 g out << " Component Text: " << compText[jj].GetText() << endl;
7 j( u: q% S& i4 p }
6 T2 E: Z8 E+ H- x ]! m& b; L9 B& A2 V( s2 F; {' S( `; j9 }
int subtype;
4 L4 E7 Q$ j- U+ r double origin[3];# t3 \& x, i# u. n3 C1 W& D" G6 J
UF_DRF_dim_info_t *info;! }( _1 m0 w. q0 X7 A
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
' j( L* h# l! @) a7 L1 k for (int ii = 0; ii<info->num_text; ii++)' N% X1 x8 A! _* O& _7 p( b
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
# T/ u% ?* j b& O for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)# {) L4 f/ L) v+ g& g
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
7 X7 C# Q8 A3 l- ~4 ?: I6 U& k2 [ UF_CALL(UF_DRF_free_dimension(&info));
. N: U7 p8 k6 l+ {' B$ P
6 P6 L3 }1 P! b# @# ` lw->WriteLine(out.str().c_str());& E# h' w, F1 v/ c& Q2 [
, U! }4 |0 y6 x9 u } // while
9 @- D6 W. c! A}
( t. ~. x$ M7 I6 b5 R& i* }; s |
|