Help with Multiple Regions in an Array var

Help with Multiple Regions in an Array var

Anonymous
Not applicable
249 Views
3 Replies
Message 1 of 4

Help with Multiple Regions in an Array var

Anonymous
Not applicable
I am selecting a Peeline 🙂 one by one & converting them to regions. I would like to know if it’s possible to store these regions as I create them in an array var so that I could later do a Boolen acUnion on them. Please provide an example if possible. Thanks in advance.

William
0 Likes
250 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You can use a Collection or Dictionary which are dynamic in size (size increased as needed), to store your regions.

When your done use something like the follwoing to fill
your array. Notice a collection is base 1 and the array is
base 0 by default.

ReDim plineArr(coll.Count - 1)
For i = 0 To coll.Count - 1
Set plineArr(i) = coll(i + 1)
Next i
0 Likes
Message 3 of 4

Anonymous
Not applicable
Ok, I have provided part of the code. I have tried almost everything but I still can't get it to work. I have pasted the code @ the location where I think it needs to be without editing it. Please show me how u declared the PlineArr and feel free to edit my code the correct way. Thanks.

William

ThisDrawing.Utility.GetEntity oEnt, vPick, "Select pline to create region "

If TypeOf oEnt Is AcadLWPolyline Then

Set oRegObjects(0) = oEnt
Set PlineArr = oEnt

oRegions = ThisDrawing.ModelSpace.AddRegion(oRegObjects)

ReDim PlineArr(coll.Count - 1)
For i = 0 To coll.Count - 1
Set PlineArr(i) = coll(i + 1)
Next i

Else

MsgBox "You must select a Polyline", vbSystemModal

End If
0 Likes
Message 4 of 4

Anonymous
Not applicable
> I have tried almost everything but I still can't get it to work
all that in a few hours... It usually takes me a few days..:<)

see if this gives you some ideas. I've used a selection
set with a filter for closed plines. You will need some
error handling.

[code]
Option Explicit

Sub PlinesToRegion()

Dim SS As AcadSelectionSet
Dim filType(1) As Integer
Dim filData(1)
'filter data for closed lwpolys
filType(0) = 0
filData(0) = "LWPOLYLINE"
filType(1) = 70
filData(1) = 1

Set SS = SSAdd("test")
SS.SelectOnScreen filType, filData

Dim objectArray(0) As AcadEntity
Dim regionEnt

Dim i As Integer
For i = 0 To SS.Count - 1
Set objectArray(0) = SS(i)
regionEnt = ThisDrawing.ModelSpace.AddRegion _
(objectArray)
Next i

Call SSRemove("test")

End Sub

Function SSAdd(inName As String) As AcadSelectionSet
On Error Resume Next
With ThisDrawing
.SelectionSets(inName).Delete
Set SSAdd = .SelectionSets.Add(inName)
End With
End Function

Sub SSRemove(inName As String)
On Error Resume Next
ThisDrawing.SelectionSets(inName).Delete
End Sub
[/code]
0 Likes