snap grid lisp help

snap grid lisp help

ht23624
Contributor Contributor
424 Views
6 Replies
Message 1 of 7

snap grid lisp help

ht23624
Contributor
Contributor

snap grid lisp doesn't work well. I want to make a lisp that changes the spacing of snap and grid at the same time. It doesn't work well. I'm a beginner in lisp, so please help me.

 

(defun c:s1()
(command "snap" "100" "")
(command "grid" "100" "")
(princ)
)


(defun c:s2()
(command "snap" "200" "")
(command "grid" "200" "")
(princ)
)

0 Likes
Accepted solutions (1)
425 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor
Accepted solution

try this:

(defun c:s1()
(command "_.snap" "100")
(command "_.grid" "100")
(princ)
)

(defun c:s2()
(command "_.snap" "200")
(command "_.grid" "200")
(princ)
)

Now at the command prompt even in the middle of a command like LINE you can enter:

LINE


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 7

cadffm
Consultant
Consultant

Hi,

 

less to do with lisp, command statements are nothing else then keyboard input (Acad recognise them as input in scripts, what is handled different than real manually keystrokes)

 

 

Open your program, let's test.

 


(command "snap" "100" "") =

(command  = send to commandline

"snap" = if in "" like here -> type SNAP in commandline and ENTER

"100" = if in "" like here -> type 100 in commandline and ENTER

"" =  -> type nothing and ENTER

 

 

Test it and type in (and one eye on screen to follow what you are doing)

 

Command: SNAP<enter>

Acad is asking for snap spacing, so answer!

Command: 100<enter>

 

and where we are now?

Isn't the command snap exit now, no commands running?

 

I think your last enter ("") in each (command-statement is too much)

 

HTH

 
 

 

 

Sebastian

Message 4 of 7

ht23624
Contributor
Contributor

thank you so much

0 Likes
Message 5 of 7

paullimapa
Mentor
Mentor

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 7

Kent1Cooper
Consultant
Consultant

I would do it this way:

(defun C:S1 ()
  (setvar 'snapunit '(100.0 100.0))
  (setvar 'gridunit '(100.0 100.0))
  (setvar 'gridmode 1)
)

(defun C:S2 ()
  (setvar 'snapunit '(200.0 200.0))
  (setvar 'gridunit '(200.0 200.0))
  (setvar 'gridmode 1)
)

In addition to setting the sizes, they ensure that the Grid is turned on.

Since they don't use (command) functions, they can be used transparently, in the middle of another command, by prefixing the command name with an apostrophe:

'S1 or 'S2

Kent Cooper, AIA
0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

Another idea, 

 

(defun c:s1()
(command "_.snap" "100")
(command "_.grid" "100")
(princ)
)

(defun c:s0()
(command "_.snap" "off")
(command "_.grid" "off")
(princ)
)

 

 

You can do transparent commands with some commands so

Line 's1 pickpoints ...... so this will set snap & grid to 100.

Line 's0 pickpoints .... will turn snap off

 

Note the single quote 's1

0 Likes