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?
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.
--
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
>>
>>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
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.
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.
@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.
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,
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.