View Full Version : New to VBA and or LISP
CADtech
19-11-2004, 06:03 PM
Hey everyone, as i said in the subject i am completely new to all this scripting or programing. In fact just a few hours ago i decided to start learning, problem is im not catching on so fast and id like to A: figure out if i can even do what i want and B: how to actually do it. Well ill start with my problem.. at the end of our drawings i need to purge and audit them.. while this is very simple it takes longer then it really has to, especially after reading something that are being done using LISPs and VBA macros.
Currently i have to type in purge, then his A 3x so all contnents are purged then hit ESC to exit it type in audit the type in y to agree to fix errors automatically. Now my goal is to simply press SHIFT-Z and have all that automatically happen.. now my question... is this doable, and if so what is better for the job VBA or LISP?
Another question i had on the back burner that may or may not relate to VBA or LISPs is.. Say i have edited my right click menu to include the dimension command, and when i use that command i want the dimensions that are created from it to automatically goto the DIM layer, a layer that is always present in our standards... is this doable?
thanks for any support and help provided, i hope to learn a lot from you guys in the near future.
hendie
19-11-2004, 06:37 PM
welcome to the programming world !
both of the topics you mentioned are do-able but to be honest, they are really more in the realms of scripting than "true" programming ~ but that aside, we've all go to start somewhere.
so, as a starting point. Lets take the Purge routine.
you don't mention which version of Acad you're using so you'd better know that this only applies to 2000i and above
take a look at what you have to do to complete your purge sequence ~i.e. write down the command and your responses to all the prompts.
it should be something like
Purge
All
*
N
the easiest thing to do here is to put this into a button macro.
so your Command would be Purge <enter> All <enter> <enter> No <enter>
here's a clue ~ using a semi colon ( ; ) in a button macro is the same as hitting the <enter> key, and if you precede a command name with a hyphen ( - ) it disables any dialogue and takes you to the command line version. So, your task is: to come back with the correct button macro for purging
any questions ~ just ask !
CADtech
19-11-2004, 06:44 PM
cool.. yea sorry about that im using Acad 2005. I'll be able to work on it when i get home.. lunch is over ;) thanks for the help
i do this in autocads VB editor? VBARUN? create...
or whats the button macro... when you goto make a new botton and you type in ^C^LINE for the command?
well this what i have to type PURGE<ENTER>.. A..A..A..ESC.
hendie
19-11-2004, 07:09 PM
No, not VBA or Lisp, just a button macro ~ right-click on the toolbar, select "customise" etc
well this what i have to type PURGE<ENTER>.. A..A..A..ESC.
that is what you have to type, but what would you enter for that sequence in a button macro ? I'll give you a start
^C^C_-purge;a;
now you finish the rest
CADtech
19-11-2004, 07:10 PM
ok i made a button then in the box typed -purge;all
and it goes intot he purge command in the command prompt and it asks me to verify names of things i want to purge then it says all is not a name then it returns to the normal command prompt..
CADtech
19-11-2004, 07:15 PM
alright got it... ^C^C_-PURGE;A;N;
ok hopefully i wont be so simple minded for the rest of this...
CADtech
19-11-2004, 07:20 PM
Sweet, got it to purge audit and save.... now im getting a little more exciting... how about setting it as a hotkey SHIFT-Z... what file would i have to edit.. oh as it stands my button macro looks like this
^C^C_-PURGE;A; N;^C^C_AUDIT;Y;^C^C_QSAVE
hendie
19-11-2004, 07:30 PM
you might want to consider repeating the purge sequence a couple of times, since it usually takes 2 or 3 purges to clear everything
I have my button set up like that and I just hit it a couple of times before I exit a drawing
I see you've used a space after the A in your purge part. ~ in button macros, a space is the same as a semi colon.
oh, btw, ... well done !
VERYCIVILDRAFTER
19-11-2004, 07:38 PM
You don't really need all that syntax in a tool bar for 2005. You can write it just like you'd type it at the command line prompt.
My custom purge tool bar button only has this in it:
-purge all n -purge all n -purge all n
I also have another "drawing cleaner" button that looks like this:
ti 1 -xref d * ucs plan -purge all n -purge all n -purge all n
However, you should propbably go ahead and keep the cancel command (^C^C)
hendie
19-11-2004, 07:48 PM
each to their own.
I find that using a semi colon is easier to read, and if you have two spaces instead of one, it can be hard to spot ~ a semi colon is much easier to see
CADtech
19-11-2004, 07:48 PM
HaHa nice avatar.. when the monkey found his wife in bed with another monkey family guy is the best...yea at first ididnt have the CC and it worked but i decided just to go ahead and throw them in there
CADtech
19-11-2004, 08:25 PM
^C^C_PURGE;A;;N;^C^C_PURGE;A;;N;^C^C_PURGE;A;;N;^C ^C_AUDIT;Y;^C^C_ZOOM;E;^C^C_-XREF;D;PS;^C^C_QSAVE
well theres my final button thanks it makes my simple task even simpler.
now how do i go about the dimensioning thing, where i want to dimension but have it automatically goto the DIM layer.. is this also a simple scripting function...
ok heres one that should have to deal with programing... can i create a macro that will search for a cloud revision or a block in a drawing and deleted it?
thanks for all your help.. this is actually fun...
hendie
19-11-2004, 08:47 PM
there is a sort of way to set the dimensions to go to the dim layer but if you want it completely automatic, then you're getting into the realms of reactors.
te cheat way is to use button macros again, just set the layer to dim or whatever in the dimension button before it calls the dim command
of course, that doesn't set your layer back once you've finished.
you could always create a lisp that would filter all dimensions and set them to the correct layer and assign that to a button.
have you ever used Lisp or the Vlide before ?
CADtech
19-11-2004, 09:27 PM
no i havnt, i read a little about autolisp and visual lisp...
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.