|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. J# M$ s H! H& uDimension* plmhome::select_a_dimension()- `& D7 U& n+ p3 [0 k) G
{* d! I. \4 A: f: G1 ]$ C
// ask user to select a label( G& @0 F* j3 S$ ^) i: f
UI *ui = UI::GetUI();. k$ M3 U) k* {! z$ `
Selection *sm = ui->SelectionManager();+ m; z8 t0 t" c8 _ V
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ H( ]) C$ J/ _9 K' o% X/ R( W
4 v2 o) r" G: A# m
NXString message("Select Dimension:"); Z0 k3 P: K9 }& S. X, @3 d3 P
NXString title("Select Dimension"); g# C" Q6 C B* D) B
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
8 R. K! H$ X t6 S- Q# f. C% o Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
$ f0 z6 ?+ G: {9 o, o bool include_features = 0;
4 b0 R* i* G% y& r) ? bool keep_highlighted = 0;. R+ d* R! z# d. P/ D8 o" r
3 _2 r. _9 D2 Q8 Q* K$ N
// Define the mask triple(s)
0 I( l6 I( |, K& k; |1 m# ^' X std::vector<Selection::MaskTriple> mask(1);
) L+ z* w1 c) ~/ j; j6 \ mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );2 b) r/ z: ?' C0 @ t, G
Point3d cursor;5 } ?7 k6 z6 S C1 q( r$ z9 T. m* Z
TaggedObject *object;. }& }3 E" ]; U) Q/ d0 d
" P. j5 T5 Y4 W8 J% T# n2 r9 V
// Select objects using filter defined by mask triples
- T8 I% K6 x! x: N5 ? Selection::Response res = sm->SelectTaggedObject(( k: |# L7 L1 H' z
message, title, scope, action, include_features,
% Y" m7 v/ x W+ o. s keep_highlighted, mask, &object, &cursor );7 ]" [" v: w. b
5 F8 \- g5 y7 t if( res == Selection::ResponseObjectSelected )+ F* b- s3 q( z
{
+ R3 I) G& O0 K Annotations::Dimension *theDim;
" [$ t) Q& v' d# u! o7 }1 B, \0 q$ n6 P8 [
// this doesn't work and 'note' will be a zero pointer, see PR-1850850
6 G4 m n9 Y8 X# x# e //note = dynamic_cast<Annotations::PmiNote *>(object);2 J7 x( W' U# y; h, A/ x, j0 Z
5 K3 C+ \/ g% Y4 W8 B // this works as a workaround- |! [5 ~* f/ v$ M' o- o. R$ d
theDim = (Annotations::Dimension *)(object);. Q- C/ N4 R# n4 Y4 Q) s& O
return theDim;
& j. z- A4 Z0 A; r6 S6 i9 f: Q8 T }
% u7 X) n* _: Z6 |1 j1 N# n2 b- x5 A' m; e% D& I- O- u
return 0;
7 L8 H2 ]- J; A3 P}" X: a) [' `1 l8 H8 T3 A
9 h+ J+ E0 V; R! j; ?7 Z
) [& B) t8 t7 B2 e$ a3 j
. t& Q( V, I% y( ] E) a9 G9 P8 i) b) u; Z
void plmhome::do_it()
5 z6 c: X) W$ R1 R{ e1 U% J8 p9 i2 G7 s$ b
workPart = theSession->Parts()->Work();
, I- L; B( |- r6 J& v1 z Part *displayPart = theSession->Parts()->Display();8 \; d4 j# z( W8 U! I1 A& q
stringstream out;
* |" h3 f/ u2 X7 u Y( s; W' t! n7 n Dimension *theDim = 0;
$ w1 ~( F. B! ?, }
$ i7 g$ _/ N7 l0 ^, R; i NXString tolTypeStrings[] =
: e: E# L8 `- O6 u/ z' v {
; J' t2 x9 Z: I3 j) u6 J: D" K% ~ "ToleranceTypeNone",
8 r k. D& g) C/ F "ToleranceTypeLimitOneLine",) g/ X: Z" Q' G3 [3 L' i% l6 U
"ToleranceTypeLimitTwoLines",& `; ~7 b ^8 D: m" M* v
"ToleranceTypeBilateralOneLine",
- _; i6 R/ `& m7 i "ToleranceTypeBilateralTwoLines",) \7 R1 R$ l# X* }
"ToleranceTypeUnilateralAbove",; h5 N/ J: O0 B! \# P c+ a, ]- C
"ToleranceTypeUnilateralBelow",3 _+ j# c# f# G1 i8 q9 A
"ToleranceTypeBasic"," [3 T. k! X8 a, Z7 Z6 U
"ToleranceTypeReference",. g$ b- }0 C) T; W! Q
"ToleranceTypeLimitLargerFirst",
5 _2 y: {" Q, Z9 t3 H "ToleranceTypeLimitLargerBelow",
+ [' y* @- E: L "ToleranceTypeLimitsAndFits",
2 v8 i" \6 t! ~) U1 I) w2 E "ToleranceTypeNotToScale",
* k$ J N, r' h7 P "ToleranceTypeDiameterReference",* G. Z4 e" J. l4 A0 L& ]0 `: p" p; N
"ToleranceTypeBasicNotToScale" 6 q/ V! b! C1 @5 w" r! `
};4 {3 ^' \7 }- J8 X% l3 Y0 Q5 K
; Z2 O( l, g! F, [; S. k" d
while( (theDim=select_a_dimension()) != 0 )
/ D* Q0 m! j* Y {3 X8 i( b, b: }' S _4 t8 `5 ^
out.str(""); out.clear();; c7 ^/ }1 ~/ [- e5 h7 C7 O
if(! lw->IsOpen() ) lw->Open();
6 v6 x# g2 U* a! _: G0 x
\3 ^) M+ ?3 p0 s- w out << "Selected Object: " << theDim->Tag() << endl;$ V- {* H- y& A3 R
+ C* {4 s& x$ I. d' f+ Q
std::vector<NXString> mainTextLines; 4 W4 }4 Q, M, u3 w! d
std::vector<NXString> dualTextLines; / j, J3 T+ H; e% c' @# n1 j. j
theDim->GetDimensionText(mainTextLines, dualTextLines);
5 s2 {: i# }8 d* V# b for( int ii=0; ii<mainTextLines.size(); ii++)
8 O* W! x5 X+ Y$ G! H+ F out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;, ?8 ?9 S! g; R6 |
for( int ii=0; ii<dualTextLines.size(); ii++)
4 k7 O/ u4 S( N8 U( T9 M out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
, [2 @' y, w8 k9 b
+ D; i3 M, x2 w bool refFlag = theDim->ReferenceDimensionFlag();! a# t6 I5 x: i
out << " ReferenceDimensionFlag: " << refFlag << endl;! E& I+ M/ k* x, h% g7 I+ `
3 n, s4 `* I, G5 f4 t
int tolType = (int) theDim->ToleranceType();
2 R3 ~" ~& x7 G' k* p0 Z% } out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
0 C* N" J: l! W4 x0 l8 ^! A+ o7 o9 `* N3 [; h
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
" y- U7 B- E* }2 Z' s std::vector<TexTComponent*> textComps = theData->GetTextComponents();
# A, D! ?0 A6 F% E* F for( int ii=0; ii<textComps.size(); ii++)
/ \' C$ [1 Y8 F& Q+ ~ {. f1 n2 B% Y0 a4 {" J
std::vector<NXString> compText = textComps[ii]->GetText();1 b% o+ F' M: X! |4 ~4 ^
for( int jj=0; jj<compText.size(); jj++ ); R$ X; o; L7 w3 c
out << " Component Text: " << compText[jj].GetText() << endl;
0 l5 e! ^: {: h' E+ s( U }# A% s9 T8 s3 `" W
! p, q' z2 Q+ Q& m5 Y int subtype;
2 u% J4 |5 c7 q$ S9 U6 U8 ~' K double origin[3];5 _6 [7 F5 j8 u6 ^# f/ g
UF_DRF_dim_info_t *info;
' R8 _* D0 \/ o; s UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));/ A% H1 g5 J( z% `8 `8 A# F
for (int ii = 0; ii<info->num_text; ii++) `2 R/ n) b @7 I+ |/ a; ?
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
. S. R7 `- z% ?9 j- I for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)1 I" i: B2 I( X4 A& U) d. k0 ^/ n
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;: w$ C) W* e! ~8 B0 {0 B: e; t
UF_CALL(UF_DRF_free_dimension(&info));
5 P: W+ q) [: H6 E q+ q7 h- g' j4 r1 z( g
lw->WriteLine(out.str().c_str());0 Q4 R2 I# X; k$ y, C
4 C$ k( p* y8 n } // while
1 k9 P! V5 g1 P. a$ h' v+ X}
" U" {6 J. I( G; P |
|