PDA

View Full Version : Redefining a Command using VBA



relysoft
2005-02-10, 03:23 PM
I'm a novice in VBA, but have been able to do a few useful things thus far.

I would like to be able to use a VBA function to replace an existing ACAD command. In LISP I would "undefine" the standard command, then use the "defun C:" feature to redefine the command to use my own LISP function instead of the native ACAD command code.

Is there a similar method for substituting VBA code in place of the native ACAD command? I have figured out that I could use the LISP technique to call my VBA code using the vl-vbarun function, but that seems like a really clumsy way to get to my VBA function. It is probably really simple, but I haven't yet found the key to this.

Thanks,
Bob

Ed Jobe
2005-02-10, 04:11 PM
As it stands now, vba doesn't have access to the command stack. As you have found, you will have to create a lisp wrapper for your vba. Use undefine/redefine in lisp.

relysoft
2005-02-10, 04:49 PM
Thanks for saving me a lot of time looking for a solution that does not exist.

Can anyone recommend a good book on ACAD VBA? I have been using the web and the ADESK documents to self-teach. I guess I will eventually figure it out, but it would be good to have something to help jump-start me.

Thanks,
Bob

Ed Jobe
2005-02-10, 04:54 PM
Have you tried ATP? I just finished a beginning class in Jan. You can download it from the archived classes (http://www.augi.com/education/archive.asp?page=293) link. Lesson 2 will be in March.

Mike.Perry
2005-02-10, 05:00 PM
Hi

Plus check out the following thread -

Running a routine in everyh open drawing. (http://forums.augi.com/showthread.php?t=5010)

Have a good one, Mike

relysoft
2005-02-10, 06:50 PM
Thanks a bunch, guys.

I am an experieced (35 years) engineering and engineering graphics software developer, but have not delved into the world of ACAD customization until the last couple of years on an as required basis. I'm not a LISP wizard, but have written several thousands of lines of code that are used by my customers' drafting departments daily. Now I find that I need to stretch beyond the boundaries of a single drawing. I figured out I could do this with VBA. My interest level and scope has increased with this experience.

Thanks again.

Bob

wpeacock
2005-02-11, 12:06 AM
Hi Bob

I've been using a sybex book called "Mastering AutoCAD VBA" by Marion Cottingham which I've found quite helpful.

Using this book along with the help menu in the VBA editor you can quickly learn some basics and fall into some trouble to!
(Refer to some of my idiot questions in this forum)

Hope this helps

Wayne