Jump to content

How to cause recorded macro code to be visible in the VBA editor.


TheNewGuy

Recommended Posts

I would like to know if there is a way to make the code from a user recorded macro to be visible when you go to the VBA editor screen.(like in excel) In excel I can use this to help teach myself the coding language, and I would like to try doing the same in autocad so I can start to write my own lisp programs. Thanks for any input and help!

Link to comment
Share on other sites

I would like to know if there is a way to make the code from a user recorded macro to be visible when you go to the VBA editor screen.(like in excel) In excel I can use this to help teach myself the coding language, and I would like to try doing the same in autocad so I can start to write my own lisp programs. Thanks for any input and help!

 

Bear in mind that VBA and LISP are two very different things. If you want to write LISP, you will need to write it from scratch, and won't be able to "record" anything that you do. I can't speak for VBA, as, honestly, I have never programmed with it - but I am sure others will have something to say :)

 

As for LISP, I use the Visual LISP Editor in ACAD (type VLIDE at command line, then File, New File).

 

There are dozens of tutorial sites out there for you to learn from, and, if you're still stuck, just post a thread on here, and we will help you all we can :)

 

Cheers

 

Lee

Link to comment
Share on other sites

VBA - I've not encountered a user recorded macro in older AutoCAD implementations. I cartainly can't see it on my 2008 version.

 

I am looking at a nice new 2010 box atm so once we get some time I will have a look at URMs but until then I can't help.

Link to comment
Share on other sites

You lucky lad :P
but by the time our parent company do all their "tests" on any piece of software and allow IT to (tell me to) install it, I will be looking at a nice new 2012 box. :x
Link to comment
Share on other sites

but by the time our parent company do all their "tests" on any piece of software and allow IT to (tell me to) install it, I will be looking at a nice new 2012 box. :x

 

Haha, I know what you mean :)

 

But I'd be happy with the wait - I'm still stuck with '04... (best release.. ever.)

Link to comment
Share on other sites

Sorry I needed to update my user CP because now I've got this fancy new 2009!!! I thought that the language used in VBA would be similar to what is used in a LISP. Is that not the case? And So I guess I would like to see if someone (Ideally NOT LEE MAC as he has done enough for me already) would mind writing a short lisp that I can use as a starting point to learn from.

lisp help.dwg

Link to comment
Share on other sites

Haha "NOT LEE MAC" ... you should be so lucky...

 

The methods used are similar, but the format and language is quite different.

 

As for a LISP to "learn from", your best bet would be to check out a tutorial site, like Jeffery Sanders, or AfraLISP - they will step you through it carefully, and use appropriate LISPs.

 

But, as you asked for it, below is one of my very first LISPs :P

 

(defun c:addone (/ ent count)
   (while  (setq ent (car (entsel "\nSelect Numerical Text: ")))
       (setq ent (entget ent))
       (setq count (atoi (cdr (assoc 1 ent))))
       (setq count (+ 1 count))
       (setq ent (subst (cons 1 (itoa count)) (assoc 1 ent) ent))
       (entmod ent)
   ) ; end while
   (princ)
)

Link to comment
Share on other sites

Your too much Lee Mac I think I'll be indebted to you for a long time at this rate! Thanks for your help. Again.....

Link to comment
Share on other sites

as I hinted above, I have yet to install our copy of 2009 or 2010 ut from what I saw the macro produced is in the form of a script file with place holders for variables. Script files have been covered extensively here (a lot of them by me) but are one of the best kept secrets in AutoCAD. So powerful but used by only a few. Have a search here then compare with your 2009 macro.

Link to comment
Share on other sites

Ok. Thank you for your help. So is there a way to make the code that is generated when I record a macro visible for analysis and editing. I have looked and can't find it.(in excel when I record a new macro the code is stored as a new module and is visible in the VBA editor.) I like this because it is helping me to learn how to write these codes for excel. I would like to do the same thing for autocad. thanks for your help.

Link to comment
Share on other sites

--EDIT--- I think I have answered this on my own. So this topic is closed. Thanks for your help.

 

What was the answer? Could you please post it so that others may benefit :)

Link to comment
Share on other sites

I am sure others have commented here but there is the action recorder available in 2009 + it allows you to record a macro similar to excell etc Not sure how much editing it allows you to do as I have not played with much it may be good for simple stuff offseting and changing layer properties as a macro. It mentions can put lisp & vba code into the macros.

 

Well just had a play very interesting you can ask for user input and I guess program it.

 

Can someone maybe put a couple of examples here done in action recorder.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...