Sending regions to another array

Sending regions to another array

Anonymous
Not applicable
421 Views
7 Replies
Message 1 of 8

Sending regions to another array

Anonymous
Not applicable
I have an array of regions declaired as
regionObj as variant

Now there are 20 regions in there. I would like to send even items (i.e. 2,4,6,...20) to another 2 dimentional array.
arrayList (1 to 10, 1 to 3) as variant

but it gives me type mismatch error.
I have also tried to claim it as acadRegion, but it didn't work either. Does anyone know what is the problem?
0 Likes
422 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
it doesn't give an error at my computer, can you show a little bit more from
your code?

- alfred -

In article , farnaz74@hotmail.com says...
> arrayList (1 to 10, 1 to 3) as variant
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Humm, it doesn't?
Well, here is what I tried. U need to make an array of circles called curves here....


'make regions out of circles in curves
Dim regionObj As Variant
regionObj = ThisDrawing.ModelSpace.AddRegion(curves)


'make rings out of regions- subtracting them 2 by 2
For n = 2 To 20 Step 2

'subtraction
regionObj(n).Boolean acSubtraction, regionObj(n + 1)

Next n

'here I want to send them to another array, cuz I need to
'fill the other columns with other information about
'the rings

Dim arrayObj(1 To 2, 1 To 10) As Variant
arrayObj(1,1) = regionObj(2)

'but it gives error!
'"object doesn't support this property or method"
0 Likes
Message 4 of 8

Anonymous
Not applicable
you missed "SET" to store a reference to an object:

set arrayObj(1,1) = regionObj(2)

- alfred -

In article , farnaz74@hotmail.com says...
> Humm, it doesn't?

> Well, here is what I tried. U need to make an array of circles called curves here....

'make regions out of circles in curves

> Dim regionObj As Variant

>     regionObj = ThisDrawing.ModelSpace.AddRegion(curves)

'make rings out of regions- subtracting them 2 by 2

> For n = 2 To 20 Step 2

'subtraction

>     regionObj(n).Boolean acSubtraction, regionObj(n + 1)

Next n

'here I want to send them to another array, cuz I need to

> 'fill the other columns with other information about

> 'the rings

Dim arrayObj(1 To 2, 1 To 10) As Variant

> arrayObj(1,1) = regionObj(2)

'but it gives error!

> '"object doesn't support this property or method"
>

0 Likes
Message 5 of 8

Anonymous
Not applicable
Oh Thanx! Well, I am not really a programmer, so.... 🙂

Hey, can I ask you something else?
What I actually wanted to do is to get 10 items (circle regions) out of an array of 20, and make 10 copies of them. So that at the end I would have 100.
I guess the idea of assigning those 10 to another array and copying the array was wrong. Cuz by copying an array I am not actually COPYing geometric entities, I just assign them to another array.
So the other thing I thought of was to make a selection set and sent those 10 there, then I make 10 copies of it. Is this the way to do it?
Also if that is the way, would the Xdata be copied along with the objects?
0 Likes
Message 6 of 8

Anonymous
Not applicable
if i understand your question correct, then you have to copy the geometry and
get the copy back to your memory-array, if so you can create your copy with the
copy-method:

dim tNewEnt as acadentity
set tNewEnt = tBaseEnt.Copy() 'where tBaseEnt is one of your existing entities


is that what you missed? - alfred -

In article , farnaz74@hotmail.com says...
> Oh Thanx! Well, I am not really a programmer, so.... 🙂

Hey, can I ask you something else?

> What I actually wanted to do is to get 10 items (circle regions) out of an array of 20, and make 10 copies of them. So that at the end I would have 100.

> I guess the idea of assigning those 10 to another array and copying the array was wrong. Cuz by copying an array I am not actually COPYing geometric entities, I just assign them to another array.

> So the other thing I thought of was to make a selection set and sent those 10 there, then I make 10 copies of it. Is this the way to do it?

> Also if that is the way, would the Xdata be copied along with the objects?
>

0 Likes
Message 7 of 8

Anonymous
Not applicable
Well, my question was more of how I can copy all the objects in the array at once.
I know that I can do that with "CopyObjects" which takes arrayas as argument:

copyArray = ThisDrawing.CopyObjects(oldArray)

But it gives me an error in the following senario....
I have an array of 20 circles in "oldArray"
I copy the ones with odd index (1,3,5,...19) to another array of 10 circles (newArray).

for n=1 to 19 step 2
set newArray((n+1)/2)=oldArray(n)
nextn

Then I try to copy the "newArray" with the same command (copyObjects)but it gives me an arror ("Array is not valid")

Funny thing is that it doesn't give me any error if I try to copy the "oldArray". It's just with the "newArray" that I have problem.
U know why this happens?
0 Likes
Message 8 of 8

Anonymous
Not applicable
i havn't tried it, but could it be that your array has an empty element
newArray(0)? is your option base set to 0 or to 1?

- alfred -

In article , farnaz74@hotmail.com says...
> Well, my question was more of how I can copy all the objects in the array at once.

> I know that I can do that with "CopyObjects" which takes arrayas as argument:

copyArray = ThisDrawing.CopyObjects(oldArray)

But it gives me an error in the following senario....

> I have an array of 20 circles in "oldArray"

> I copy the ones with odd index (1,3,5,...19) to another array of 10 circles (newArray).

for n=1 to 19 step 2

> set newArray((n+1)/2)=oldArray(n)

> nextn

Then I try to copy the "newArray" with the same command (copyObjects)but it gives me an arror ("Array is not valid")

Funny thing is that it doesn't give me any error if I try to copy the "oldArray". It's just with the "newArray" that I have problem.

> U know why this happens?
>

0 Likes