Jump to content

A couple questions for the CAD Tutors...


AceRiddler

Recommended Posts

Hi there,

Still trying to learn,

 

here are 3 questions that if answered will help me understand deeper what we really can do with the famous LISP.

 

1. is the (Open (filename)) command used only to open LISP files or you can use it to open .dwg , .doc , etc. ? What would a good code look like?

 

2. Is it possible to create a LISP that initiates itself when you open a drawing and shows an alert when you close it?

 

3. Can you put in there a lisp that recognise the notion of time (exemple : counting the time elapsed since the dwg was opened, or doing something every 5 minutes).

 

I will have other questions soon, i will keep replying in this thread instead of creating different threads each time if you guys don't mind.

 

Thank you all in advance.

Ace.

Link to comment
Share on other sites

1. is the (Open (filename)) command used only to open LISP files or you can use it to open .dwg , .doc , etc. ? What would a good code look like?

 

Auto LISP is a drawing level language that can only function within the current (Active) drawing.

 

Visual LISP can access both Auto LISP API and the ActiveX COM API which is an application level language, and can interact with the Documents Collection Object in order to 'open' (read *Add) a new Document Object to the Documents Collection. Then the newly 'opened' (read Added) Document can be Activated.

 

* SDI = 0 required.

 

2. Is it possible to create a LISP that initiates itself when you open a drawing and shows an alert when you close it?

 

This functionality already exists in the form of two user created files:

 

ACAD.lsp - Which is (by Default) loaded once per session.

ACADDOC.lsp - Which is loaded each time a drawing is opened.

 

3. Can you put in there a lisp that recognise the notion of time (exemple : counting the time elapsed since the dwg was opened, or doing something every 5 minutes).

 

Yes.

 

I will have other questions soon, i will keep replying in this thread instead of creating different threads each time if you guys don't mind.

 

No, please do not. This thread should not be your personal 'blog' of unrelated questions.

 

Instead, please post a new thread for each request. Not every question has to be in its own thread, of course. Use common sense to group your questions as you feel appropriate, and in the future, please use a clear thread title. Often times if your thread title is unclear, members may ignore.

 

As you're interested in LISP development, I'd also recommend that you learn to use

 when posting code.

 

Hope this helps!

Link to comment
Share on other sites

1. is the (Open (filename)) command used only to open LISP files or you can use it to open .dwg , .doc , etc. ? What would a good code look like?

 

The open command can open any file format, but will open the file to be read as a text file. To interface with a .dwg, or .doc you would use ObjectDBX and an instance of the MSWord Application Object respectively - but this is far beyond the level for a beginner.

 

2. Is it possible to create a LISP that initiates itself when you open a drawing and shows an alert when you close it?

 

The ACADDOC.lsp, if found, is loaded upon opening a drawing in AutoCAD, hence any LISP expressions contained therein will be evaluated.

 

As for a LISP evaluating when closing a drawing, this would require a reactor.

 

3. Can you put in there a lisp that recognise the notion of time (exemple : counting the time elapsed since the dwg was opened, or doing something every 5 minutes).

 

The LISP would not be able to constantly monitor the time without taking full control - you can't have multiple threads in LISP. However, a command reactor could be used to check the time every time a command is issued and evaluate LISP expressions when the time reaches specific intervals.

Link to comment
Share on other sites

and in the future, please use a clear thread title. Often times if your thread title is unclear, members may ignore

 

1+

 

Also, without a relevant title, the 'Similar threads' functionality at the bottom of the page is rendered useless, as is the forum search utility.

Link to comment
Share on other sites

@ Lee - Thanks for following up, you added some good information that I neglected in my initial (rushed) response.

 

Cheers! :beer:

Link to comment
Share on other sites

@ Lee - Thanks for following up, you added some good information that I neglected in my initial (rushed) response.

 

I think between us we covered most of it :thumbsup:

Link to comment
Share on other sites

Thank you guys,

 

Also, without a relevant title, the 'Similar threads' functionality at the bottom of the page is rendered useless, as is the forum search utility.

 

perhaps we can ask a mod to change the title if you guys think that theses questions answered may help other people.

 

Lee,

The open command can open any file format, but will open the file to be read as a text file. To interface with a .dwg, or .doc you would use ObjectDBX and an instance of the MSWord Application Object respectively - but this is far beyond the level for a beginner.

 

great, so we would be able to store information (gathered in the drawing youre using the lisp in) in a text file.

 

However, a command reactor could be used to check the time every time a command is issued and evaluate LISP expressions when the time reaches specific intervals.

 

Thats some great news, i need to learn more about that "reactor" !

 

Renderman,

This functionality already exists in the form of two user created files:

 

ACAD.lsp - Which is (by Default) loaded once per session.

ACADDOC.lsp - Which is loaded each time a drawing is opened.

 

hmmm indeed eh, i did not really think before asking this question, it still refreshed my mind :P

 

Thanks again,

both of you,

 

Im buying your beers

Link to comment
Share on other sites

Renderman,

 

hmmm indeed eh, i did not really think before asking this question, it still refreshed my mind :P

 

You have no idea how often I suffer this very same affliction. :P LoL

 

Thanks again,

both of you,

 

Im buying your beers

 

WooHoo - Free beer! :D

 

P.S. - I told Lee the same thing when he first started helping me, and I've never lived up to it... Shhhhhh. Admittedly, I added the caveat that I'd only buy him one when I 'cross the pond' (read fly to UK), but still. LoL

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...