VBA uses?

VBA uses?

Anonymous
Not applicable
470 Views
5 Replies
Message 1 of 6

VBA uses?

Anonymous
Not applicable
I am curious to know what is the best use for VBA in autocad. I know some
lisp now I would like to know about VBA. VBA seems to be hard work when
something is required to be 'drawn' (ie lots of code). However I know VBA
has advantages over lisp such as dialog boxes and talking to other
applications, but what other times should I use VBA rather than lisp?
thanks Russ
0 Likes
471 Views
5 Replies
Replies (5)
Message 2 of 6

arcticad
Advisor
Advisor
I've written a lot of programs in VBA, Some of the ways I prefer using VBA is for reactors and interfacing with other applications; such as excel and access.

There are still some parts of autocad that must be done in lisp. Qleader was one recent example. VBA didn't have the proper options exposed. Also Mtext TextMask was a problem in vba.

Being able to easily create a user interface and being able to modify objects easily has it's advantages.

Once you start using VBA you really won't want to go back to Lisp unless you are forced to.

I wrote an entire database application in Lisp and then i rewrote it in VBA and it was a better product in VBA. Looked Better and had more functions and took less time to develop.

As for creating objects; It may look longer to you at first but you don't need to use dxf codes in vba for most objects. And this alone makes it worth it.

I've got lots of Lisp code that activates VBA to finish. For example I have reactors that always position text to be horizontal and forces company standards for layer control and font sizes.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi Russ,

If you mean this is lots of code, then so be it

Like lisp, you have to assign data to the Pt1 and Pt2 variables which can be
done by selection from the drawing or by computation and/or pure assignment.
Once you've done that you can create the line with:

Thisdrawing.ModelSpace.AddLine Pt1, Pt2

To do this the actual typing would be:
thisdrawing.maddli pt1, pt2

Note all the typing is in lower case. The program adjusts the case when you
get your typing right - so it is a form of error checking.

You can extend on this with if you don't wish to have the line use the
current settings:

Dim oLine as AcadLine
Set oLine = Thisdrawing.ModelSpace.AddLine (Pt1, Pt2)
With oLine
.Layer = "Fred'
.LineType = "Dashed"
.Color = 1
.Update
End With

Maybe layer "Fred" doesn't exist
you need:
Thisdrawing.Layers.Add "Fred"

Again the typing to create this is less than you see and each time you type
a . in the code above your will see a pull down list of your options.

There have been lots of quite spirited discussions on the subject of
recommended programming languages in this NG and you would be wise to spend
a little time reading them.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"Kiwi Russ" wrote in message
news:5225237@discussion.autodesk.com...
I am curious to know what is the best use for VBA in autocad. I know some
lisp now I would like to know about VBA. VBA seems to be hard work when
something is required to be 'drawn' (ie lots of code). However I know VBA
has advantages over lisp such as dialog boxes and talking to other
applications, but what other times should I use VBA rather than lisp?
thanks Russ
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi Russel
I glad again to meet you here
My opinion is the following: especially, if to consider that circumstance,
that I am the same beginner in VBA, as well as you,
each programming language good in the certain situations
in a concrete case can have the superiority any language,
here it will be more important a level of the programmer,
instead of a choice of the programming language
(This my personal opinion and is more than anything)
BTW you are good lisp programmer as far as know,
why you need VBA?

Fatty

~'J'~
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks for your interesting answers.
Yes Laurie I agree VBA "helps you along" as you write, but at the
moment it all looks very complicated. Still I want to preserve with
learning.....I would like to learn VBA (as you ask Fatty) because it is
used in other applications and there is the possiblity of linking.
many thanks
Russ
0 Likes
Message 6 of 6

Anonymous
Not applicable
I would suggest you get a book on VBA or Visual Basic 6 and get familiar with the language before trying to understand using it with AutoCAD. Once you are comfortable with the language the examples in the help files are quite good or you could also get a AutoCAD specific VBA book.

If you would like a bigger challenge you could learn a .NET language and use the .NET API.

Regards - Nathan
0 Likes