|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 s: ^0 k$ z: n) WDimension* plmhome::select_a_dimension()" [1 h8 G, t! r8 [
{
2 G8 N: e9 T& L5 M5 K3 c( V // ask user to select a label* `; e" t. D( C U& G: D
UI *ui = UI::GetUI();
8 q1 b$ K( z- C$ A! b Selection *sm = ui->SelectionManager();
( w- h2 l% R6 y! A0 s NXMessageBox *mb = ui->NXMessageBox(); // as of NX56 T# Y6 N* U! ~. ~; {
# ^+ Q( M9 l4 L p9 ^2 @
NXString message("Select Dimension:");- _* H! C$ s* ? ?- O. x+ J& e
NXString title("Select Dimension");
5 _; | h' M6 z: y6 o* @& u' E+ d Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;$ ?4 {$ q0 } @2 ~% }! X! H, i
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
J( y3 |7 B) _6 G3 u$ A bool include_features = 0;
2 E, {% X8 ` F& d6 V! ^" b bool keep_highlighted = 0;
8 T, z6 r7 z# ?3 y+ C3 D$ S* Z' u( D& l$ e
// Define the mask triple(s)
Y/ G+ g4 z! v) M1 r, I: | std::vector<Selection::MaskTriple> mask(1);
2 m- o0 o2 d0 b5 _1 M mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
+ z9 y, y. v4 Q" i6 X1 _4 ] Point3d cursor;3 |2 G1 J, E) `! u t8 @4 H
TaggedObject *object;& y1 B9 J1 B8 _5 N3 W1 n) K- b9 A
* R4 A: A' g" W7 U" _
// Select objects using filter defined by mask triples
9 U( a7 i7 D1 z0 K8 l0 V Selection::Response res = sm->SelectTaggedObject(
4 A; y! ^3 s( j3 R' U+ S message, title, scope, action, include_features,* o) \7 J5 I2 S5 A. r
keep_highlighted, mask, &object, &cursor );; U: z! a& K& q9 d% z9 M
$ r: r; g' P+ C9 M( H- B2 d& H
if( res == Selection::ResponseObjectSelected )
& x* v- v% V+ ?. Y _. r. h' k3 U {
2 g% ~6 A$ ]! o7 _! g: L/ a Annotations::Dimension *theDim;
! O8 o& t9 ]2 f) ]; Y7 Q; j; B& d0 d) H+ A) k" _# y# @
// this doesn't work and 'note' will be a zero pointer, see PR-1850850
3 _; E' ?/ O+ H9 L3 E& _ //note = dynamic_cast<Annotations::PmiNote *>(object);
4 O( ]( I. f; l/ x6 j/ }6 e
6 T& O, i- L8 l2 q // this works as a workaround
E- \, m2 r9 { Z; C# [& I theDim = (Annotations::Dimension *)(object);0 J' f3 s \/ J* [6 b
return theDim;$ D) n3 o9 S) V" f i
}: F$ t$ n3 N* p9 p
# X) E% F: y: ~& V0 d+ O V
return 0;' t4 ~, ^' w+ Y( o
}
/ h4 c% j1 X' w# {1 }0 B9 f+ @% p+ U
* M& Y* ~" f* {& {" W) Q% e' F8 r7 I0 o2 F
8 h7 X+ J) M5 M; v& E( X* l
# s N( p% v) U2 `& A! q) q6 ]: Q" |$ C- ]void plmhome::do_it()1 K3 T2 F E5 q/ _! ?" B2 L8 n
{4 B9 c9 X- n# I$ E7 o
workPart = theSession->Parts()->Work();" D6 u9 }$ c A( f+ t' U+ ]8 |
Part *displayPart = theSession->Parts()->Display();
1 L. X: x" C7 a stringstream out;" E Q* b; `+ ~2 |4 `
Dimension *theDim = 0;: I5 o& m m/ `
5 r: s) y+ c5 @) N
NXString tolTypeStrings[] = * o8 q/ N: g" z$ [8 |
{
: ^2 F L4 m+ N/ S! ] "ToleranceTypeNone",
}& w6 f. f% X" X, {0 w* L# B: I "ToleranceTypeLimitOneLine",
! ~/ Z" p" c. J7 u2 v7 N8 [ "ToleranceTypeLimitTwoLines",
- u( i. {' u6 z" s* `, q "ToleranceTypeBilateralOneLine",
' B8 _& Q% I1 w "ToleranceTypeBilateralTwoLines",
7 k; _, m! }5 ]* a! E7 @ "ToleranceTypeUnilateralAbove",7 D$ B5 P$ K' q; q5 |: S
"ToleranceTypeUnilateralBelow",( d' |; Y' i4 U
"ToleranceTypeBasic",2 w9 a3 ^5 ?+ ~* n# A
"ToleranceTypeReference"," D' c/ e; }+ s I( {+ |, U5 A
"ToleranceTypeLimitLargerFirst",' r0 i- e/ A' |! y/ L) a2 E
"ToleranceTypeLimitLargerBelow",
# r* \. O- j9 X* p" q8 T; y "ToleranceTypeLimitsAndFits",1 ~: ?2 C4 D$ \- J. |7 E y9 ]: F- u
"ToleranceTypeNotToScale",0 a# O' h& s6 N5 ^7 O: z) q
"ToleranceTypeDiameterReference",! q4 c+ l; q% h, @9 g; m
"ToleranceTypeBasicNotToScale"
/ y7 n$ v, K# u4 b( k2 d };# u. n6 e' X" L+ p0 M
& j4 W) I* D1 I& o0 ], F- q
while( (theDim=select_a_dimension()) != 0 )
5 y3 ^3 |- P" _7 b. H. K {
* t7 e0 e5 `1 ^# M out.str(""); out.clear();
% s7 o. d- Y. i4 N if(! lw->IsOpen() ) lw->Open();
! T. u7 J% h) \( y0 h# l$ n/ @7 g5 X
out << "Selected Object: " << theDim->Tag() << endl;7 p( Z, Q$ k/ X+ r6 {( r* T
f( \. F' g5 G) k7 k std::vector<NXString> mainTextLines;
& s- r ?3 ?+ V) \% I; H; m( ^+ v std::vector<NXString> dualTextLines; 3 G. m9 H0 w8 Q% I( }7 n( d/ E2 I
theDim->GetDimensionText(mainTextLines, dualTextLines);
: e7 p5 g& J i. T for( int ii=0; ii<mainTextLines.size(); ii++)
' b( n- H9 ]* I* b out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;) `# H& f. P, }2 I
for( int ii=0; ii<dualTextLines.size(); ii++)9 [5 \3 {3 Z( H0 X- J
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
0 D3 \9 ?" F, m: h; o- s4 N
`. c; k7 g8 x9 c bool refFlag = theDim->ReferenceDimensionFlag();
1 C/ }% v ?: P0 M; c out << " ReferenceDimensionFlag: " << refFlag << endl;
1 e# H, U0 w0 d- G, M& R
' I. m7 _! J. A; c1 r2 R% R- k7 Y int tolType = (int) theDim->ToleranceType();" c5 P6 q9 l6 F6 o+ {; K0 i2 S8 m5 U* g
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;9 F$ z3 `6 e4 n( K: w
" N% L' m+ g4 e0 L1 t ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);2 _( ~! l5 k/ W8 w# l/ v3 w1 V6 Q( O
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
* e5 @' a! m9 N. ]: [/ I for( int ii=0; ii<textComps.size(); ii++)
+ L7 L. K: M, R {2 }, P! D. }2 z ~2 H( }
std::vector<NXString> compText = textComps[ii]->GetText();3 N$ N4 w2 j( T- o& q; S
for( int jj=0; jj<compText.size(); jj++ )
7 Q6 p( g9 g3 J) l6 t out << " Component Text: " << compText[jj].GetText() << endl;( f* T; Q& L9 ~4 J
}' u2 Z; @% E& K3 ?; ]2 X* m
( }+ U3 g, {! J- }& E4 {2 p int subtype;; x1 c& W, Y- W# z
double origin[3];
8 e9 @3 j2 i: V- A, r" v; R4 }' ] UF_DRF_dim_info_t *info;
7 @$ W/ W3 i# V+ u* n+ h6 @ UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
4 k2 l6 f( ^9 F4 {* k& Z for (int ii = 0; ii<info->num_text; ii++)
2 G f+ d& c, D! N# | if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
5 r- s# P3 s4 W4 x for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)! a& O! L& q8 e& Z& r3 h$ A
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;7 E# {/ t0 ]& u
UF_CALL(UF_DRF_free_dimension(&info));; D* d/ D/ ~ w* q
: k( s( L/ `% ^/ s% d2 X# f$ r
lw->WriteLine(out.str().c_str());: E5 S: G2 n3 U5 r' N
3 r4 H \" A' k, q, |
} // while' A8 A% |& O* [0 j) [0 _6 a
}
- e8 o1 t" r3 \. h+ G6 |5 w& a |
|