|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 l% C. U6 M7 O3 i. q6 a
Dimension* plmhome::select_a_dimension()
. |& C8 W$ D% a& A$ G8 ?{) x `0 e3 q4 j% t3 o; z
// ask user to select a label
6 m1 Q( E& q+ i* D UI *ui = UI::GetUI();: R/ M( @9 |: W1 I$ ^7 U
Selection *sm = ui->SelectionManager();1 a* I% }, M* y9 y( Q
NXMessageBox *mb = ui->NXMessageBox(); // as of NX5; l D) f) ]$ U2 w& ?& S5 Y$ o+ ~
% N0 M& @. K2 I
NXString message("Select Dimension:");
3 F* R% |1 o8 z* N" Y0 r NXString title("Select Dimension");
5 a% q6 I$ T+ i, W( v0 l Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;8 c4 w, v0 N8 k+ L5 h3 N
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;9 A3 U8 A- \3 G4 a* l$ t! t% y
bool include_features = 0;- S! l, u$ m1 P) t( E6 b
bool keep_highlighted = 0;2 k0 D, N- t5 b
7 E9 l8 v; ]; n& d$ s
// Define the mask triple(s)
9 ], u( p3 s, V; S. f* V) ^ std::vector<Selection::MaskTriple> mask(1);7 Q; ^, f" s4 \# x* @
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
& a$ @" T( z" t! q8 A0 r& P/ X Point3d cursor;( T0 g. ?& K. K' T+ y4 ?
TaggedObject *object;( \9 C' Z5 @9 n( {! }- e2 j/ s
8 `7 N" K; x' ]2 u9 E
// Select objects using filter defined by mask triples$ ~8 `2 z) T2 a5 g3 T3 K
Selection::Response res = sm->SelectTaggedObject($ v% ~& R; R- v( k* b
message, title, scope, action, include_features,
( R5 N6 |0 [: w/ K0 G keep_highlighted, mask, &object, &cursor );
' i" ]/ i2 Y ]3 g- ]% D L i1 I2 E6 }: v: g! Z+ D- m7 u
if( res == Selection::ResponseObjectSelected ), y0 N0 [& v: k4 K2 \
{/ v' Y3 i& U2 t& P" u' q0 ]
Annotations::Dimension *theDim;
- \/ Z* ^+ ~9 v5 C: g6 c# I
# m* X: s7 f! X8 z t' b // this doesn't work and 'note' will be a zero pointer, see PR-1850850) \5 E( m' O7 c
//note = dynamic_cast<Annotations::PmiNote *>(object);' V2 W2 D( P) t" N( q
- h/ R1 R: H8 m- l* R k1 |3 x$ y // this works as a workaround
& a. ]% N% k2 p. ~6 ] theDim = (Annotations::Dimension *)(object);
9 [) c0 D ^( R; } return theDim;- w s# _+ z3 R6 B3 s
}: q) N Y2 _" ]* R" z; |& n; m0 p
( `. V& p3 {8 \- x return 0;
1 p u; C8 ` D8 y- l/ {5 M}5 X' J6 T+ f( E# x9 {
4 A" T# ?% p1 C( r" |& X9 w% @2 ^1 _% F
2 p* J7 j0 P I$ L" Y! G
7 x- C) T# @. E+ a$ K( z2 z$ J* x; d. n
void plmhome::do_it()
+ {$ ^$ g1 z- n# S{% X+ Q% o1 E, K P( h) q
workPart = theSession->Parts()->Work();/ ]9 ^' U6 @, o! x4 k% J
Part *displayPart = theSession->Parts()->Display();" i/ A H5 c: w7 F
stringstream out;
( x# {; D) `8 k' _+ j" @ X. U9 U Dimension *theDim = 0;5 v' v3 r B% Y
9 b9 o+ s9 k! W- e
NXString tolTypeStrings[] =
U& s0 ?: S9 c {" u( ]' d T1 ^) D& q q* T+ l
"ToleranceTypeNone",; o) X2 D4 |1 C" B# d( _
"ToleranceTypeLimitOneLine",
, V- S$ ?' K! Y# ~ "ToleranceTypeLimitTwoLines",
]) }% @' M. p u4 Y "ToleranceTypeBilateralOneLine",! R; O! T4 l/ b5 Z
"ToleranceTypeBilateralTwoLines",' m7 f8 {, X P. b& w, k& j
"ToleranceTypeUnilateralAbove",7 S% Y2 @5 v' n5 z
"ToleranceTypeUnilateralBelow",; T$ l: n' K, `& H6 |( z9 Z
"ToleranceTypeBasic",
- o. @1 A" h: |3 m9 n" Q "ToleranceTypeReference",; C* ~4 h) s9 j. R& @
"ToleranceTypeLimitLargerFirst",
1 s% B" p1 p7 }$ o8 Q% ^6 Z- o "ToleranceTypeLimitLargerBelow",
( q6 g: Z* ^4 ^% d "ToleranceTypeLimitsAndFits",
' o: C0 H2 S! B% a "ToleranceTypeNotToScale",
j8 m8 _2 E: L' d- X2 G2 C, e9 E "ToleranceTypeDiameterReference",- P q" L+ ?: T0 ?* H1 w
"ToleranceTypeBasicNotToScale" ; W8 \% g% w& i3 a
};, s) @; V; D3 p- V
; K3 Q" y& m3 [* l- M: x3 Z' X1 k8 [, U c
while( (theDim=select_a_dimension()) != 0 )4 c$ q: n# ^& c, J% X
{
" L ?$ o2 b$ G9 a: ` out.str(""); out.clear();4 X; x. Q |+ w3 L G2 C, A
if(! lw->IsOpen() ) lw->Open();( `* [- e9 P7 N% s! t5 M
! \% ~9 k% X7 c8 C9 O
out << "Selected Object: " << theDim->Tag() << endl;
+ G/ J. J0 g* [& U" I ^) s
5 Y1 w2 G" k! O1 V& t" Y% `# s std::vector<NXString> mainTextLines; ' a2 g: M* g, s) i- h
std::vector<NXString> dualTextLines; # R; R; M9 g" M0 i# _
theDim->GetDimensionText(mainTextLines, dualTextLines);- }$ ]% h& f. S
for( int ii=0; ii<mainTextLines.size(); ii++)
6 U: w1 }/ o I6 Y* q" c out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;5 |5 c9 W9 t! ^
for( int ii=0; ii<dualTextLines.size(); ii++)
9 d( S7 f$ I7 _6 [ u" e out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;
8 l# m& R/ s' M: f9 S9 j9 k- n, v8 T1 _( ~# ?; ?
bool refFlag = theDim->ReferenceDimensionFlag();5 u* X" D% g9 u! b7 `& b: B3 q
out << " ReferenceDimensionFlag: " << refFlag << endl;4 p! @! l7 S1 F. S' Y& k
- x% v& W. ], Y! n+ G3 n* M9 c" B int tolType = (int) theDim->ToleranceType();
& Q" a4 @$ M; J O" k. \2 n out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;$ m$ n9 H( g- D# k" A& y7 b4 S. J7 y
3 o- I" N6 a2 t: Y# [$ r ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);- L/ T& j0 X1 S7 A' k" z
std::vector<TexTComponent*> textComps = theData->GetTextComponents();
+ H. ?: O: v% G for( int ii=0; ii<textComps.size(); ii++)% q2 x5 O/ U9 U' \
{% M# H i; J0 `% D( u5 M t. A
std::vector<NXString> compText = textComps[ii]->GetText();7 \# E% h6 p$ R: n% ~" f: ]1 ~. g5 ^4 s
for( int jj=0; jj<compText.size(); jj++ )
) S3 ?2 L7 f# t$ H' W& a, Y. q) ~ out << " Component Text: " << compText[jj].GetText() << endl;- x: f9 p2 k* j; z6 b
}
+ S; m1 B% ]. X; ^
6 e4 p& u6 i9 ^; Q! B int subtype;
% {/ N- J* S0 X$ u1 L. } double origin[3];
8 G( z0 [, j5 b5 R: D UF_DRF_dim_info_t *info;
6 a+ J( d) }- F7 ?8 b UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));6 @1 T0 q5 ~) L# x! |
for (int ii = 0; ii<info->num_text; ii++)1 U& r9 a, S/ \9 A( T+ I% |
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)( q/ S& Q7 _5 b% C. ~
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)1 {- y9 X( I6 V& J6 p8 W
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
5 v1 [$ V6 T3 Z+ q) T: ` UF_CALL(UF_DRF_free_dimension(&info));7 p. I: Z# {2 Z
2 L- D. J2 p* v8 y: h
lw->WriteLine(out.str().c_str());
9 \* J7 H- y" v9 T3 b) E0 c- j
% X: i8 N4 R7 T% x- l } // while
* o: f3 c8 w% ]9 k- f+ E' p}
- n( M L1 Z2 A |
|