Jump to content

Need quick help adding variable to script startup! THX


tmelancon

Recommended Posts

I have written in my custom lisp routine to run at startup...

 

(defun S::STARTUP()
(setvar "CMDECHO" 0)
(command "SCRIPT" "update")

We use .DAT files when we open drawings through our interface and I have this script-update running automatically when opening our drawings.

 

What I am looking for is just a simple IF variable so when we are NOT opening a drawing through interface (just a blank drawing like acad.dwt) it overlooks running this script file. If anyone has anything real basic I would greatly appreciate it. God bless

Link to comment
Share on other sites

What is your test going to be?

When should it not run the script?

I don't know what "NOT opening a drawing through interface " means. Sorry.

 

(if something  [color=blue][i];;or (if (not something)[/i][/color]
 (command "._Script" "update")
)

Link to comment
Share on other sites

Again, like I said in the original post. We still want the script to load but we are looking to ignore loading the script when a blank autocad drawing is opened. Hence why I put the the "just opening a acad.dwt" (which is the template that opens when you click the 'new drawing' button. Furthermore, the "NOT opening through interface" reiterates that I want the script to be ignored while opening new from scratch and not new through our interface.

 

Now that I clarified for you, to answer your questions. We are not testing anything. I just simply want to ignore the script when I open just a blank template to mess around with. We do not want the script to run when opening a blank template (the acad.dwt template, by clicking file then new drawing or by clicking new drawing toolbar button)...

 

So to break it down I would want the code that I wrote to run EVERYTIME I open (just like its doing now with no problems) and then a piece of code to ignore the piece of code that loads the script when I open a blank drawing.

 

Thanks I hope this helps

Link to comment
Share on other sites

Again, like I said in the original post. We still want the script to load but we are looking to ignore loading the script when a blank autocad drawing is opened. Hence why I put the the "just opening a acad.dwt" (which is the template that opens when you click the 'new drawing' button. Furthermore, the "NOT opening through interface" reiterates that I want the script to be ignored while opening new from scratch and not new through our interface.

 

Now that I clarified for you, to answer your questions. We are not testing anything. I just simply want to ignore the script when I open just a blank template to mess around with. We do not want the script to run when opening a blank template (the acad.dwt template, by clicking file then new drawing or by clicking new drawing toolbar button)...

 

So to break it down I would want the code that I wrote to run EVERYTIME I open (just like its doing now with no problems) and then a piece of code to ignore the piece of code that loads the script when I open a blank drawing.

 

Thanks I hope this helps

 

I understood that you want to ignore the script under certain circumstances, but under *what* circumstances is the part that was lacking from your original post. "NOT opening a drawing through interface" does not make sense. What 'interface'?

 

What I understand now, from your second post is that if you are "starting a new drawing" you don't want the script to run. Is that correct? (When I said "What is your test" -- I meant what are you going to look at, or what are you evaluating, to make the decision whether or not to run the script.)

 

So the answer to your question is you need to test for whether the drawing is NAMED or not. A new drawing will not be named.

 

(if (eq 1 (getvar "dwgtitled"))
  (command "._Script" "update")
)

Link to comment
Share on other sites

Use getvar dwgname in a lisp and if not template then run script

 

(if (= (getvar "dwgname") "mytemplate name")
(princ)
(command "script" "update")
)

 

 

The test in that IF statement will never be true, and the script will always run.

Link to comment
Share on other sites

rkmcswain your code worked flawlessly. Sorry for the confusion in the beginning, I was at the office and just wanted to try and make it quick. My second post I was at the house. Blessings to all who chimed in YOU ARE BEAAASTTSSSS!! :notworthy::notworthy:

Link to comment
Share on other sites

rkmcswain your code worked flawlessly. Sorry for the confusion in the beginning, I was at the office and just wanted to try and make it quick. My second post I was at the house. Blessings to all who chimed in YOU ARE BEAAASTTSSSS!! :notworthy::notworthy:

 

No problem. Glad it worked for you. :beer:

Link to comment
Share on other sites

rkmcswain start Autocad dwgname is "drawing1"

 

Close, new, dwgname is drawing2 and so on, could check for drawingX as a name.

 

Your test is simpler though 1 line usual thing so many hidden little variables that you can use.

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