|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# g# h: e6 f0 ~, j
Dimension* plmhome::select_a_dimension()
) s4 d3 u2 c0 b# F! A, H{1 l; a# K* L" m# J# ?3 h& t+ ^
// ask user to select a label
5 k8 y# l; H, H4 r UI *ui = UI::GetUI();7 ?! e+ I* d1 B
Selection *sm = ui->SelectionManager();: ~: H+ u; i5 @0 Q" h: R
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5. A0 \: e& I, z4 C, h5 n
/ q0 u' }9 K; _2 w$ q# I8 l- Y# } }
NXString message("Select Dimension:");
" _2 `3 g" _3 n' u2 s. m6 B NXString title("Select Dimension");
1 E& [) O. ?/ O( F4 {4 h9 W1 ] Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
; p8 j; H5 L2 J9 ]& N Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
$ f2 d: V% |) l bool include_features = 0;: Y% Q) O. r* Z) B- n" f
bool keep_highlighted = 0;
6 v# B, b, R0 D; u3 ~6 ]- L% y
! R6 W: |$ g3 v) z$ q1 _1 n // Define the mask triple(s)
0 n% r2 D% n- ? std::vector<Selection::MaskTriple> mask(1); i& {# A# [) r3 ~% l
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
4 M+ a: T8 Y1 Z0 y5 s% e4 u' H8 M Point3d cursor;! S' \/ q& O# _2 O1 [7 }
TaggedObject *object;
; v) s1 j# |7 s: n* v
/ p j1 u- [/ h; G# I8 l5 {2 \3 o // Select objects using filter defined by mask triples0 K& H; F& K/ x n1 Z* @
Selection::Response res = sm->SelectTaggedObject(5 i/ \/ n* s' D( z& v
message, title, scope, action, include_features,
/ `0 c/ a! A3 P/ q keep_highlighted, mask, &object, &cursor );
) \' X# E) M7 [3 q) a1 q; B% I5 G
6 g2 S7 C5 V- ?9 G& v if( res == Selection::ResponseObjectSelected )
* r1 O1 r: A7 v" K- h {& k; {( v3 C7 A# H
Annotations::Dimension *theDim;
/ B4 Q! ] Y1 E8 {% y- o0 x: [
. Z7 L1 Q7 `* C: K( ` // this doesn't work and 'note' will be a zero pointer, see PR-1850850- Y* L/ l: ]% M, ^5 E& G
//note = dynamic_cast<Annotations::PmiNote *>(object);
! U% E( I ?. {9 E6 J: M: W F) t) c3 z. V
// this works as a workaround1 O% T6 Q. {+ G. a' z/ a) ]
theDim = (Annotations::Dimension *)(object);
6 n" v% m$ `( {4 h0 d return theDim; \' Y* k j2 _; } w
}2 x! k' s; k+ I/ N |
* T0 R) X9 }% v7 c% @0 i! @5 {# F' i
return 0;
' ?) q+ ~ \5 P. }/ w* h}
" h# z1 N; T$ m9 P7 M3 k( P3 `; f+ c
4 |% I3 I7 O( C* {6 ?0 U' {' m, E3 o
$ m4 M L( f, k$ p( i+ l+ u; ^
void plmhome::do_it()
3 [! b, ^* |4 {: U' n/ h{7 x4 }5 H0 h' g V9 y$ R
workPart = theSession->Parts()->Work();
* G/ [3 }/ b* u$ Y" y Part *displayPart = theSession->Parts()->Display();+ d0 h1 F' T) k
stringstream out;* d) S9 Y* l, d' Y6 ?- M
Dimension *theDim = 0;
9 m) h2 O7 [5 c2 d9 M" T2 Q& n ~. Q) |0 k6 t
NXString tolTypeStrings[] =
7 p+ _! Q1 a+ H$ r1 n0 U1 n$ _ {
0 } T$ ~* D8 j4 q* a' N9 t: Y "ToleranceTypeNone",4 w/ N* }& H" ~; [" g& _
"ToleranceTypeLimitOneLine",+ i, R( o' s [2 }4 _/ R
"ToleranceTypeLimitTwoLines", b: L$ r" O$ R: I' i$ l
"ToleranceTypeBilateralOneLine",
& _* ^# C) G& c "ToleranceTypeBilateralTwoLines",
/ C* _7 a, |# {% r0 y: i; I "ToleranceTypeUnilateralAbove",
6 r& v# x# s( D* n "ToleranceTypeUnilateralBelow",
7 C1 I* n5 H0 s7 h( C n "ToleranceTypeBasic",
" [+ u' d$ }4 _8 O3 f6 R/ N; H "ToleranceTypeReference",0 U+ \: R) Z$ u" ^" E: m# t! H) r
"ToleranceTypeLimitLargerFirst",6 |- N4 X: s* _
"ToleranceTypeLimitLargerBelow",% a2 t9 {, t' ]
"ToleranceTypeLimitsAndFits",
7 n* O( c2 _& k$ d "ToleranceTypeNotToScale",! j( B' u0 Q$ q; @2 G2 ]7 z
"ToleranceTypeDiameterReference",: H8 r: X. L& L
"ToleranceTypeBasicNotToScale"
. G; }+ W, @8 F" @8 q P u: _1 k };
$ X: d! X5 b# B. x0 B# P4 ?+ w( f6 L6 X
while( (theDim=select_a_dimension()) != 0 )& b) U9 R( {2 X7 d8 ]: ]
{% Y# q' U( I7 C
out.str(""); out.clear();
3 `1 w) o0 A" |7 O( G& U9 K if(! lw->IsOpen() ) lw->Open();
# w5 a P$ c/ s, y$ p% g: A( f+ d/ v" B6 J4 n7 T
out << "Selected Object: " << theDim->Tag() << endl;; b6 ?7 C7 w l; T5 w3 |8 l, N
9 r* ~. G/ d5 X2 E/ s6 m$ P `
std::vector<NXString> mainTextLines; + m* C" C3 y. `8 P! q8 [
std::vector<NXString> dualTextLines; 2 \ K1 a: w- G- G$ s1 u4 }
theDim->GetDimensionText(mainTextLines, dualTextLines);
4 P8 ^$ t/ h6 B8 I for( int ii=0; ii<mainTextLines.size(); ii++); |. w1 l% I# Y7 t5 n
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
1 M3 F# b2 r/ Y3 H- O for( int ii=0; ii<dualTextLines.size(); ii++)
/ u `# z3 p) k out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
4 j/ y5 s2 w, z7 I! y7 y8 {: P- O$ ] l
bool refFlag = theDim->ReferenceDimensionFlag();' P+ N* q: D& t: c; N
out << " ReferenceDimensionFlag: " << refFlag << endl;: ?' n( j/ v z- o/ L" C4 {( Q. |
; r6 V6 \7 d9 u. E$ d
int tolType = (int) theDim->ToleranceType();
/ Q: c9 l3 Q, j0 p W out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;0 v% N& y# M4 z% c$ m- B. W% E$ X
# t' m8 |$ `' Z) r2 l7 m! m
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
' g: O" v0 Y( U7 x" G6 \ std::vector<TexTComponent*> textComps = theData->GetTextComponents();
) ~6 E8 ]& e" T) S for( int ii=0; ii<textComps.size(); ii++)1 P* g" `+ X4 p7 f8 k$ ^6 r$ r1 h
{
9 D- E' d6 q5 v2 d1 b6 t: N) g std::vector<NXString> compText = textComps[ii]->GetText();7 n, f! K' K; F7 ^5 h- l
for( int jj=0; jj<compText.size(); jj++ )
( g) t! z2 s/ k% G, t0 `& o out << " Component Text: " << compText[jj].GetText() << endl;' L5 B5 t2 {) e" O
}
$ U& I* `& w7 I8 K/ C3 F2 a2 h& p. Z6 [
int subtype;; R% H: c5 J9 A# e9 G
double origin[3];3 a4 |4 P$ E$ u) U$ h8 T1 B
UF_DRF_dim_info_t *info;
/ N1 `+ F9 c/ Q UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));( |' M+ u1 S- v& F% v
for (int ii = 0; ii<info->num_text; ii++). \- z8 u% G. N1 T1 t; l
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
5 I% h ^( _ \5 d9 c- _: ]0 O for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)6 M. A& v& f Q3 ~; `# m: Q5 |
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
5 s9 u3 m1 x0 h, d UF_CALL(UF_DRF_free_dimension(&info));
- O$ s% t0 k( d" ]" h4 I" @4 T( ] G( A
lw->WriteLine(out.str().c_str());
( J* t. Q1 e- i/ [# S' K3 G
" N$ F" p) j: N! v# r } // while
+ l# M1 ^ ~5 @! W. f}$ |+ T9 r2 k/ C% P! ^ T$ Y8 y
|
|