AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Standardized Grid and Snap Settings

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anthony.Mauric
642 Views, 7 Replies

Standardized Grid and Snap Settings

We're trying to standardize grid and snap settings at my company, and so have implemented a LISP file into everyone's startup. This is currently working, but I'd like to improve it.

(defun c"test nil
  (command "_.Grid" "_Major" "4"
           "_.Grid" .25
		   "_.Grid" "_On"
		   "_.Snap" .0625
		   "_.Snap" "_On"))

 

I think it might be the cause behind some lag time between opening a file to when it's ready to edit. I know it's also the reason why every file now shows up as having been edited even if nothing technically changed.

 

I'd like to know if there's any way to check the file for the grid and snap settings before running the commands, so the file may not need to be changed or to do them more elegantly, so it isn't as resource intensive.

7 REPLIES 7
Message 2 of 8
jseefdrumr
in reply to: Anthony.Mauric

I'm not sure, but I doubt that there is very much (if any) difference - as far as how much computing power is used - between telling ACADE to change the grid settings vs asking it what they are.

That said, there are ways within LISP to do what you want. My advice would be to cross-post this question on the customization forums, where you're more likely to encounter users who regularly use LISP.


Jim Seefeldt
Electrical Engineering Technician


Message 3 of 8

As Jim said, that code won't impact the loading very much.

If you for some reason want to test variables before changing them, there are system variables for most settings.

Like this for GridMajor:
(if (not (= (getvar "GRIDMAJOR") 4))(setvar "GRIDMAJOR" 4))

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
Message 4 of 8

Thank you for the suggestion @rhesusminus,

 

I'm having a little trouble with Gridunit and snapunit though, when testing with setvar in the command prompt it seems to be looking for a 2d coordinate. The following works;

 

2020-03-03 09_13_56-Clipboard.png

 

and I'm not quite sure what the proper format to test and set this would be in the code

 

 

(if (not (= (getvar "GRIDUNIT") .25,.25))(setvar "GRIDUNIT" .25,.25))

 

 

Message 5 of 8
Anonymous
in reply to: Anthony.Mauric

I normally set these settings via the Drafting Settings  in the drawing template, see attached.  And it works

Message 6 of 8
Anthony.Mauric
in reply to: Anonymous

Thanks @Anonymous, but that's not going to work in this case.

 

In any case, I found what I was looking for. I needed to put my settings in a list. I'm not sure if I needed to also put them as variables, I was getting an error about an unexpected decimal point, but it worked.

 

(setq var1 0.25)
(if (not (= (getvar "GRIDUNIT") (list var1 var1)))(setvar "GRIDUNIT" (list var1 var1)))

 

Message 7 of 8

You can't compare two lists with =
You must use the equal function, like this:

(if (not (equal '(0.25 0.25) (getvar "GRIDUNIT")))(setvar "GRIDUNIT" '(0.25 0.25)))(princ)

And, you MUST include the initial zero for coordinates in a list.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
Message 8 of 8

Thanks @rhesusminus, I fixed that.

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

Post to forums  

Autodesk Design & Make Report