Author Topic: Filling an ACAD object array... what am I doing wrong?  (Read 1899 times)

0 Members and 1 Guest are viewing this topic.

gmyroup

  • Guest
Filling an ACAD object array... what am I doing wrong?
« on: September 26, 2007, 05:47:08 PM »
I am trying to extract the entities that make up the outer boundary of an ACAD hatch object using the following code:

Dim acadents(1000) As AcadEntity
For tl = 0 To acHatch.NumberOfLoops - 1
     acHatch.GetLoopAt tl, acadents

Next

When i run the code and look at the entites that should be in the ACADEnts array... there are none.

What am I doing wrong?

Jerry

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Filling an ACAD object array... what am I doing wrong?
« Reply #1 on: September 26, 2007, 06:23:03 PM »
First of all, it looks like you could assign the whole array multiple times (tl).

I would look into using getloop with a temporary array, then stepping through the temp array to assign acadents one at a time. That way you can append the next temparray (tl+1) to the end of the data you just put into acadents.

Does that make sense?

gmyroup

  • Guest
Re: Filling an ACAD object array... what am I doing wrong?
« Reply #2 on: September 26, 2007, 06:57:22 PM »
Hello

Thanks for getting back to me.  Theoretically I need to fill the array with entities for each loop in the hatch boundary and thus the tl = 0 to numberofloops - 1.  It would be nice if I could redim the array but unfortunately I have no way of knowing how many entities are in each loop.

I'm not sure what ACAD is looking for when the method ask for the loop number (that I do know) and the object array... which is the vehicle to return the entities in the loop... and thus the ACADEnts array.

It shouldn't be this hard and yet... I appear to be missing something.

Jerry


Bryco

  • Water Moccasin
  • Posts: 1883
Re: Filling an ACAD object array... what am I doing wrong?
« Reply #3 on: September 29, 2007, 10:46:02 AM »
The loop number gives access to a variant of entities,
for example a circle as a single entity or 4 lines making a rectangle, the latter is the reason why you need a variant for each loop.

Code: [Select]
Sub Hatch()

    Dim h As AcadHatch
    Dim i As Integer, Cnt As Integer
    Dim j As Integer, Clr As Integer
    Dim Ents(), oLoops
    Set h = EntSel
    Cnt = h.numberOfLoops
    ReDim Ents(Cnt)
    For i = 0 To Cnt - 1
        h.GetLoopAt i, oLoops
        Ents(i) = oLoops
    Next i
   
    For i = 0 To Cnt - 1
        oLoops = Ents(i)
        For j = 0 To UBound(oLoops)
            oLoops(j).Color = Clr
            Clr = Clr + 1
        Next j
    Next i
End Sub

gmyroup

  • Guest
Re: Filling an ACAD object array... what am I doing wrong?
« Reply #4 on: September 30, 2007, 05:50:59 PM »
Thanks so very nuch... I'll give it a try and get back to you if needed.