|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ b; |1 y2 ^3 r9 T ^' n, `8 V
Dimension* plmhome::select_a_dimension()
0 _8 F9 X' r# I& l2 k; w+ S{( Q0 W0 `' Y! \% h3 \
// ask user to select a label
" x/ Z/ Z) j) i3 ~1 p# r6 B+ I9 F UI *ui = UI::GetUI();
9 J, S) _4 U/ n Y: @ Selection *sm = ui->SelectionManager();
2 G. @" o# |- r9 I/ Y+ D5 w8 X NXMessageBox *mb = ui->NXMessageBox(); // as of NX5
# h1 b: b: V! W
9 r3 u* j- |1 \0 Z NXString message("Select Dimension:"); X9 W$ r2 \& o: P1 j
NXString title("Select Dimension");
2 f$ M7 c( P4 J; Y" `; l+ u Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;5 r. K. v" k* u( Z
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
! E1 Y3 N3 b1 K9 C/ ^9 G bool include_features = 0;: K) d1 F z; f. { u# h, f
bool keep_highlighted = 0;8 T/ J% a* \, x$ Q
- Y( P- f' w5 R // Define the mask triple(s), K `. U+ [) D6 f( _" N
std::vector<Selection::MaskTriple> mask(1);- p* I* [5 T+ r9 Z
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );& `- y- F/ Q: G: F4 T7 I
Point3d cursor;, {* n- `# l/ N7 j! l
TaggedObject *object;
4 n8 k" ]% K, Q8 Q! A) p ]5 F4 v, Q. }; [- B- h
// Select objects using filter defined by mask triples1 z) L7 H" H8 C5 O
Selection::Response res = sm->SelectTaggedObject(
9 j0 g! o% l4 o+ g2 E( t message, title, scope, action, include_features,
3 I5 y% u( Y3 g# Z* l. w ? keep_highlighted, mask, &object, &cursor );
2 W5 ~4 M3 ^' t( b7 h( s2 Q* [5 C- ^! f1 o2 d4 l
if( res == Selection::ResponseObjectSelected )
8 B. [& i4 J! A9 _/ [9 u {
/ ?( T9 ~! [9 A Annotations::Dimension *theDim;
& ~+ Y8 z; } l/ C" ~
& ?8 ^, H6 l6 N1 k. A V // this doesn't work and 'note' will be a zero pointer, see PR-1850850' {4 i! r. n- _! r5 N4 V% ^
//note = dynamic_cast<Annotations::PmiNote *>(object);7 w" v9 t& Q3 i( L1 }0 j7 S
# z" F; E3 G8 X4 R5 m; X$ H* @- | // this works as a workaround1 Z/ M" m" v0 D9 I i0 [
theDim = (Annotations::Dimension *)(object);5 L h5 }/ m0 g- L& l d, J% K
return theDim;" z$ t0 f) K5 O! u1 F5 W- X5 ^* E
}8 N7 D5 r& [ E
3 O$ q, P& N7 H) h0 @& Z
return 0;
4 g5 ^4 P7 T9 ^% F- L}
3 v6 ^' _7 E9 ^; p/ M) K I2 l
8 Z7 U, V0 d- t& q: R, E4 P- j8 w/ H3 R' n
2 t9 M6 {: f. y' a0 W
/ i) ^) ` G* m! W5 A" W: Rvoid plmhome::do_it()
8 c9 g2 ^6 M3 X, F1 v. H{; h6 Y1 f$ M$ z5 u/ }
workPart = theSession->Parts()->Work();
. p* n/ O0 m3 H) @7 y% o Part *displayPart = theSession->Parts()->Display();: g# ]/ e. h' T" z
stringstream out;
: e V; V. E) d( D9 l Dimension *theDim = 0;9 S' J# U* @# R& J! @1 Z3 ^
) v2 }9 y! k$ @0 L& m1 }/ M NXString tolTypeStrings[] =
. J6 y& H7 c/ K+ j: Y4 ?7 U3 g {& \) _& x5 N, _* ~) L$ W3 ^
"ToleranceTypeNone",3 x7 [4 P5 h% N2 V5 `$ K
"ToleranceTypeLimitOneLine",
0 K6 a; q3 l, J$ _/ Y "ToleranceTypeLimitTwoLines",
& L6 G3 L1 o8 \" r3 N0 [ "ToleranceTypeBilateralOneLine",9 ~7 C# @5 [0 N9 [) {/ V% N" d& {
"ToleranceTypeBilateralTwoLines",
6 D& Q' w. v C; W _ "ToleranceTypeUnilateralAbove",
; a' u- ?0 L' ~4 n; k/ w( Z' L "ToleranceTypeUnilateralBelow",, j& W( g* h8 L" m
"ToleranceTypeBasic",
( \! l* u5 |/ W* P "ToleranceTypeReference",; N& @& v: F7 e7 V
"ToleranceTypeLimitLargerFirst",5 f ]4 Y6 a( |; J d: Z, ~* _0 n
"ToleranceTypeLimitLargerBelow",
9 ^( a. P6 I3 e) X% `5 s "ToleranceTypeLimitsAndFits",, F0 l& }! ], F* `6 c
"ToleranceTypeNotToScale",) Q. \' i( U4 V \* F+ X& P
"ToleranceTypeDiameterReference",
3 b1 C! G) T- t: P( J: A# b "ToleranceTypeBasicNotToScale"
8 f, `0 X, b$ }/ K. U };
& s" S5 U. k5 R, X/ s% E3 S# f# S* U- b: u- x& }7 a
while( (theDim=select_a_dimension()) != 0 )! S2 k' a# m5 Q' L- x) f1 S
{
0 g" e) z4 G- T5 b out.str(""); out.clear();
# t) D8 e$ h& [5 j" a if(! lw->IsOpen() ) lw->Open();: G& w! A3 ^/ {0 s
! W* o7 w( |, ?3 N3 `
out << "Selected Object: " << theDim->Tag() << endl;- s- ^! I* u8 V+ w+ n5 R9 o' V, x; e
- M5 B) b0 ]) X1 h- [6 w
std::vector<NXString> mainTextLines; 0 @2 I. I. J5 f% T( U0 m2 m
std::vector<NXString> dualTextLines;
# T. ~4 u' O5 w theDim->GetDimensionText(mainTextLines, dualTextLines);
$ O7 [7 U6 i# E5 R7 |( o for( int ii=0; ii<mainTextLines.size(); ii++)
; {+ i5 e5 `' p- U% Y out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
6 `. D" S# z* j |$ Q for( int ii=0; ii<dualTextLines.size(); ii++) j) j2 |, q! a e
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;( N* T$ g! \: T, a+ S) S0 Y
4 V5 h; Q0 C3 \$ F9 a, m' V a) K bool refFlag = theDim->ReferenceDimensionFlag();
: G- P N2 V1 G out << " ReferenceDimensionFlag: " << refFlag << endl;; P0 a% j- w1 Q; [* q ?: Q8 c
+ Z6 }6 A: ^" O4 I x5 @- o
int tolType = (int) theDim->ToleranceType();
4 c V* Z% f6 c& Z2 J" d out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl; g7 }- m( `* }' D
$ c& C' e* q" F6 G ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
( \* [6 K. d: m9 z0 F7 ^ std::vector<TexTComponent*> textComps = theData->GetTextComponents();
1 f% u6 Y2 M$ I7 f for( int ii=0; ii<textComps.size(); ii++). q0 \: j8 E7 ?# [5 X
{
8 I. C1 U! |' K' j6 g4 f8 ~( \( n: h std::vector<NXString> compText = textComps[ii]->GetText();2 U* l! Y; V( S/ d
for( int jj=0; jj<compText.size(); jj++ )
" [! O9 I# P+ D5 `% N. x! q out << " Component Text: " << compText[jj].GetText() << endl;
" X% O: T) F3 {: Q }
+ y$ _5 x. @8 P2 j
- K1 Z( w# N/ u, `4 a! R int subtype;
7 R: }) O9 @* I& i( D, ] double origin[3];
- b9 s. `3 I7 [3 I8 H1 G6 c UF_DRF_dim_info_t *info;) S0 r/ z8 y) b" p5 W! G
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));3 d5 l+ J, H% Y& p0 C: |
for (int ii = 0; ii<info->num_text; ii++)
2 V5 q {+ U0 m6 w% r if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)
; t3 e; L/ M1 @* Q0 ~* ]0 k$ a for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)* ]) m4 n% `& a' ~$ s" U0 z2 @
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;: ~1 j4 |+ ?. U$ j6 h
UF_CALL(UF_DRF_free_dimension(&info));
- X2 z; f7 t- P+ I0 g. |* f# Q
2 ^8 {* l; m2 a lw->WriteLine(out.str().c_str());9 z! V+ F* Y. J7 I X+ q1 Z( x3 I# R
# k+ x+ g/ M8 w# l* h2 X1 x
} // while5 m# H D" R4 X" x/ R% L0 S/ ]
}' [: ~ R; C: Q2 _) K" B
|
|