|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
O' n* `: l" MDimension* plmhome::select_a_dimension()- f8 M1 S+ I6 }# |8 K) Z
{/ {4 T, N, `9 ]. W& c
// ask user to select a label" R& J8 u& J" R$ @% C
UI *ui = UI::GetUI();0 Q) ^( Y. G0 A7 r! e% ^/ A
Selection *sm = ui->SelectionManager();
' k! T9 b% I( I. l8 p0 t! _* b NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
; j' d0 \1 f$ S7 M2 K2 U
4 F* ~0 E4 R2 \& F# D+ y NXString message("Select Dimension:");7 C& ~( d, {+ N+ V3 m: O
NXString title("Select Dimension");
% H5 A& L8 n& v n Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;5 h( _/ I9 M+ o& d* {3 c0 s
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;# W9 y/ i" o) H$ Z( J8 W
bool include_features = 0;# g% T* A3 B* B* B8 U) ? W# X, A
bool keep_highlighted = 0;% |, F! B2 ]% N3 `! I6 m
# `. A" w2 Y( n3 A# w/ K
// Define the mask triple(s)
6 E9 v5 L2 y5 _+ D! { std::vector<Selection::MaskTriple> mask(1);5 B5 M4 H2 c9 n' k" L! I
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );
, i' i. U: A7 s Point3d cursor;, ?3 B# }8 ~3 D, j$ N; G2 E
TaggedObject *object;
% g" a! Y8 a k( ^2 A8 K, |4 v9 V# `: l) r$ E+ }+ L. l
// Select objects using filter defined by mask triples
7 F+ o* W5 h9 D+ S, K Selection::Response res = sm->SelectTaggedObject(
" @3 m7 G( L! u) S7 j; o message, title, scope, action, include_features,/ `: a& e, A, v0 R6 F1 k4 G+ W
keep_highlighted, mask, &object, &cursor );
( d! v8 C( q8 R$ ?/ l! X& l
: a8 z' G9 D& w8 D7 N! T if( res == Selection::ResponseObjectSelected )
2 q* }/ A0 A+ J {
2 X+ n( G8 X$ t R Annotations::Dimension *theDim;
% d L: y% {& o E
, a$ |' _" O- T- R% [5 b6 d/ h$ f6 p2 N // this doesn't work and 'note' will be a zero pointer, see PR-1850850
2 |0 p- b" s3 w- l //note = dynamic_cast<Annotations::PmiNote *>(object);" g L8 u. x" @/ R% ?1 A
( C d& @( G4 b# q
// this works as a workaround: h4 W: l1 H7 P, E" b6 L% o
theDim = (Annotations::Dimension *)(object);
8 S+ |3 Q, S9 R return theDim;2 W" I$ a' f" C0 {
}
/ E% [' [7 K+ N% V; L: F9 o- Z5 H9 \
return 0;
& G7 k; o" T+ u! d0 y}
( I# c7 Q% Z. M5 I0 T* I" D
! ]5 @, f1 s5 ~& J. q G* B0 S3 j) B7 ^6 X) N3 H
8 h; H& d" p+ u$ ^" ?
Q h0 q- y) l) R! K- S, ^void plmhome::do_it()
2 z+ I, A$ @; N& n{
& n; {5 R/ ?+ R2 H1 ?( | workPart = theSession->Parts()->Work();
% C4 t+ P" ^3 Y" I: N, c& P9 u7 m Part *displayPart = theSession->Parts()->Display();( c# O" J1 r$ N6 T7 J
stringstream out;
; s6 g4 T* }4 u Dimension *theDim = 0;
3 e' ?* `0 W- ?" e) Z+ N4 ?4 l$ O. J3 @
NXString tolTypeStrings[] =
$ q* f" c7 R& u4 u, w {
\, O+ c) U+ f5 ]) b2 C3 z) P Q "ToleranceTypeNone",
' O9 W: j! F) S "ToleranceTypeLimitOneLine",
" a) Y* g( c# V, f& w$ _ "ToleranceTypeLimitTwoLines",
5 p6 u; J5 d9 i) L5 A "ToleranceTypeBilateralOneLine",3 k( ?! X8 @/ q& E. i
"ToleranceTypeBilateralTwoLines",
8 d$ W! `$ e* h0 J% m+ p "ToleranceTypeUnilateralAbove",
; W1 u) N! F) N/ e. L2 @' q "ToleranceTypeUnilateralBelow",# r) m9 z$ m) ~
"ToleranceTypeBasic",( h- z8 p9 R0 F9 u4 L7 F
"ToleranceTypeReference",1 T* w3 d: u% W- P t, [
"ToleranceTypeLimitLargerFirst",
1 J D7 e1 q7 h6 u6 O. Z4 m "ToleranceTypeLimitLargerBelow",4 X; J6 s4 K: @+ Q. G: a, ?+ E
"ToleranceTypeLimitsAndFits"," k: C2 Q) d I& g w
"ToleranceTypeNotToScale",7 A( t) g2 w: T- \) y3 J; M4 ?
"ToleranceTypeDiameterReference",% @! h/ U: Z" Q
"ToleranceTypeBasicNotToScale" ( [3 u5 w! H0 V6 V: V9 W2 z
};! y5 j! F$ V2 c/ r4 }% q3 p
7 q2 y/ {' M* r2 z" `, G8 K8 Y
while( (theDim=select_a_dimension()) != 0 )
' z" A9 g! C p0 \. w# m3 f {
% @! L! M2 r) y+ d. T! G5 p. q out.str(""); out.clear();
, K$ t, f8 x& K if(! lw->IsOpen() ) lw->Open();
4 J. M# v% A! G0 `4 J- v4 B
' B( S, Q/ q- k' ~9 I' i5 ~ out << "Selected Object: " << theDim->Tag() << endl;
' B& {0 W2 G3 \7 l" x) P7 J! @6 c( ^# X
std::vector<NXString> mainTextLines; 2 G; ?% x- g3 R" h' r
std::vector<NXString> dualTextLines; ! R( Y+ n) g+ `* J8 X* ]# d
theDim->GetDimensionText(mainTextLines, dualTextLines);- o, M, G2 b- X/ F5 ]* S$ R- k, J
for( int ii=0; ii<mainTextLines.size(); ii++)
/ h' }( ?4 z. [( G4 n# l out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;1 q* L! i9 A5 O6 ?" m
for( int ii=0; ii<dualTextLines.size(); ii++)
2 r R1 `% p) t' z7 [8 v4 ` out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;: j$ j8 O1 p+ M; w' r
+ m4 J8 T) p( l5 P: f2 F bool refFlag = theDim->ReferenceDimensionFlag();
) V2 m: J8 g1 q5 J out << " ReferenceDimensionFlag: " << refFlag << endl;- a4 ^% f0 U: z5 d% X( {2 O0 v- d" i
0 g2 I# l2 V" N' h5 ~7 W( h" r int tolType = (int) theDim->ToleranceType();
1 X: r' u. {1 F- [" b# d5 N out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;# e; H. A* [7 n: X
$ X- A+ `: f, P( J [ ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);, Z; Q/ l& _/ y; ~
std::vector<TexTComponent*> textComps = theData->GetTextComponents();' }( N, V! U3 h% [- z+ V
for( int ii=0; ii<textComps.size(); ii++)3 P, o: ], S+ r( s: g
{
5 b# b. n8 V- e std::vector<NXString> compText = textComps[ii]->GetText();
' l; M2 O/ L7 I- p for( int jj=0; jj<compText.size(); jj++ )1 i+ x( R( z. r& X7 g) R
out << " Component Text: " << compText[jj].GetText() << endl;
" N5 T2 h9 k) d2 `, | h% { }: O. }. v6 @8 s4 }' ?9 A3 z
) ?- S7 C9 Z5 H- C# C: L* R3 ?
int subtype;( h# P" m6 h4 l3 K4 j( A% k% u8 [
double origin[3]; X" y9 D- X" t7 D/ A" B. K
UF_DRF_dim_info_t *info;
: k9 X: y: G& x4 @- K# b UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));1 x; ]% e' T( K3 ?. |
for (int ii = 0; ii<info->num_text; ii++)
# a2 T6 U9 H! S r if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
8 s: \& }7 D& h for (int jj = 0; jj < info->text_info[ii].num_lines; jj++); i- G; W- n) r) X; g/ \/ ^
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
8 w1 p- I# V ?" y) g UF_CALL(UF_DRF_free_dimension(&info));8 p: T* H) T% l2 f( P" X. @2 O
% i: {! [ R/ R* \- d+ n# j
lw->WriteLine(out.str().c_str());# R. a) r$ B, S, w2 [
, B0 _# ^. R9 S$ j } // while
# T$ m/ N" r: B. w* n+ Y2 t}
( @, T* \( ~) P0 j/ S/ ^6 b2 X |
|