|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, T) P9 f! e$ ^) P; H6 t) B
Dimension* plmhome::select_a_dimension()
5 l( v( d F+ _{
0 X+ |8 ^6 u: g+ z% K/ i( c // ask user to select a label
( B2 Y* r# ^) h7 |" p1 R; d! i UI *ui = UI::GetUI();2 k- K+ ^: D* E
Selection *sm = ui->SelectionManager();% Q$ i& R! k5 w6 ^. t2 i
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ i) F* o' `( D" D- Y+ ]9 n
9 g5 k' P r' ^( J0 V; i/ R
NXString message("Select Dimension:");
6 C/ N- M2 Y5 y8 U- b d) ^% b NXString title("Select Dimension");% {1 R! ]* P4 o
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;7 E2 [3 J _7 `
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
8 E' z& \2 C2 ?* ] u) t1 S bool include_features = 0;; ?. K8 Y& p: P; l8 A+ G+ M, T6 ^
bool keep_highlighted = 0;5 y6 m, R9 e" J. f
0 v" ]+ s' L/ l5 c5 {; Z* o# w
// Define the mask triple(s)
) d* ~: Y" ~/ q4 E std::vector<Selection::MaskTriple> mask(1);! @: U0 \! Z* w3 {
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
% T) |3 a L: Q$ w Point3d cursor;
: B* h v! |0 [. M2 P& f+ |6 q TaggedObject *object;5 c2 V; b: n' Y! ^
+ V, j7 ~2 D' K
// Select objects using filter defined by mask triples
7 T/ k- M6 C$ ?$ M* a# c1 b- a6 K Selection::Response res = sm->SelectTaggedObject(
2 Z: m6 _+ w1 c1 ` message, title, scope, action, include_features,
6 ]+ @ h) X" ^- e, E keep_highlighted, mask, &object, &cursor );2 k* N9 F" Y0 }3 C$ [8 s* Y
6 `; G5 G9 m$ G% T" s& y) u if( res == Selection::ResponseObjectSelected )* n2 ~$ J( Z. b. C
{/ @, b, s& L l) D" r
Annotations::Dimension *theDim;
$ t- w( n, w x; w2 t: @/ n3 d1 K+ s8 H4 ]7 q3 F8 ^! y! g
// this doesn't work and 'note' will be a zero pointer, see PR-1850850
! g7 F! m0 X3 X( {) K1 ~ //note = dynamic_cast<Annotations::PmiNote *>(object);
' q: P2 `4 r+ t( F+ W6 r5 o7 j8 G3 F( e$ Y3 o
// this works as a workaround
, h* N# `0 R! A. ]1 ^$ {0 g1 S. | theDim = (Annotations::Dimension *)(object);
( I- l1 o; f( x return theDim;) j; b. ~* D/ x; n) Z: Q5 H W W
}
0 a, t1 K- \, G9 A% Y- q0 v7 `# K, e$ i# U& q' I" d) l/ T
return 0;
# ~: a1 Y, G6 o0 h( C+ A' j Z}% }7 u( ]3 O& x6 N9 j" ?5 g9 S
( r: c- `9 z6 l2 h9 t
w) U+ m: {3 i: o/ P, O# P$ E8 @* u) ]6 ], M
6 G& O- Z+ N$ k3 w5 U% S5 G
void plmhome::do_it()
% g1 S# L+ b" I0 Q{
4 [7 n: G+ t3 R b; F$ p0 E workPart = theSession->Parts()->Work();
* k9 |# z7 h; j Part *displayPart = theSession->Parts()->Display();
2 O6 p2 m* X- f7 J8 G7 f9 z stringstream out;3 G1 ~! e8 N z% J
Dimension *theDim = 0;5 y; k7 z: J2 K7 ` Y& ^- ^% {
0 q7 o4 B ]1 A( G x; z
NXString tolTypeStrings[] = 8 j- d' [( j2 _
{
7 J5 e/ S5 i9 W/ x0 I& p9 u "ToleranceTypeNone",6 e3 {7 o8 a8 h) T- D
"ToleranceTypeLimitOneLine",
- E: V$ m0 a$ L, ]# c$ H1 @ "ToleranceTypeLimitTwoLines",! T" K" h" R3 \# @, k7 }, G/ v ~) E
"ToleranceTypeBilateralOneLine",
1 C+ P9 v1 N9 e( ^5 o: ^ "ToleranceTypeBilateralTwoLines",
8 k* F- K" d5 P9 w "ToleranceTypeUnilateralAbove",5 D" t* E" f0 [
"ToleranceTypeUnilateralBelow",
+ K( b' N! v) K7 m# l "ToleranceTypeBasic",
9 z4 y# T" _. q. E. S O "ToleranceTypeReference",9 z! r. W( d6 _- W6 T4 j
"ToleranceTypeLimitLargerFirst",
' F: Q- V9 o5 P "ToleranceTypeLimitLargerBelow",% C0 T& m0 c2 h- Z: ]. \- a9 E( t
"ToleranceTypeLimitsAndFits",
0 v8 K: }: I0 d1 @9 m "ToleranceTypeNotToScale",
- K7 s* t% v! T "ToleranceTypeDiameterReference",
/ Z3 v; b( D8 N; x1 e" f "ToleranceTypeBasicNotToScale" $ Z' c5 j p3 [7 l9 c
};" B$ f1 s) t4 r3 W
) y% z: g+ z8 h& m- \% O7 T2 J
while( (theDim=select_a_dimension()) != 0 )
7 D5 ?5 q9 B$ t. ?+ i {
4 `" V' _6 _) B" D) u2 t. [ out.str(""); out.clear(); C0 i# g) O o) z! }$ v
if(! lw->IsOpen() ) lw->Open();( v- H( F3 p+ \) Z3 ]4 h8 W. L
+ \9 Y; S# ]# w5 W out << "Selected Object: " << theDim->Tag() << endl;
$ A0 q: e' r$ F2 l. |
; m: w0 P/ s+ |5 ~2 W7 U std::vector<NXString> mainTextLines;
0 {0 u/ j( t+ z) f( ^8 w/ J6 G- [ std::vector<NXString> dualTextLines; ( G1 G# a2 z8 Z8 _$ A3 K
theDim->GetDimensionText(mainTextLines, dualTextLines);- `+ B, ^3 Q M1 Y) P
for( int ii=0; ii<mainTextLines.size(); ii++)
. Y+ K; t4 S0 r$ c* A out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
6 e# n% W; f+ {- J4 S0 | for( int ii=0; ii<dualTextLines.size(); ii++)
" f! t+ `. t1 n$ }5 O out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
! w h0 X e2 L' k% x! G) ~8 a# h# \
bool refFlag = theDim->ReferenceDimensionFlag();
/ S% @3 i# y# d- ?5 x out << " ReferenceDimensionFlag: " << refFlag << endl;
8 ^0 m2 v7 u3 L- H* g) o& G/ m! o1 h" V& l9 e1 [6 n
int tolType = (int) theDim->ToleranceType();
; r4 K# _9 p* Q' e- Q/ D8 X: a$ C% ~ out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
+ O# {9 M& ~' ^2 y) D
( M- a/ z9 K& Y- t2 m( x ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
' o [* J- F3 p6 i& P9 ^ std::vector<TexTComponent*> textComps = theData->GetTextComponents();
9 e7 E# L; b" f, s% n% p7 ?4 b5 _ for( int ii=0; ii<textComps.size(); ii++)) t F* P ^: q+ |8 Q
{3 T D# j, r A
std::vector<NXString> compText = textComps[ii]->GetText();# u$ ?4 \; ]6 ~; n# D6 o2 R
for( int jj=0; jj<compText.size(); jj++ )4 Q. F# p! \' ]2 e( [
out << " Component Text: " << compText[jj].GetText() << endl;+ U1 j$ z" ?8 t" w7 X6 O9 F% J; m
}5 ?7 }( B: ^9 h, m+ m% N
" a% o+ M' j( j
int subtype;$ [0 A" m9 \: z& F
double origin[3];
1 ?6 \1 {+ w' t2 q& x UF_DRF_dim_info_t *info;
$ t5 o5 B& ] i7 C UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
4 t) a" T6 M+ [! R; g for (int ii = 0; ii<info->num_text; ii++)1 r4 z; ~7 x8 s2 C& H3 G! r5 y2 F
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
* W, G' `/ W* X) H0 C2 z9 w, d2 _ for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)" p& C' d" C2 T' [/ ?
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
1 E6 f' o3 x, x9 s UF_CALL(UF_DRF_free_dimension(&info));
2 b% J8 h+ M' `8 \2 Z* X# ]$ k
' M0 _( r8 X& A3 G; j lw->WriteLine(out.str().c_str());1 G' y# M: g3 ^+ }
7 Z! B- Y h: z& u7 L$ x- o" r
} // while. B/ Y# x+ B& Y6 x) I" ]$ y7 y: r, c
}
# [( X4 A5 v9 m( q' h$ v |
|