Changes in VBA for 7.1 - Document Collections and Colors

#1
I am starting to work through updating my VBA code to ver 7.1, and have a few questions:

1) Am I correct in thinking that most (all?) of the document collections are now 0 based rather than 1 based. That is:

ver 6.6: IntelliCAD.ActiveDocument.Layers.Item(1) for layer "0"

ver 7.1: IntelliCAD.ActiveDocument.Layers.Item(0) for layer "0"


2) It looks like setting a line color is different with the new object model. Using

lineObj.color = vicRed

does not appear to work in 7.1. I am having a hard time figuring out what the new code should be. Is there an example in the help that I missed? If not, can someone post a short code segment?

Otherwise, that-you for adding VBA back in. It looks like 7.1 in general is a very nice upgrade from 6.6.

Thanks,
Erik

#2
I am also having the same problem with ver 7.1

The example listed above seems to result in a type mismatch for me.

I've tried this method:

anObj.color.ColorIndex = 2

which appears to eliminate the type mismatch, but all of the layers that are created in my program are just white. If I output the colorindex in a message box during the program, it displays a colorindex of 7 (white).

#3
Hi,

Yes, all collections are now zero based.
The color setting issue will be analyzed. A workaround to this would be setting it through LISP.

Regards,
JCAMPOS

RESOLUTION

#4
I am happy to report that I have made a breakthrough with this issue. Below you will see code that successfully changes the BYLAYER color of a layer. As you can see, a pointer is necessary instead of directly accessing the color properties. There is preceeding code that allows the user to select which layer to make active from a combobox. I don't believe the regen is necessary, however I need to hover the mouse over the layer dropdown box in Intellicad before I see the new color. I don't think a regen accomplishes that...it could just be my video card (or lack thereof).

Code: Select all

    Dim thiscolor As IntelliCAD.color
    
    Set thiscolor = ThisWorkspace.ActiveDocument.ActiveLayer.color
    thiscolor.ColorIndex = vicBlue
    ThisWorkspace.ActiveDocument.ActiveLayer.color = thiscolor
    ThisWorkspace.ActiveDocument.Regen
So far it seems that Intellicad is much happier using what I consider a more old school method of assigning a pointer to what you want to work with, modifying that pointer, and then reassigning the pointer back to the system variable. The VBA for autoCAD that I've been converting works directly with the .color property.
cron