各位大神求帮忙,我是ug开发新手,打算做一个电极设计中用到的自动盒子,打算用两个对角点创建盒子。代码写了一点,下面不知道该怎么弄,大家能不能帮忙看一下,十分感谢!!!: \$ N6 p% {4 c. L
public int apply_cb() , e* }: i9 R0 p/ H {: [- {% R# e% m6 ^, F3 w
UFSession theUFSession = UFSession.GetUFSession();0 i, K/ K% z4 l3 `1 @7 f' S
Part workPart = theSession.Parts.Work; / ]3 F& e' |0 d' i Part displayPart = theSession.Parts.Display;% W, R) a2 t4 G3 p1 I& ?3 |0 [
+ o6 B, ?2 ]8 u* L% U( K 0 a, }1 Y& Y& m3 j# W double xMax = -999999999; & l2 ~& X" f8 g( ]1 A double yMax = -999999999; ' I' T/ G( H# H double zMax = -999999999;; r! h+ p! ^- J( k+ d ^4 a
double xMin = 999999999;# o+ w6 ~3 n0 M1 n( z, a5 j2 C/ R
double yMin = 999999999;" G2 k& S+ i& `5 _" z, i i) w, S
double zMin = 999999999; ?% ]0 M& e. p6 o$ @1 N- D
N# K* [. s# K6 _3 R* R% V1 X) ~# d! x- D- |
foreach (TaggedObject obj in face_select0.GetSelectedObjects()) & L& s1 d3 a5 K7 ?& H {* b; C) ?0 U1 B
if (obj is Face) ! U5 L- c' b- P9 V { e) L: x, |- F9 |
Face face = obj as Face;' K% q1 D( F; z" J+ u
double[] cornes = new double[6];; H* h* Q; G5 |; v3 C8 S, J A1 f
theUFSession.Modl.AskBoundingBox(obj.Tag, cornes); / O* h2 R0 y5 b) C" I$ Z4 j4 y0 e" y# j7 `
if (cornes[0] < xMin) B" ~8 F9 _# E xMin = cornes[0]; - |9 X R1 O5 t if (cornes[1] < yMin)+ }6 P: Y1 Z" ~: X
yMin = cornes[1]; * f9 i" \- p& C. U8 m if (cornes[2] < zMin) , ?0 S2 e1 P5 e- v zMin = cornes[2];/ {2 T. X* T) Q Q* @* T" E
if (cornes[3] > xMax)/ ]9 y% h- z5 u2 V* X- T
xMax = cornes[3];4 q" Z; @& p1 e
if (cornes[4] > yMax) ' B9 Z6 H" ~9 ?' q; o yMax = cornes[4]; 2 [0 F' G2 S) i# I5 L if (cornes[5] > zMax)6 \3 i( b$ l I! R( Q0 y
zMax = cornes[5]; 7 L8 b2 n, _- I: z! i, x NXOpen.Features.DatumCsys datumCsys1 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject(""); ( q) j' }" r2 m, X3 d: ` Point point1 = (Point)datumCsys1.FindObject("xMin-10,yMin-10,zMin-10"); . r y- r/ F5 h4 |( c NXOpen.Features.DatumCsys datumCsys2 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject("");+ n3 p6 \5 T, u$ a
Point point2 = (Point)datumCsys2.FindObject("xMax+10,yMax+10,zMax+10"); ) m, I. z3 W& u1 a; ?5 g& G ' k! M& T( i5 I% L6 T; s 6 F# W5 D s2 z4 o# C8 a) a