|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ @! O# z3 d: G6 }# M1 RDimension* plmhome::select_a_dimension()
0 h3 X/ j7 z; G$ T{
5 B9 a! r) N) i% Z$ x // ask user to select a label$ B# W! D; z- r+ c' F2 I
UI *ui = UI::GetUI();, `" }* K/ j; e. Q1 I3 Z0 p
Selection *sm = ui->SelectionManager();
' j8 ?/ E& u' Y NXMessageBox *mb = ui->NXMessageBox(); // as of NX5) e% ~- m, \9 `. K
! a/ S4 \/ u7 W D7 K7 I2 I NXString message("Select Dimension:");8 k$ z- C. D! P3 d/ o) N) _
NXString title("Select Dimension");
- w* b6 |& W" |' Z0 [8 R* l7 @ Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;, W8 D1 ^* u8 j$ D7 f: O) x) \
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;9 c1 a! C, h h, F2 ^) Y2 ^3 P
bool include_features = 0;- v7 ~! z+ R& s1 }1 f. {/ c
bool keep_highlighted = 0;
( v5 J# j+ L, `# t# h' j" i
0 L8 z+ i& w# L' J0 t5 k5 B* I/ K // Define the mask triple(s)
$ S+ Y1 J1 a5 n' T& E( {. \ std::vector<Selection::MaskTriple> mask(1);
, k( ~! A7 L1 a6 [$ i mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );2 d% k! [9 I8 l& [4 B9 g8 K
Point3d cursor;
: D2 [" p/ b; Z k4 ` TaggedObject *object;7 v# d' ^# u! t* Z0 l8 b' u% N
, t$ x! u) o0 \" i // Select objects using filter defined by mask triples
2 V4 U8 ?( y, X& E& j Selection::Response res = sm->SelectTaggedObject(5 z3 S6 l3 O8 D. l0 k. ~
message, title, scope, action, include_features,
% n9 Z' G1 R! H9 _ keep_highlighted, mask, &object, &cursor );
" n- s3 Q/ f, A# h% T# }2 \7 _5 n5 @6 i9 Q. ^. }
if( res == Selection::ResponseObjectSelected )! Y$ n9 }) [) f
{
: k+ s- V: ~4 Z" y Annotations::Dimension *theDim; o2 @2 {1 w4 p+ t p
+ A( P9 U+ e9 E' e // this doesn't work and 'note' will be a zero pointer, see PR-1850850
C' L& C8 ~: o8 }4 N1 m //note = dynamic_cast<Annotations::PmiNote *>(object);) b3 N1 i2 O6 ^1 `8 G8 ]/ |: M; p
: T7 @" B* D4 ^; m2 ^) a // this works as a workaround( g' ]4 _" @% a
theDim = (Annotations::Dimension *)(object);
! y# r% i8 k6 C% v' v return theDim;+ Q4 {! n D" W; u; l
}
" z% U. A. l: y" ?' Q0 j1 j3 a! M
return 0;) W' k8 E9 _$ R1 A3 M9 d
}
( I7 Z0 J( l) m6 [8 n
- K) J# K, Q( C! e8 z$ ]0 `
$ N( F: D$ A5 B! N9 a, [0 t0 N+ E5 P' o( i5 E4 _
; W5 B; F4 T- f3 O' v' i) B9 t& wvoid plmhome::do_it()
) I5 l1 y, ?7 s( D5 u4 G2 ?( p) d{1 a$ v+ k& ?, `4 o+ Q, L Z9 F4 N
workPart = theSession->Parts()->Work();
; P0 R! o3 c# A3 L Part *displayPart = theSession->Parts()->Display();9 D" d$ _0 e, k9 j
stringstream out;
1 X* j, L" h. A A) N; q1 l Dimension *theDim = 0;
! E H; K) a- c0 J# n7 H5 l" L# c2 p8 D4 @
NXString tolTypeStrings[] = $ p$ _& z% N" L2 \& Y0 ~
{: Y* }1 h1 \+ g5 i
"ToleranceTypeNone",$ O! a5 E( \5 z
"ToleranceTypeLimitOneLine",5 s% J8 H* F8 N0 q% W
"ToleranceTypeLimitTwoLines",
5 ` W4 G3 z& G" }1 ~ "ToleranceTypeBilateralOneLine",
' w4 c4 P7 L6 @5 e& { "ToleranceTypeBilateralTwoLines",
( m" I; V2 u$ [; x. w: t1 w$ S "ToleranceTypeUnilateralAbove",
* Q3 h2 G. ^' d1 d8 V "ToleranceTypeUnilateralBelow",
/ k- f% h' Z6 c5 G+ w9 o) T "ToleranceTypeBasic",2 E; x, N' `* X. c4 [
"ToleranceTypeReference",
9 z2 J9 F) W/ Z. ?$ x2 [ "ToleranceTypeLimitLargerFirst",9 _7 T" g6 P7 N0 }/ G
"ToleranceTypeLimitLargerBelow",- Q& h9 h; X& P5 V. n
"ToleranceTypeLimitsAndFits",! _ O7 D! S; x* \; D
"ToleranceTypeNotToScale",7 x0 [3 b# f0 D9 P- g; n: {/ @# i& d
"ToleranceTypeDiameterReference",2 b O2 @3 S- p* X8 F W% i/ Y! M" q
"ToleranceTypeBasicNotToScale" , Y8 S) S" F/ V6 l5 @
};0 W: w" _1 \( K1 T N
( Y& [0 O# p% u while( (theDim=select_a_dimension()) != 0 )1 s! D* \9 {# ?
{
1 m! c' a: A% O: |4 U/ J1 e# Q out.str(""); out.clear();+ V8 W- V5 A3 ^. m" S
if(! lw->IsOpen() ) lw->Open();
" x! s/ T& }: H1 v+ p6 @& x
; |( ~$ D9 ~3 g- m0 A/ S! X6 `% J out << "Selected Object: " << theDim->Tag() << endl;- L+ u7 L, C: F! N& N8 }
; a4 U+ w' n+ @9 l) @& l std::vector<NXString> mainTextLines;
! \7 X* y/ @/ C! _4 T) P* B$ | std::vector<NXString> dualTextLines;
* B6 f0 Y3 z _ theDim->GetDimensionText(mainTextLines, dualTextLines);
$ o l; I, _( [: h' ~ for( int ii=0; ii<mainTextLines.size(); ii++)9 Y! S1 `7 m) F, I& Q
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;: R& d4 z5 j, p0 b8 w5 [
for( int ii=0; ii<dualTextLines.size(); ii++)
5 N+ ^$ W# G: m# g out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;7 u$ L' G2 }& @) r
/ C* l7 u8 U' H; k bool refFlag = theDim->ReferenceDimensionFlag();
$ i B0 g3 n( b3 S( x7 Q# b2 Q out << " ReferenceDimensionFlag: " << refFlag << endl;
- k" w( C4 m) f+ a d* h/ \! z/ k) }+ y( D0 Y3 L4 j
int tolType = (int) theDim->ToleranceType();2 A _- d- c' ~% Z$ E" H% P! E
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
# W2 \" U8 B% X1 g" C- M) s% u+ ?5 I# K3 O# K7 L% \' m3 G
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
0 L* R0 _0 S: N, E5 B, G' E std::vector<TexTComponent*> textComps = theData->GetTextComponents();
O& @; F: J1 ?& w2 B a9 A6 u" t, p for( int ii=0; ii<textComps.size(); ii++)
: @7 S# F* ?% N' J# }6 ~ {1 @+ ~1 F& n9 U; {
std::vector<NXString> compText = textComps[ii]->GetText();
# [$ [! u4 U+ S* \& O5 q for( int jj=0; jj<compText.size(); jj++ )
; ? I3 |+ U W5 `" l8 Y out << " Component Text: " << compText[jj].GetText() << endl;
% p$ g# ^+ s8 b! B, C }" \- J" r& i' X9 Q! o- b
5 G- J$ z" l. B) o; F$ _* B int subtype;: l+ E! o5 h' J0 m% ]+ `% s1 L
double origin[3];! }9 F8 P5 W: [" w8 u& `8 ]1 y+ X
UF_DRF_dim_info_t *info;; u t- B) S" J0 C1 ?
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
4 T% f, i- p$ A0 d for (int ii = 0; ii<info->num_text; ii++)
8 _3 z) Q0 \- X- m1 G if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
3 ^+ G1 O1 t0 f6 d# S for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)0 ]; c# ]$ p- j- ^* |1 A3 R5 L: [6 M
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;
1 v& Q+ S$ B2 \% O- @ UF_CALL(UF_DRF_free_dimension(&info));
+ ]8 E q( }6 k; I4 `/ `
) ?; d0 x2 W: ]; Q# i/ A% h lw->WriteLine(out.str().c_str());
. K' A0 K* c# [& d" k& j7 B7 ?4 @( w4 Z( J/ H
} // while5 c5 }* m/ p# ?9 v( z D
}
% @5 i/ [5 ]6 U1 U$ U |
|