Skip to main content
daneJ
Inspiring
July 26, 2016
Answered

line of code gives me an array. But why?

  • July 26, 2016
  • 1 reply
  • 534 views

I am having some coding trouble. refArtboard.ArtboardRect is an array in illustrator that contains the 4 entries regard position.

When i run: refArtboardX = refArtboard.ArtboardRect(0) i get the first entry in the array as a double.

i have moved this part of the code into a subroutine. when i go in to the sub and reach this line: refArtboardX = refArtboard.ArtboardRect(0) then refArtboardX becomes an array containing all 4 refArtboard.ArtboardRect entries rather then a single value. I can not figure out what is going wrong here. i tried diming it as a double but just got an error. I can put any number at all at the end of refArtboard.ArtboardRect(0) but the result is alway the array(0 to 3). does anyone have any ideas what could be going wrong here. If anyone has some thought i  would be very interested to hear them.

i have pasted in more of the code below to give more context.

Set refArtboard = doc.Artboards.GetByName("L&A")

                    refArtboardName = refArtboard.Name

                    Set layerChoice = idoc.Layers(refArtboardName)

                    refArtboardX = refArtboard.ArtboardRect(0)

                    Set newSymbol = symbolMethod.Add(refSymbol("LL #15"))

                    Set bottomLftSymbolRef = newSymbol

                    newSymbol.Left = refArtboardX + marginRef

                    newSymbol.Top = refArtboard.ArtboardRect(3) + newSymbol.Height + marginRef

                    lastSymbolLeft = newSymbol.Left

                    lastSymbolTop = newSymbol.Top

                    newSymbol.Move layerChoice, aiPlaceAtBeginning

                    Set newSymbol = symbolMethod.Add(refSymbol("LL #14,15OR"))

                    newSymbol.Left = lastSymbolLeft + newSymbol.Width + 14

                    newSymbol.Top = lastSymbolTop

                    newSymbol.Move layerChoice, aiPlaceAtBeginning

Thanks alot.

Dane

This topic has been closed for replies.
Correct answer daneJ

Hello CarlosCanto

Thank you for replying. Next itme i will be sure to add a complete code. The main reason i didnt is because the code is approx. 40 pages long.

I actually just figured out what the problem was about 3 minutes ago. I had not declared refArtboard as an artboard inside the subroutine. This is my first time using a subroutine so I am not at all familiar with it. appearently variable declarations do not pass into subroutines.

Best regards,

Dane

1 reply

daneJ
daneJAuthor
Inspiring
July 26, 2016

I forgot to mention that I am using VB.

CarlosCanto
Community Expert
Community Expert
July 26, 2016

please post your sub the way you have it and it'll be nice if you post a full working (or not working) sample so we can copy, past it and run it right away without adding additional code to to make it work...as it is, it all seems to be ok.

daneJ
daneJAuthorCorrect answer
Inspiring
July 26, 2016

Hello CarlosCanto

Thank you for replying. Next itme i will be sure to add a complete code. The main reason i didnt is because the code is approx. 40 pages long.

I actually just figured out what the problem was about 3 minutes ago. I had not declared refArtboard as an artboard inside the subroutine. This is my first time using a subroutine so I am not at all familiar with it. appearently variable declarations do not pass into subroutines.

Best regards,

Dane