CadDesigner
Programmer
Hi guys,
If am trying to make a little program in VBA that subtracts 2 ellipse regions.
You'll find the program-code below.
When executing, everything goes well, except for the subtracting in the last sentence.
An error is given.
I can't figure it out, possible something stupid I oversee.
I am working with autocad 2000(i)
Can anyone give me a hint/ correct the code what I'm doing wrong?
Thanks,
Paul
If am trying to make a little program in VBA that subtracts 2 ellipse regions.
You'll find the program-code below.
When executing, everything goes well, except for the subtracting in the last sentence.
An error is given.
I can't figure it out, possible something stupid I oversee.
I am working with autocad 2000(i)
Can anyone give me a hint/ correct the code what I'm doing wrong?
Thanks,
Paul
Code:
Sub startup()
Dim EllipseObj(0 To 0) As AcadEllipse
Dim SmallEllipseObj(0 To 0) As AcadEllipse
Dim RegObj As Variant
Dim SmallRegObj As Variant
Dim Radius As Double
Dim RadiusY As Double
Dim SmallRadius As Double
Dim SmallRadiusY As Double
Dim Center(0 To 2) As Double
Dim RadiRatio As Double
Dim RadyPoint(0 To 2) As Double
Center(0) = 0: Center(1) = 0: Center(2) = 0
Radius = 100
RadiusY = 60
SmallRadius = 80
SmallRadiusY = 40
' Create ellipse 1
RadiRatio = RadiusY / Radius
RadyPoint(0) = Radius: RadyPoint(1) = 0: RadyPoint(2) = 0
Set EllipseObj(0) = ThisDrawing.ModelSpace.AddEllipse(Center, RadyPoint, RadiRatio)
' Create ellipse 2
RadiRatio = SmallRadiusY / SmallRadius
RadyPoint(0) = SmallRadius: RadyPoint(1) = 0: RadyPoint(2) = 0
Set SmallEllipseObj(0) = ThisDrawing.ModelSpace.AddEllipse(Center, RadyPoint, RadiRatio)
' Create ellipse region 1&2
RegObj = ThisDrawing.ModelSpace.AddRegion(EllipseObj)
SmallRegObj = ThisDrawing.ModelSpace.AddRegion(SmallEllipseObj)
' Subtract both ellipse regions
[COLOR=red]RegObj.Boolean acSubtraction, SmallRegObj[/color red]
End Sub