Page 1 of 1

Changes in VBA for 7.1 - Document Collections and Colors

Posted: Wed Jun 13, 2012 6:12 am
by ErikXdot
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

Posted: Tue Jul 31, 2012 11:59 am
by Accuright
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).

Posted: Tue Aug 07, 2012 2:54 am
by JCAMPOS
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

Posted: Tue Oct 30, 2012 9:34 am
by Accuright
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.

Posted: Tue Oct 30, 2012 10:00 am
by Accuright
I also just tested this method changing color with SetRGB

Code: Select all

 thiscolor.setRGB 255, 255, 255
and this also works correctly!