Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP by Template

8 REPLIES 8
Reply
Message 1 of 9
cattjake
869 Views, 8 Replies

LISP by Template

Good afternoon,

 

I am very new to LISPs and just trying to create a few simple ones to help reoccuring issues.

The first one I would like to create I think would be something like

 

(alert "Please define a coordinate system for all new drawings.")
(command "editdrawingsettings")

 

I can add this LISP to the startup suite and it seems to function fine but it prompts every time a drawing opens. How do I make it execute for only NEW drawings started from specific templates?

8 REPLIES 8
Message 2 of 9
martti.halminen
in reply to: cattjake

You have two separate parts to work with:

- finding which template the drawing is based on

- finding if it is new

 

The first could work by adding something in your template that identifies it when inspecting the drawing database. I'd try first with Ldata, but there are also other possibilities.

 

The high-end way for catching new drawings would be with a reactor watching the creation commands etc., but that tends to be a little difficult for beginners.

The easier way might just be checking the size of the drawing: if it doesn't contain anything not coming from the template, it is new.

 

-- 

 

Message 3 of 9
Ajilal.Vijayan
in reply to: cattjake

Try by changing the code like this

 

(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)));get the active document
(if ( = :vlax-false (vla-get-saved adoc));if drawing not saved,then show the message
(progn
(alert "Please define a coordinate system for all new drawings.")
(command "editdrawingsettings")
(vlax-release-object adoc) );progn );if

 

Message 4 of 9
scot-65
in reply to: cattjake

>>

>>How do I make it execute for only NEW drawings started from specific templates?

>>

 

Does the drawing template(s) have the file name different to the (final) project's file name?

I.E.: Do you do a "SaveAs" shortly after opening up the templates?

 

Try:

(getvar "DWGTITLED")

(getvar "DWGPREFIX")

(getvar "DWGNAME")

 

 

DWGTITLED

(Read-only)
Type: Integer
Saved in: Not-saved
Initial value: 0

Indicates whether the current drawing has been named.

0

Drawing has not been named

1

Drawing has been named

 

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 5 of 9
paullimapa
in reply to: scot-65

Maybe the catch all may be to UNDEFINE the built-in NEW command and define using Lisp your own NEW command which would check the name of the drawing template selected to run those specific commands you want.

 

AOL @ Exchange App Store

DDSetup @ Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 9
cattjake
in reply to: scot-65


@scot-65 wrote:

>>Does the drawing template(s) have the file name different to the (final) project's file name?

>>I.E.: Do you do a "SaveAs" shortly after opening up the templates?

 

 

Yes, the drawing templates are .dwt files saved in a support folder. After a drawing is opened a Save As is executed off into the proper projects folder.

 

 

 

 

 


 

Message 7 of 9
cattjake
in reply to: Ajilal.Vijayan

Ajilal,

I am trying to learn, could you please explain your logic behind this?

Thank You!
Message 8 of 9
cattjake
in reply to: martti.halminen

Martti,

 

It would be very easy to add a marker to the templates to preform a check on. And I think you might be onto something, once the drawing has objects in it the file size will not equal the template.

 

Now to just figure out the best way to do this.

 

Thank You,

Message 9 of 9
Ajilal.Vijayan
in reply to: cattjake

Hi,

My logic is to simply test whether the drawing is saved or not.

If the drawing is not saved then display the message to set the coordinate system.

 

But this wont help you, if you just need to display the message for new drawings from specific templates.

One another thought is to create a text with this message, so that the user will see the text when they open a new drawing.

 

If you want to display the message for new drawings from specific templates, how about creating a pre defined template with coordinate system which already set.

So that when somebody use this template, can make sure that the coordinate system is already defined.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost