Checking my understanding of VBA
I just wanted to make sure my understanding of how VBA is organized is correct.From what I've read from VBA tutorials written for other applications (like Word), the VBA program itself is contained within the DWG file (or the Microsoft Word .doc file). And while you can export or import VBA programs, the program itself must always be contained within the main application's documet.On the VBA for Word tutorial I came across, it said there was a "normal" and "projects" heading in the Project Explorer. However, I can't see that on my VBA screen. Instead it has "Common Projects" and "Document1". I have no idea why this is different.Joe Dunfee
Comments
-
The vba code which you write under "Common Projects" will be available to all your drawings. On the other hand each drawing (=each document) can have it's own specific vba space. It is specific in that it is only available to that drawing (so it is NOT common and NOT shared with other drawings...) To see what happens open 2 or more drawings with BricsCad then launch the VBA editor (Tools>Visual Basic>Visual Basic Editor). In the left pane (Project tree) you should see the as many spaces as you have open drawings plus a "Common Projects" space. Expand each of the projects and you will notice that they all contain 'BrisCad Objects'. These in term all contain a 'ThisDrawing' object while the 'Common Projects' project contains a 'ThisWorkSpace' object.Finally it is not so that the actual vba code is stored within the dwg. In the case of BricsCad it gets stored in a .vbi file that resides alongside the . dwg of the same name ( eg myNewDrawing.dwg and myNewDrawing.vbi) (the CommonProjects.vbi lives in the BricsCad root)I hope this clarifies matters...
0 -
Thank you very much. It is difficult to make progress when I am not understanding even basic facts.I am also trying to form a set of rules in my head about how to translate books written for AutoCAD VBA into IntelliCad's version. I've read about, and think I understand the major fact about points being stored differently.Can you tell me if it is appropriate to just substitute "icad" wherever "acad" is used in a command?Joe Dunfee
0 -
Translating acad to icad will get you somewhere... and simply rely on the VBA editor to complain about methods or properties it doesn't recognize...More seriously a good starting point is the IntelliCAD Object browser in the VBA editor. You will see that a lot of the properties and methods which exist in the AutoCADCOM model have their exact counterpart in the IntelliCAD COM model.Another starting point is the on-line documentation (Developper's reference>COM>User Guide) which includes code examples. Alternatively you can search the on-line help on the 'Examples' key-word. This should lead you to the code examples contained in the on- line help. You can easily cut and paste these examples into your the VBA editor and start hacking...Start writing small routines that perform very basic tasks.Success...
0 -
Thank you for the reply.I've browsed over the "com" section of the developer's guide in the past. I noticed some examples that looked like Visual Basic, but wasn't sure.Actually, it is not necessarily the methods that puzzle me, but rather the setting up of the program to communicate with IntelliCAD. There seem to be some tricks to this which are not really spelled out in the on-line help.How is COM related to VBA?Joe Dunfee
0 -
In the above message, I am not sure I am asking my question very well. In VBA, you refer to objects in the drawing, and use "methods" using a series of words separated by dots. However, sometimes I am confused about this.I think of them as a heirarchy of terms, e.g. To refer to the layer of a line, you use the currently open document "dot" line "dot" layer. (not the exact terms, but the same concepts)
0