各位大神求帮忙,我是ug开发新手,打算做一个电极设计中用到的自动盒子,打算用两个对角点创建盒子。代码写了一点,下面不知道该怎么弄,大家能不能帮忙看一下,十分感谢!!!8 h$ J$ ^( X7 j- j( [9 f
public int apply_cb(): Y/ ^$ m& @6 g% ^7 B% d- Q$ _: ?
{ * [: D4 x, V& E: \% i3 D4 s8 E UFSession theUFSession = UFSession.GetUFSession();4 G) S3 U6 G" {# ]
Part workPart = theSession.Parts.Work; 1 o7 G3 [5 W8 s Part displayPart = theSession.Parts.Display; ! A7 \( h1 g ?8 e* ] J, j1 x8 d6 ]' Q% p+ Z/ y( q
4 ^: O6 [: O! x) E e c double xMax = -999999999; ! d J# O+ v, n# Y, E) A9 S | double yMax = -999999999;$ W9 J! X' F! s, O. k: |& Y( x7 K7 m/ n
double zMax = -999999999;8 `! \/ j; s- S. i i, g& L L
double xMin = 999999999; - T6 Z+ w6 F3 X. F+ b' H- N double yMin = 999999999; 6 W5 Y" S- m8 N double zMin = 999999999;& n! W+ R" s9 s" e' ~
+ z0 U6 i8 S; T+ B- b' I- ]. P" d T- m0 t$ {/ @& M2 x
foreach (TaggedObject obj in face_select0.GetSelectedObjects()) ) Y0 R @3 t7 e1 z { ) T! K" \# b" n8 q- D+ w if (obj is Face)( m* a1 A' \6 F0 u9 }
{: H& k. z& m: Q ~/ T7 V9 U$ X
Face face = obj as Face;: K! T, v i8 G6 L
double[] cornes = new double[6];8 U& c. _5 C! O9 V) s
theUFSession.Modl.AskBoundingBox(obj.Tag, cornes);; e- V8 T8 T" a- M" T* C1 l
2 F- a, Z% e: k. i if (cornes[0] < xMin)4 F; M1 s" U! ~( M" C4 s1 m# Y
xMin = cornes[0]; % m/ `0 M. d+ g1 @$ s' S) Q) O, t if (cornes[1] < yMin)7 S: Y& d: t! p3 b5 k" S! a) w
yMin = cornes[1]; ( v8 [3 L2 e0 F- Q+ Y$ j) i W if (cornes[2] < zMin)5 Y5 I- }) R- f: _4 G: @9 ]* N- l
zMin = cornes[2]; + D* M2 f( W2 ~$ d0 N o if (cornes[3] > xMax)0 m0 d& i0 b) Q- E0 _- a; n
xMax = cornes[3];9 W- I/ H0 g$ z, A
if (cornes[4] > yMax) . n$ `+ B2 u2 M" \ yMax = cornes[4]; / [/ g: g0 i% i4 h4 O! v if (cornes[5] > zMax). l1 u/ {! W* i- C/ ~7 @
zMax = cornes[5];0 Z/ F! R% {0 v k4 Q& M; ^
NXOpen.Features.DatumCsys datumCsys1 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject(""); 1 |) S; k- b. D- t Point point1 = (Point)datumCsys1.FindObject("xMin-10,yMin-10,zMin-10");$ w6 k: T9 a1 M0 X- o
NXOpen.Features.DatumCsys datumCsys2 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject(""); + w9 Q" Z) b- ^+ [1 Z4 Z Point point2 = (Point)datumCsys2.FindObject("xMax+10,yMax+10,zMax+10");1 u$ b: A* Q- ]8 T9 E$ `
( d8 p* c% `1 h+ Y! Y: Z
5 p& S" {" O# ~