PDA

View Full Version : autocad VBA problem, union after polar array Options



clarence_cad
10-16-2005, 10:18 PM
i want to union a big cylinder with no. of small cylinder,since the small cylinder is create by polar array, the small cylinders after polar array are "variant" not are "acad3dsolid", so the union command is not work ...so what can i do??Thanks!



Public Sub crownplane()

Dim bigcylinder As Acad3DSolid
Dim smallcylinder As Acad3DSolid
Dim crowncen(0 To 2) As Double

crowncen(0) = 0: crowncen(1) = 0: crowncen(2) = 0

Set bigcylinder = ThisDrawing.ModelSpace.AddCylinder(crowncen, crownradius, crownheight * 1.2)
Set smallcylinder = ThisDrawing.ModelSpace.AddCylinder(crowncen, teethradius, crownheight)


Dim noofcylinder As Integer
Dim angletofill As Double
Dim polarSmallcylinder As Variant

noofcylinder = 4
angletofill = 6.28

polarSmallcylinder = smallcylinder.ArrayPolar(noofcylinder, angletofill, crowncen)


bigcylinder.Boolean acUnion, polarSmallcylinder

End Sub

Tommy
10-17-2005, 06:54 AM
Hi clarence_cad,

Welcome to VBAExpress! :yes

Using your example I added:


crownradius = 10
crownheight = 20
teethradius = 15


Not sure if this is what you are trying to do but .Boolean doesn't accept arrays. So to try and get what you want I tried this with some success :

Public Sub crownplane()
Dim bigcylinder As Acad3DSolid
Dim smallcylinder As Acad3DSolid
Dim mSolid As Acad3DSolid
Dim crowncen(0 To 2) As Double
Dim mI As Integer

crowncen(0) = 0: crowncen(1) = 0: crowncen(2) = 0

crownradius = 10
crownheight = 20
teethradius = 15

Set bigcylinder = ThisDrawing.ModelSpace.AddCylinder(crowncen, crownradius, crownheight * 1.2)
Set smallcylinder = ThisDrawing.ModelSpace.AddCylinder(crowncen, teethradius, crownheight)
ThisDrawing.Regen acActiveViewport

Dim noofcylinder As Integer
Dim angletofill As Double
Dim polarSmallcylinder As Variant

noofcylinder = 4
angletofill = 6.28

polarSmallcylinder = smallcylinder.ArrayPolar(noofcylinder, angletofill, crowncen)
For mI = 0 To UBound(polarSmallcylinder)
Set mSolid = polarSmallcylinder(mI)
bigcylinder.Boolean acUnion, mSolid
Next
Set mSolid = Nothing
ThisDrawing.Regen acActiveViewport
End Sub



HTH

clarence_cad
10-17-2005, 10:27 PM
Thanks a lot!! Tommy.