|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% x' @+ t! O* \1 o+ KDimension* plmhome::select_a_dimension()
: {6 i( O1 f* R) N/ q. R{7 C/ M A, t/ k" l2 @- h
// ask user to select a label4 d6 T+ R4 }' u. w
UI *ui = UI::GetUI();. Q/ ^, Y' l' @1 q
Selection *sm = ui->SelectionManager();
' I) a" B w0 b, \" n4 \9 A& g NXMessageBox *mb = ui->NXMessageBox(); // as of NX5. E# }2 u: V5 a2 J0 \4 v
, T/ I U8 a+ Y* _6 @ m- w$ K NXString message("Select Dimension:");, Q( A# x2 d/ O
NXString title("Select Dimension");
/ X" x7 ?2 c* G, m$ T7 l Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;; Z0 b. e* ]! ?# N
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
+ O( {, q% q( b% M bool include_features = 0;. H1 J, n; n8 S( Q" u; ]- X; b
bool keep_highlighted = 0;6 e0 d8 j0 ~/ [3 e* h+ L$ u5 r
[8 E4 {& x0 ] D$ r* c
// Define the mask triple(s)& M: j* Q7 A5 D8 N" s* M) \
std::vector<Selection::MaskTriple> mask(1);
- ^, }- [: w, P/ F mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
0 C1 o' \( T/ V7 w1 h Point3d cursor;
* Z* Q1 J0 q8 |- S8 u+ _( |/ z TaggedObject *object;; `" D) x& c! C( J) E* \
( c0 E6 d: G& `, G
// Select objects using filter defined by mask triples: }/ M+ B# n+ i4 f2 V5 k6 i& L
Selection::Response res = sm->SelectTaggedObject(* V) e$ `! |% C1 w
message, title, scope, action, include_features,) B3 Q1 e( r6 [( r3 }
keep_highlighted, mask, &object, &cursor );
: u3 s( W/ G4 T4 F$ k7 }4 B1 D% _
if( res == Selection::ResponseObjectSelected )
! \; c0 O2 k2 W+ \: C4 l, a+ I8 c {
% K' C" q+ @6 D+ x. d0 n Annotations::Dimension *theDim;) x$ ?! T v/ M
0 t3 Q7 A) D4 l6 a0 o* s // this doesn't work and 'note' will be a zero pointer, see PR-1850850" p5 c+ h" J# k( z- `! D9 X
//note = dynamic_cast<Annotations::PmiNote *>(object);( P1 ^( D3 g+ I$ y1 I: N+ k
$ g. N' I, j+ {1 L/ D' m. P
// this works as a workaround3 P& H4 ]- R$ \3 E
theDim = (Annotations::Dimension *)(object);: m$ H; v5 `/ |" C1 I
return theDim;
( g$ Y/ Q2 N3 b& g" _0 ] }
$ f& P! N3 t' B( u
- g- ~. v) j- v% F/ A return 0;
# E: w3 u# \+ T+ m. I0 R6 N1 E}
1 U" y6 {$ ^; i" `- G, W! B% f* ]- M9 M. m
9 d2 k- w7 |" }9 K6 k
U& I- `8 U. {; }9 V" d W
9 }- d3 a# v" {void plmhome::do_it()
. H' I5 {+ F6 W: L{
a( b c1 r! @, C workPart = theSession->Parts()->Work();
# C( }# \! S2 p+ V6 | Part *displayPart = theSession->Parts()->Display();
3 ~# H8 a( H) u \ stringstream out;
% r& q3 o! \6 S- {/ } Dimension *theDim = 0;
9 ^: n! V {- Q6 ]- x. z9 s
2 S- k5 F n. w) X9 `- C- n NXString tolTypeStrings[] = 9 ^4 k8 ?5 ]- U& Y4 W
{1 k3 I* X( y" U( r, u* _3 |
"ToleranceTypeNone",
+ O! u; K! L" d4 J "ToleranceTypeLimitOneLine",
* T4 A4 V& ^% U! [3 ` "ToleranceTypeLimitTwoLines",
! i! r! M6 i p0 m "ToleranceTypeBilateralOneLine",
- P1 h/ }$ B4 ?. z: q: V6 M "ToleranceTypeBilateralTwoLines",
& f1 T" j+ |9 Y, s1 } "ToleranceTypeUnilateralAbove",
$ E* h6 J' K7 H6 h "ToleranceTypeUnilateralBelow",3 v. V; _. |+ V5 H: H" K \6 B
"ToleranceTypeBasic",
1 h* y: B4 [* C% v- P "ToleranceTypeReference",* d m* G- `9 k% V, s) u% ~
"ToleranceTypeLimitLargerFirst",4 R9 F7 H3 L5 o% B; T
"ToleranceTypeLimitLargerBelow",
7 Y# B* R. \+ K- |: M8 x, u "ToleranceTypeLimitsAndFits",
9 D6 e& J6 u$ Y0 I' M0 M "ToleranceTypeNotToScale",
4 p8 @' h0 N! F! T8 E3 n "ToleranceTypeDiameterReference",6 H7 w' J. _5 `/ X! f
"ToleranceTypeBasicNotToScale" O# M! t% i S5 j% h
};8 l* `8 g: B- C( ?. k2 z5 h$ Q
0 l' K0 C* m# r# A6 M% }& P) n while( (theDim=select_a_dimension()) != 0 )
n; M$ @) z, g, e( Z6 X$ o {
) V6 Q: Q; Q* T0 b3 a4 G) m3 I out.str(""); out.clear();
* N7 t8 i3 ?+ q# c8 R8 _3 A if(! lw->IsOpen() ) lw->Open();
$ ~2 F$ N7 @+ \2 H5 C; ~! S3 n) V4 | Z% w: o
out << "Selected Object: " << theDim->Tag() << endl;6 y: U5 p* e' C! A. C
5 N! D1 n O" G* X5 f std::vector<NXString> mainTextLines;
2 B2 Z$ h, m; f* _/ B( D7 L( L std::vector<NXString> dualTextLines; : G; X" G" Q0 g2 K- o. S
theDim->GetDimensionText(mainTextLines, dualTextLines);
$ o8 J1 `7 V8 _3 i for( int ii=0; ii<mainTextLines.size(); ii++)# u$ X2 Y0 Z* ?% |
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
, V5 N6 e1 \: E' P( d2 z for( int ii=0; ii<dualTextLines.size(); ii++)& z! r; l, d: K
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;* E9 }+ m" n7 Q- e; Y3 L" e9 l0 E
. _1 N, J9 }9 n* @1 t! R! p% d
bool refFlag = theDim->ReferenceDimensionFlag();
1 S" @6 h$ Q# ]: @ out << " ReferenceDimensionFlag: " << refFlag << endl;
6 [8 o9 d8 v8 |- g, k$ _+ f3 [$ {+ t5 ~4 e9 {- K( [8 |4 @
int tolType = (int) theDim->ToleranceType();
& |' k" A4 J: n) r/ F3 n& r7 ] out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
# G" f# f. _* V7 ~2 m$ g# s
* a: K h/ {5 Z, z2 n* l ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
# P6 z/ ~( Z5 b$ [! [' v2 m std::vector<TexTComponent*> textComps = theData->GetTextComponents();
4 k+ |. g+ l5 k. w6 T; O for( int ii=0; ii<textComps.size(); ii++)
6 q1 }7 U' I( n: } {0 i# v( J4 J+ L$ f
std::vector<NXString> compText = textComps[ii]->GetText();
: y5 _1 I9 Z' Z) @ for( int jj=0; jj<compText.size(); jj++ )) \7 Q; y, N% G
out << " Component Text: " << compText[jj].GetText() << endl;! ^# q2 D4 k3 |
}
3 N& I" V8 z/ i7 x) I
O' b( |2 V4 G! K, @ i6 u int subtype;
( C" B4 S7 o) k double origin[3];
) J- | b8 X M5 o- N UF_DRF_dim_info_t *info;
" W* `2 k5 I$ K+ C UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
1 k) ?; ~( }2 |6 I for (int ii = 0; ii<info->num_text; ii++)0 i0 T/ A; r$ l! j2 @ M( b
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
q: S9 g8 w* h9 K for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
# n5 p! Q9 q# K; ~ out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;2 i' ]2 \- G2 Q" W) F8 j5 ^+ m9 E
UF_CALL(UF_DRF_free_dimension(&info));
' _; h! K) g6 M& C; B) L* T
. Z9 L' \! t& m4 n7 W lw->WriteLine(out.str().c_str());
5 O& q5 P% }+ t7 P# l1 _( @- g D8 M: _# I
} // while1 |+ U |/ V9 i" ^+ V! \5 r. R
}
8 r" X4 X+ p" O& K0 I; {0 j: j) `/ L |
|