|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
$ t% m. T) r6 s ]' X8 L# ]+ |Dimension* plmhome::select_a_dimension()' z/ l0 I4 W: v }! j# r! Q1 G
{+ Z1 S3 C$ M) p5 I6 p
// ask user to select a label9 Q2 ?+ ^4 {. @% ^. y: }' C
UI *ui = UI::GetUI();" M- v% g& H$ m, }, r# l4 T4 o; R
Selection *sm = ui->SelectionManager();
' Q/ t& g1 s" A( t% M; w8 | NXMessageBox *mb = ui->NXMessageBox(); // as of NX5! @& E8 l2 B+ Q q2 q
; h" ?% A! A% R% m0 Y0 H& i6 f+ K
NXString message("Select Dimension:");6 c. A6 T u; \, n5 z4 Y9 S/ J$ G
NXString title("Select Dimension");$ u7 _+ O/ P4 X3 w5 y$ ~6 \
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
- P- l8 L" R$ m! \( a% @ Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
4 m1 t5 y* K7 Y: k$ E; W7 i' s bool include_features = 0;
5 G( i( n5 T# s$ v1 _$ T2 ^ bool keep_highlighted = 0;
2 k" N6 z5 b1 m( m, D' o6 t* j: P s5 `8 _5 R
// Define the mask triple(s)
: b9 _) K* K2 n& {5 o6 K std::vector<Selection::MaskTriple> mask(1);# a Z% `9 i h0 A0 T- Q! D5 U
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );6 l* ~+ q+ ]# w, n7 T
Point3d cursor;: W3 s9 ^2 Z/ i2 x3 I
TaggedObject *object;( e& k4 }( c/ t( X" W& E6 o
$ J% b4 w, o0 D1 J/ C9 S- Y/ z
// Select objects using filter defined by mask triples
0 b0 W9 e, ?0 I+ s" R, B Selection::Response res = sm->SelectTaggedObject(; {7 F6 O+ k; F" F1 J8 R) u
message, title, scope, action, include_features,
3 B; [6 ]' L4 S. b keep_highlighted, mask, &object, &cursor );
- a4 L$ v5 l+ I/ R: M- a; |7 {7 a" Y; w) _
if( res == Selection::ResponseObjectSelected )9 Y# ` I) Y( D1 a( d @
{* B3 m* [. |* x) b7 P- A, a
Annotations::Dimension *theDim;, n6 @/ D% |$ H& O/ E0 _9 @9 H
+ q, o8 I4 r, C5 g& O1 b3 S0 X // this doesn't work and 'note' will be a zero pointer, see PR-1850850
" o5 h! ~& W& N3 x d: O //note = dynamic_cast<Annotations::PmiNote *>(object);/ n. r* R: L7 p* B. F. L
( P0 x+ T7 g$ E- C4 K9 @& t5 B
// this works as a workaround4 \$ l) O3 [- Y" Q+ N9 a4 w2 e
theDim = (Annotations::Dimension *)(object);
9 J, P4 W, s. N3 z return theDim;
. s2 V6 {, C: F0 }3 p3 O }
( U; `$ g) T9 F
7 K* Y0 C# I3 J8 D! N% n$ J return 0;
7 _: {6 c6 l3 o M}
: g! g' m. ^3 e4 e3 w/ K' z- L# F J: b) e" D; @
. O1 S: d+ ^* \0 I$ W$ c5 a( i$ U A8 r: `' V }
! t3 A5 i0 l2 P! Rvoid plmhome::do_it()8 ]1 Y8 v6 r5 L' x9 ]% O! j
{
3 k" i- ]2 r& Y workPart = theSession->Parts()->Work();3 h2 b$ H; e5 o' o9 H) N6 I# Y
Part *displayPart = theSession->Parts()->Display();8 O$ R7 G4 r7 } X
stringstream out;4 k6 y. ? ]0 C8 R$ n" ]$ r1 a4 A
Dimension *theDim = 0;
$ T: `8 x# _3 Y8 a
% _% u+ y7 X! q NXString tolTypeStrings[] = 3 _0 t! L* r' ]/ w. \$ V
{
, j( g; q, c# O% n* X* z8 h "ToleranceTypeNone",8 ]# N9 g- L3 D( {5 y" G, y
"ToleranceTypeLimitOneLine",
4 n( u+ l0 m1 ~) N2 {$ P, i "ToleranceTypeLimitTwoLines",
1 K8 R* J: ^9 a "ToleranceTypeBilateralOneLine",
0 l/ M4 X+ j% O# G$ h+ [+ p+ W "ToleranceTypeBilateralTwoLines",) _& @. Z" a; A# k+ ]
"ToleranceTypeUnilateralAbove"," }) O9 G8 p' w, y
"ToleranceTypeUnilateralBelow",
; j4 E! f: a% ~" p "ToleranceTypeBasic",
- n4 \# K9 _* }, ] "ToleranceTypeReference",+ |, F; U; M2 e7 X! t
"ToleranceTypeLimitLargerFirst",/ c2 C6 {2 C- V+ P
"ToleranceTypeLimitLargerBelow", e' E% C- O, \+ l
"ToleranceTypeLimitsAndFits",
+ G: y0 g% M# M; _ "ToleranceTypeNotToScale",
. ?, p4 o/ u7 x1 t: L "ToleranceTypeDiameterReference",
x+ R% }0 F! N h( ~8 ^$ N( R& Q "ToleranceTypeBasicNotToScale" . a( z- s( V x
};
, L5 m6 p0 w. v4 V- v1 H$ R
& F/ q0 W/ f1 a# v0 Y0 d while( (theDim=select_a_dimension()) != 0 )
+ z5 B$ ]' H2 {% i5 g' x {
' r( g+ o0 C3 L: {/ I r+ h- n out.str(""); out.clear();
, l2 O! c3 P( _/ N: F- g) H if(! lw->IsOpen() ) lw->Open();
$ L/ y' z, H( ^ G' ~; m g( ?% W; X+ K: v2 V$ a& N
out << "Selected Object: " << theDim->Tag() << endl;0 P. t8 O! ?0 E- o
+ P& N& f2 ^$ C5 Y( F2 s& R0 M std::vector<NXString> mainTextLines; Y }/ o+ Y% A
std::vector<NXString> dualTextLines; 0 I! P. S3 s; c9 W
theDim->GetDimensionText(mainTextLines, dualTextLines);
* m/ _5 c5 `* B' j- X/ H for( int ii=0; ii<mainTextLines.size(); ii++)" `* @6 t2 X- @, d* ]8 x: }
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;
3 f9 x9 J4 m- z for( int ii=0; ii<dualTextLines.size(); ii++)
+ t$ ^3 o4 A% Y9 T7 P1 q out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;6 G% F: T( W r7 y3 M6 A3 {
$ e0 f8 _# a7 L7 D8 @, U ?
bool refFlag = theDim->ReferenceDimensionFlag();( p2 m' O( O( |2 y: j6 z k
out << " ReferenceDimensionFlag: " << refFlag << endl;
: \! b% ?2 h8 F7 `& ^, d2 a5 t( B: u. a, L8 ]. S( `* q0 ?( Q
int tolType = (int) theDim->ToleranceType();
# | g7 ~1 b& p( `4 N. l/ p out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
& m2 k6 C. ~ ? f$ ]4 F) [) B. Q4 i/ j. o
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);
# T5 I7 @( L: i std::vector<TexTComponent*> textComps = theData->GetTextComponents();
; L! w) d" [! |3 i B. O" _ v for( int ii=0; ii<textComps.size(); ii++)8 f- d! O' L8 J, R; r
{& `# ~- S) c. c' w% a2 o5 D4 [0 `
std::vector<NXString> compText = textComps[ii]->GetText();# q, ?# Z/ |& {. M. _3 o5 j" A1 f' v
for( int jj=0; jj<compText.size(); jj++ )
# a; t% x3 }2 L% C: t1 Q0 B! M out << " Component Text: " << compText[jj].GetText() << endl;: Z; I. Q2 \, k' w3 g' [
}8 u/ o$ A7 U/ Y. [
* |3 N* r& w1 J- Y& y5 q: ]: z& T
int subtype;; i2 `. y) D1 R3 A0 i9 x
double origin[3];
( _1 F1 p/ V0 X# _# a1 D0 A( n UF_DRF_dim_info_t *info;8 L7 L, o5 g9 H. N' a, e
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));7 } G7 n4 ^, H6 v2 S
for (int ii = 0; ii<info->num_text; ii++)) U$ z" W( g# L8 U
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT). \! \! q2 o. i9 g
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)9 b6 B$ }* l. s$ t
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;) B" z9 l: v. m; w
UF_CALL(UF_DRF_free_dimension(&info));) C! \6 V# o3 A3 [( ^+ g( y
- M* H# Z) X- @ lw->WriteLine(out.str().c_str());
8 Z8 |- w4 L) \7 {' s$ K
* t) a7 L# _6 G1 y" ~ } // while. ]2 e7 p5 n" \
}2 o. s$ w# M4 u7 a
|
|