|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 S/ z0 `; ?7 H
Dimension* plmhome::select_a_dimension()/ k" h4 M2 t) l1 P! ]; g4 W
{
* {* b, v6 I/ o" u. {9 T3 `( t- G // ask user to select a label
8 ~8 l( t7 r& W' ?2 } UI *ui = UI::GetUI();( k- f+ N+ H1 O* H
Selection *sm = ui->SelectionManager();
7 a8 l0 W, @0 Z4 }( N NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
8 s3 ?; w$ {" P! G. ]6 j [# K* d9 J* o; Z
NXString message("Select Dimension:");( }% z3 o: e( P5 a- S( L) Y4 ^
NXString title("Select Dimension");
8 Z Z" @8 v, c4 d) |$ i Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;" J' V! _: M* d3 b: j
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;7 i# R: u; R, X) Y( Z8 Y1 w1 {
bool include_features = 0;
$ s {3 Z+ U' Q0 D; y2 f+ ? bool keep_highlighted = 0;
% J ^: P9 H' X- O% I" `$ g$ e( \3 I1 S& B1 s2 E
// Define the mask triple(s)
- s+ v/ C8 w. S, A std::vector<Selection::MaskTriple> mask(1);
1 i: H8 ^5 T h4 @" F! C mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
* r: O9 M- [ c( b- f Point3d cursor;- y* D. R3 u/ a& c) G
TaggedObject *object;
. g$ H3 @+ W; \( M0 x* c8 S* A
6 J8 g/ V! m! F5 B% i+ q* e // Select objects using filter defined by mask triples- q; K- ~. a- B
Selection::Response res = sm->SelectTaggedObject(9 s3 |* ?/ E+ u" A
message, title, scope, action, include_features,
' D4 U t. f: i& z keep_highlighted, mask, &object, &cursor );
$ v, s p2 O4 r z2 |, O7 C2 I/ H! g# ]8 l" Q
if( res == Selection::ResponseObjectSelected ); H; j# A5 W7 H. [
{& g6 p5 E; @# k: v
Annotations::Dimension *theDim;/ d! O5 H* w: c0 ]4 l( |
. y8 F, I2 O! Y4 n8 P9 I/ v$ u // this doesn't work and 'note' will be a zero pointer, see PR-1850850% W# Z8 ~, J: F# N$ s( n" D- O
//note = dynamic_cast<Annotations::PmiNote *>(object);
2 N/ x( v b$ O5 ]& S
8 n7 b1 n+ D+ r // this works as a workaround
$ _) e/ I( j& s0 x0 L# r$ ?1 W3 p theDim = (Annotations::Dimension *)(object);
9 Y- h: ]4 f2 C return theDim;
. S, b/ o" ~1 h& I& d: d ?* ] }8 m$ n; a6 q4 I. E" \, b, G- [
7 K2 `' ~# S {! k+ O return 0;
1 K' Q# ]) X3 D* @( X/ I* U}
, @' x. R. s+ [$ W9 D5 I
/ d# s7 t- ]; l# b- Q
: U: ?% L' j8 a2 c9 g y. K& \; T) r" `8 ?, E" _: T5 }7 O
y# m4 o3 H- _7 cvoid plmhome::do_it()
, X6 T9 [- ^$ k5 [! k( f{/ _' `/ B. P! o2 x6 p$ B
workPart = theSession->Parts()->Work();
0 p8 T' G6 d; T- x4 g1 c Part *displayPart = theSession->Parts()->Display();$ v5 G' r; l9 J/ J) M: _. @" D5 A
stringstream out;
8 y: E {# z$ K/ W$ P2 C Dimension *theDim = 0;7 S9 f' Q4 s$ }
# t% q. d2 }1 \ NXString tolTypeStrings[] = ) ~9 _ N5 W" f
{# Y0 v. k* `% W/ w# ~
"ToleranceTypeNone",: M$ x- Z8 ]8 z6 E5 Z! r
"ToleranceTypeLimitOneLine",! [( c! W& s: g* O
"ToleranceTypeLimitTwoLines",
, V0 J, w, r" k( x" T "ToleranceTypeBilateralOneLine",6 p S0 E' u6 M4 u1 Q+ p" @
"ToleranceTypeBilateralTwoLines",' f. {/ t% K: P8 n
"ToleranceTypeUnilateralAbove"," |: u5 S8 B/ O
"ToleranceTypeUnilateralBelow",
4 Y# e3 |. h4 D$ q "ToleranceTypeBasic",
7 ^* A5 w4 H% {7 N" i "ToleranceTypeReference",
2 }) S5 q7 f; d2 T+ Y "ToleranceTypeLimitLargerFirst"," R" C$ o3 q/ N% g8 t
"ToleranceTypeLimitLargerBelow",
2 L9 `! K9 `( J, | "ToleranceTypeLimitsAndFits",
5 T c' e; |% y' \! T "ToleranceTypeNotToScale",
7 O) A6 \) D( S- d9 ]4 ? "ToleranceTypeDiameterReference",
9 `4 J6 A1 H$ C3 m* f% C4 ^ "ToleranceTypeBasicNotToScale" + I; U. U7 V! T' f, @9 N
};# a' ?$ {: R2 {5 `( r1 e
8 Y. Q# P1 s, U8 D7 H% }: R* V6 J while( (theDim=select_a_dimension()) != 0 )
$ H1 L6 x- t0 I& ?+ }, K$ f4 I" F7 Y {5 g( J$ m, C+ G3 X6 D! @5 s- {4 _" c
out.str(""); out.clear();
" b1 y; r/ n- i. ^3 m if(! lw->IsOpen() ) lw->Open();
+ ` ?8 U) k( E' r; P' M, k ]$ I1 ~0 r0 l9 T
out << "Selected Object: " << theDim->Tag() << endl;
/ C* `. B' g6 ?5 S# a. ?: G* ?) N8 ]" q/ E* q. z7 p5 ?+ m* B4 {
std::vector<NXString> mainTextLines; % y) i' y# I6 g8 l: c* X
std::vector<NXString> dualTextLines; : _' h! b3 b8 Q4 I( o" C" K
theDim->GetDimensionText(mainTextLines, dualTextLines);
! ]9 h) o$ O6 |4 k for( int ii=0; ii<mainTextLines.size(); ii++)$ C0 C+ t; {# r' G: f+ c9 Y. G7 V
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
% b- X6 l/ E7 A) }9 h8 O for( int ii=0; ii<dualTextLines.size(); ii++)
% h* s: ` M1 ~( m; A# _ out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
: A% Y5 S# |: V* l, X& p5 M0 F* T
! ^- L; M. e6 [9 k5 i6 E& i bool refFlag = theDim->ReferenceDimensionFlag();) Z( c& ~( q# V% H; d
out << " ReferenceDimensionFlag: " << refFlag << endl;$ O b4 x6 @" O
1 D. Q4 }# u* \- ]6 i& p
int tolType = (int) theDim->ToleranceType();
% U) T! {8 L8 N9 x6 j# R( G% W out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
$ t9 }, P& z% { t3 b+ }# R" B
6 U0 v2 T0 {1 M' u1 V ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
2 C* @$ ]( C+ }$ Z8 Q6 w0 { std::vector<TexTComponent*> textComps = theData->GetTextComponents();3 A$ L, H) Q4 s0 M7 L
for( int ii=0; ii<textComps.size(); ii++)
( \. b' k: C. R {. |! f1 [# T+ `2 _" ~
std::vector<NXString> compText = textComps[ii]->GetText();
. j! W: q9 x5 M0 x7 K for( int jj=0; jj<compText.size(); jj++ )
- ^- p6 {, X5 ?3 g out << " Component Text: " << compText[jj].GetText() << endl;
2 n; X) H3 Y6 d) P9 k }! E4 L8 g% y* ^9 w
. c( j! L/ B3 R# P1 i) @, [! [ int subtype;! M0 i3 Y3 z" c/ W
double origin[3];
M6 S4 m/ @4 x) S+ P* j- T& @ g e UF_DRF_dim_info_t *info;! [& i1 e$ I5 ?, c1 I9 L
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));" c) q/ y1 `- K- K
for (int ii = 0; ii<info->num_text; ii++)0 n5 A) h* ]# C# _* `
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)% f2 ?: d' D* U5 I G
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)
3 `# |* R) e' C- Z/ S" x/ p out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
- \, j0 J5 D5 e1 t. a& x8 W UF_CALL(UF_DRF_free_dimension(&info));- T" Q5 R4 Y8 r5 h/ v
) x2 u9 O2 f; e: b" t- J lw->WriteLine(out.str().c_str());0 P# ^5 U8 G6 Q& z0 j1 N8 o2 e
" R4 l+ V: q% A
} // while' x' P; {3 z# t( B! u2 v* M( Z8 k3 u
}
3 O3 g$ h/ `( Z. s- }% ~: l |
|