Regions - Adding elements

Regions - Adding elements

Anonymous
Not applicable
347 Views
3 Replies
Message 1 of 4

Regions - Adding elements

Anonymous
Not applicable
I have a series of lines and arcs that create what I believe to be a closed loop. When I run the following code:

Dim Elem As AcadEntity, regionObj As Variant, oLine As AcadLine, solidObj As Acad3DSolid

For Each Elem In ThisDrawing.ModelSpace
'Find the path of the extrusion
If Elem.Layer = "Path" Then
If Elem.ObjectName <> "AcDbLine" Then
Set oLine = Elem
End If
'Find the elements of the extursion
Else
If Elem.ObjectName = "AcDbArc" Or Elem.ObjectName <> "AcDbLine" Then
regionObj = ThisDrawing.ModelSpace.AddRegion(Elem)
End If
End If
Next

Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), oLine)

ZoomAll

I get the error "Invalid Object Array" on the line where I'm trying to add the elements to the region.
0 Likes
348 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You create an array of objects (lines, arcs, etc) then you use that array as
the argument for the AddRegion method. It's difficult follow exactly what
you're attempting to do, could you please explain it further?

Joe
--

wrote in message news:5196951@discussion.autodesk.com...
I have a series of lines and arcs that create what I believe to be a closed
loop. When I run the following code:

Dim Elem As AcadEntity, regionObj As Variant, oLine As AcadLine, solidObj As
Acad3DSolid

For Each Elem In ThisDrawing.ModelSpace
'Find the path of the extrusion
If Elem.Layer = "Path" Then
If Elem.ObjectName <> "AcDbLine" Then
Set oLine = Elem
End If
'Find the elements of the extursion
Else
If Elem.ObjectName = "AcDbArc" Or Elem.ObjectName <> "AcDbLine" Then
regionObj = ThisDrawing.ModelSpace.AddRegion(Elem)
End If
End If
Next

Set solidObj =
ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), oLine)

ZoomAll

I get the error "Invalid Object Array" on the line where I'm trying to add
the elements to the region.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Try this - make sure path is a polyline

Dim Elem As AcadEntity, i as integer, regionObjs() As AcadEntity, regionObj
As Variant, MyRegion As AcadRegion, oLine As Object, solidObj As Acad3DSolid
i = 0
For Each Elem In ThisDrawing.ModelSpace
'Find the path of the extrusion
If Elem.Layer = "Path" Then
If Elem.ObjectName <> "AcDbPolyline" Then
Set oLine = Elem
End If
'Find the elements of the extursion
Else
If Elem.ObjectName = "AcDbArc" Or Elem.ObjectName <> "AcDbLine" Then
ReDim Preserve (regionObjs,i)
Set regionObjs(i) = Elem
i = i + 1
End If
End If
Next
regionObj = ThisDrawing.ModelSpace.AddRegion(regionObjs)
Set MyRegion = regionObj(0)
Set solidObj =
ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(MyRegion,oLine)

wrote in message news:5196951@discussion.autodesk.com...
I have a series of lines and arcs that create what I believe to be a closed
loop. When I run the following code:

Dim Elem As AcadEntity, regionObj As Variant, oLine As AcadLine, solidObj As
Acad3DSolid

For Each Elem In ThisDrawing.ModelSpace
'Find the path of the extrusion
If Elem.Layer = "Path" Then
If Elem.ObjectName <> "AcDbLine" Then
Set oLine = Elem
End If
'Find the elements of the extursion
Else
If Elem.ObjectName = "AcDbArc" Or Elem.ObjectName <> "AcDbLine" Then
regionObj = ThisDrawing.ModelSpace.AddRegion(Elem)
End If
End If
Next

Set solidObj =
ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), oLine)

ZoomAll

I get the error "Invalid Object Array" on the line where I'm trying to add
the elements to the region.
0 Likes
Message 4 of 4

Anonymous
Not applicable
That seems to work great.

Thanks,
Jeff
0 Likes