|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! H5 j8 u( A- X( b- {2 FDimension* plmhome::select_a_dimension()* k ~. o+ U" [8 R- R$ k+ d
{1 C+ @8 d- C+ q( F' t1 R2 r6 }; j) V
// ask user to select a label
; ^0 B# m$ w( J UI *ui = UI::GetUI();( L' ^+ k5 u! e, M+ d5 Z$ H6 {, d
Selection *sm = ui->SelectionManager();
$ @; b i1 Q5 K! ^* u& F' t9 E( }! } NXMessageBox *mb = ui->NXMessageBox(); // as of NX5/ ~: g7 l, J* ?7 |& a5 U# T2 c
7 T; P6 A7 O$ s( s
NXString message("Select Dimension:");
/ F& `, n" _, p& {0 u NXString title("Select Dimension");
; K6 C2 @5 I. _( ]/ l6 U Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;1 `+ i( H; A: [+ q2 a# L
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
! B9 z1 D) T; H# r6 Q4 P8 ]) M bool include_features = 0;
, W$ j: V/ b8 \( T1 m9 b+ ^/ m bool keep_highlighted = 0;
* T5 z% _% z( T# w2 X) \2 H8 i
. ^. B7 }7 s/ W- |$ ?1 _ // Define the mask triple(s)
! i+ {) D7 ?- a8 ^3 [/ o9 d std::vector<Selection::MaskTriple> mask(1);# |7 i# p7 U1 Y
mask[0] = Selection::MaskTriple( UF_dimension_type, 0, 0 );5 m1 o& C E% q; r) D
Point3d cursor;" X/ y5 j& G7 m7 F0 k `
TaggedObject *object;
6 D" @ V( Q' a- i3 G/ r) q3 s" R
// Select objects using filter defined by mask triples
; Q# Q8 N1 T5 T- w* m, y- U" B Selection::Response res = sm->SelectTaggedObject(, c) r' N9 |& L3 U ` h
message, title, scope, action, include_features,
8 t, K/ e: E) z0 a( Z keep_highlighted, mask, &object, &cursor );; r0 X/ e+ n4 ~( o9 A6 f! o. e
. E+ p; ^5 L$ `2 s5 Y if( res == Selection::ResponseObjectSelected )
- m$ o7 `6 B, V* g6 Y {
9 O3 i5 k$ e. Q6 \) C Annotations::Dimension *theDim;7 T6 i+ O5 F F- ]
. S4 `! R3 D& W p) K/ D
// this doesn't work and 'note' will be a zero pointer, see PR-1850850( |9 P) {% g6 G/ W( `- r6 J
//note = dynamic_cast<Annotations::PmiNote *>(object);& F/ v, K0 f) ]; p9 {+ u$ t3 z
% h* Y7 Y9 _, I8 o // this works as a workaround
- b" d0 \' v' [0 ^# G( F- Z1 G theDim = (Annotations::Dimension *)(object);
( z# ?" _: d0 `! {, { return theDim;
( N6 g' g# \. D0 M2 P. B6 z }
6 k$ u0 w( J2 d3 H* l1 c, G
1 G1 K9 ]/ ~% j5 A return 0;0 s+ D2 C7 T+ l- b$ S$ U6 F
}
1 k9 }- t1 w+ `9 w4 L6 K8 e
# f$ Z: h; f% q& C0 {* d
# i; e. C, a2 c2 _- O4 y* X0 E3 m/ |
; x8 L( z* ^2 @# ~5 \void plmhome::do_it()4 ]4 f9 ~- Y* V; F
{6 [6 Y( Y8 ~5 C) E E* g ?! [
workPart = theSession->Parts()->Work();$ f7 \) w8 I; f8 L
Part *displayPart = theSession->Parts()->Display();
0 Z Q, a, l: |2 y stringstream out;
% e* p3 O2 F, x6 B V# E Dimension *theDim = 0;
9 c1 q# ~# A7 Q1 R
. u- s l) w" J NXString tolTypeStrings[] =
- a/ f+ y* I+ S {
2 V7 i, D, I6 g* ]) N9 x8 P, ` "ToleranceTypeNone",
/ ^6 ~3 O0 Q5 Z: [. }, ? "ToleranceTypeLimitOneLine",% y* g" k3 V, E1 K1 r/ ?
"ToleranceTypeLimitTwoLines",& V8 k( `2 k0 k: q
"ToleranceTypeBilateralOneLine",
7 S4 C7 W o4 ?# }; K "ToleranceTypeBilateralTwoLines",
! p/ r5 Z1 ^3 ] "ToleranceTypeUnilateralAbove",
8 v3 ? l ^8 P; Q" t" G "ToleranceTypeUnilateralBelow",
3 S1 J( v9 ?; ` P "ToleranceTypeBasic",
# \, X9 I' E0 T! f& r# d "ToleranceTypeReference",
+ `9 G# S0 M' [4 C! e4 _ "ToleranceTypeLimitLargerFirst",
: E6 I. ?& c/ K( D. E+ E5 T$ ] "ToleranceTypeLimitLargerBelow",
3 B- ~4 v/ Z( `( v; o- ? "ToleranceTypeLimitsAndFits",
/ x `/ @; r8 w$ [( D4 Q, R! I* I "ToleranceTypeNotToScale",0 R( b ` Y. E$ j3 j% t6 w
"ToleranceTypeDiameterReference",
0 F' h9 c- f) @! G, I. w/ _ "ToleranceTypeBasicNotToScale" . g* V* Q+ K8 I, P8 q& Z: D
};
1 x% t. p o! F0 [' l [! c* D" W6 G' K" v
while( (theDim=select_a_dimension()) != 0 )
. v; q8 Q9 |$ A1 a {
5 M) m1 q9 p5 U2 @+ c0 H! B% d2 m out.str(""); out.clear();
/ J' r/ [$ e$ B% v% S if(! lw->IsOpen() ) lw->Open();' z" G- M. F9 ]2 R* }5 z
/ s: X- c |' g( o: N
out << "Selected Object: " << theDim->Tag() << endl;
9 d4 S8 x* S) p7 V* K5 k) o' X5 E& F, g) _$ b2 P& @( L1 L4 ]5 T
std::vector<NXString> mainTextLines;
5 |* T) q# }% ?2 r! n std::vector<NXString> dualTextLines;
9 y2 K- G% H+ R: T theDim->GetDimensionText(mainTextLines, dualTextLines);2 J' T2 O# D% N" T1 x1 G2 c' ~
for( int ii=0; ii<mainTextLines.size(); ii++)9 h" v P* j8 \) {( i9 b- W+ ~, I
out << " MainTextLine: " << mainTextLines[ii].GetText() << endl;, x \/ h$ R, q" A7 {1 A1 t* G6 S
for( int ii=0; ii<dualTextLines.size(); ii++) K, y2 O: K% K/ @7 ]9 _
out << " DualTextLine: " << dualTextLines[ii].GetText() << endl;5 p# x% m/ ^6 c) ^ x8 y
$ G3 |) B/ y! S7 b
bool refFlag = theDim->ReferenceDimensionFlag();7 @5 Q% [" M; x+ q
out << " ReferenceDimensionFlag: " << refFlag << endl;
8 a" i5 _& }7 g7 ^. L% B$ v8 t { N$ w
int tolType = (int) theDim->ToleranceType();+ J; F+ j5 t7 i9 M" J: M5 E
out << " ToleranceType: " << tolTypeStrings[tolType].GetText() << endl;
2 b* e$ G! S# T% V U+ B4 e9 |: j
ComponentData *theData = displayPart->Annotations()->CreateComponentData(theDim);: i3 d4 d9 `$ T* S
std::vector<TexTComponent*> textComps = theData->GetTextComponents();3 j; _: O6 ?( {( h" e
for( int ii=0; ii<textComps.size(); ii++)4 X) `$ C* C4 G8 T& a* X) X
{
, w5 G) C! r! v U1 z5 _' T std::vector<NXString> compText = textComps[ii]->GetText();
w" b8 ?- {$ r, @; |% L for( int jj=0; jj<compText.size(); jj++ )
* f/ y! D F$ D s out << " Component Text: " << compText[jj].GetText() << endl;, {1 d& v$ {! u6 \! ?# o' t
}
0 e! Y# Y5 [% b! W7 ?1 ?
& ], G. C" n! v0 @: d int subtype;2 P" O" Z$ l4 U, p, Q; M5 Q
double origin[3];! r; a d4 T [
UF_DRF_dim_info_t *info;6 k7 O3 p$ F8 m: K) M: J
UF_CALL(UF_DRF_ask_dim_info(theDim->Tag(), &subtype, origin, &info));
2 [; q2 k2 R Y$ E X, }: v for (int ii = 0; ii<info->num_text; ii++)4 A) T2 @; L$ y5 d
if (info->text_info[ii].text_type == UF_DRF_DIM_TEXT)* n1 x$ I* b* M# c4 r8 q% D
for (int jj = 0; jj < info->text_info[ii].num_lines; jj++)4 ? e; v5 Q5 }0 Y. T# e/ S# G: i7 Q; P
out << " UF_DRF_ask_dim_info Text: " << info->text_info[ii].text[jj].string << endl;/ M t+ }/ u- q$ N' ^
UF_CALL(UF_DRF_free_dimension(&info));
7 \) d$ ?: R. j7 A! H
0 g- C- [; A0 k$ h5 o! M' k lw->WriteLine(out.str().c_str());& F! k# b; U1 m! @
9 ~( i6 t& G% c2 A2 c+ }
} // while
4 n, r& Z7 y( n}
" I9 o% G) @8 Z [4 ]9 R |
|