Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
Posts: 42
Registered: ‎12-03-2003
Message 1 of 6 (176 Views)

Re-set variables with SCRIPT on opening exisitng files.

176 Views, 5 Replies
05-09-2005 02:25 AM
I am very new to script writing, and have looked through these discussion groups to try and create a script to re-set certain variables on Start-up as well as opening existing files once CAD is running. I have managed to create the switch, see below and the script, see below, which works great when you start CAD, but I don't know how to make this work for existing files. All of the variables are correct when opening up the template file, so this is not very affective, what I do want is stop people continuing to draw with incorrect settings, half of them don't even realise that they are incorrect ? there are only so many times you can say ?please follow company procedure? ? to 80 users!!

"C:\Program Files\AutoCAD LT 2004\aclt.exe" /t "L:\cad\templates\new\pte template-2.dwt" /b "PTE-StartUp"

PSLTSCALE 0
MEASUREMENT 1
SORTENTS 0
CECOLOR BYLAYER
CELTSCALE 1
CELTYPE BYLAYER
CELWEIGHT -1
THICKNESS 0

Any help in this would be very much appreciated.

Catherine
Distinguished Contributor
Posts: 690
Registered: ‎06-21-2004
Message 2 of 6 (176 Views)

Re: Re-set variables with SCRIPT on opening exisitng files.

05-09-2005 05:36 AM in reply to: Caff
Maybe if one of them were let go..The others might start to listen.
Sometimes things need to be taken to extemes for people to sit up and notice.
Active Contributor
Posts: 35
Registered: ‎10-21-2008
Message 3 of 6 (139 Views)

Re: Re-set variables with SCRIPT on opening exisitng files.

03-30-2011 01:36 PM in reply to: Caff

Use a lisp file and run it every time a drawing is opened....i.e.

 

(defun c:svars (/)
(command "setvar" "imageframe" "2")
(command "setvar" "taskbar" "1")
(command "setvar" "previeweffect" "0")
(command "setvar" "gripobjlimit" "10000")
(command "setvar" "vtenable" "0")
(command "setvar" "menubar" "1")
(command "setvar" "savetime" "12")
(command "setvar" "recoverymode" "2")
(command "setvar" "xloadctl" "0")
(command "setvar" "isavepercent" "0")
(command "setvar" "ribbonbgload" "0")
(command "setvar" "gripcontour" "7")
(command "setvar" "layerdlgmode" "0")
(command "setvar" "layerevalctl" "0")
(setenv "ShowTabs" "1")
(princ)
)

*Expert Elite*
Kent1Cooper
Posts: 4,962
Registered: ‎09-13-2004
Message 4 of 6 (137 Views)

Re: Re-set variables with SCRIPT on opening exisitng files.

03-30-2011 01:57 PM in reply to: eddyrichardson

eddyrichardson wrote:

Use a lisp file and run it every time a drawing is opened....i.e.

 

(defun c:svars (/)
(command "setvar" "imageframe" "2")
....etc....

(command "setvar" "layerevalctl" "0")
(setenv "ShowTabs" "1")
(princ)
)


If you're going to do that, I would recommend using the (setvar) Lisp function itself, rather than (command "setvar" ....), for each of those.  The (command) function is comparatively "heavy lifting" and will take longer, in addition to involving a lot more code characters, partly for the command words themselves and partly for the double-quotes around all the values, which you don't need in (setvar).  Also, in (getvar)/(setvar) you can use an apostrophe only at the beginning of a System Variable name, rather than double-quotes at both ends [though that also works].

 

(defun c:svars (/)
  (setvar 'imageframe 2)
  (setvar 'taskbar 1)
  (setvar 'previeweffect 0)
  ....etc....

  (setvar 'layerevalctl 0)
  (setenv "ShowTabs" "1")
  (princ)
)

Kent Cooper
*Expert Elite*
scot-65
Posts: 2,082
Registered: ‎12-11-2003
Message 5 of 6 (132 Views)

Re: Re-set variables with SCRIPT on opening existing files.

03-30-2011 03:48 PM in reply to: Caff

Others here seemed to ignore the fact you are using LT.

One would have to manually start the script as no LISP facilities is available for LT.

 

Someone chime in if it is possible to embed the S::smileyfrustrated:TARTUP or equivalent in a LT platform?

If so, (command ".SCRIPT" ...

 

???

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Active Contributor
Posts: 35
Registered: ‎10-21-2008
Message 6 of 6 (115 Views)

Re: Re-set variables with SCRIPT on opening exisitng files.

04-04-2011 01:06 AM in reply to: Caff

Thanks for the Apostrophe tip - makes it a lot easier.....

 

Of course if using LT then a script is required.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community