Lisp for Layer Freeze, LTScale 50 (all lines)

Lisp for Layer Freeze, LTScale 50 (all lines)

melissa.quintrall
Explorer Explorer
369 Views
6 Replies
Message 1 of 7

Lisp for Layer Freeze, LTScale 50 (all lines)

melissa.quintrall
Explorer
Explorer

I'm new to the lisp writing and have 2 successful small lisps under my belt. My team now wants to add the above commands to the simplest lisp and I can't figure where my fail/errors are .

I built a block specifically for this command but when I run it I get the " ; error: no function definition: COMMAND: "

 

(defun C:QCCK (/)

(Command: "_LAYFRZ")

(Command: "S")

(Command: "B")

(Command: "B")

(Command: "REFERENCE-LAYFRZ")

 

(Command: "LTSCALE")

(Command: "50")

)

 

Where am I going wrong?

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

ronjonp
Mentor
Mentor
Accepted solution
Remove the colons after all "command:" .. ie (Command: "_LAYFRZ") should be (Command "_LAYFRZ")
Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

... and just so you know [to streamline future efforts considerably], you don't need a separate (command) function for every entry, and in fact you can include not just a sequence of inputs for a single command, but even more than one command, in a single (command) function -- try it consolidated something like this:

 

(defun C:QCCK (/)

  (Command

    "_LAYFRZ" "S" "B" "B" "REFERENCE-LAYFRZ"

    "LTSCALE" "50"

  )

)

 

Kent Cooper, AIA
0 Likes
Message 4 of 7

melissa.quintrall
Explorer
Explorer

Thank you so much for the help. These have been fighting me for 2 days!

0 Likes
Message 5 of 7

paullimapa
Mentor
Mentor

I assume you want to freeze all objects on layer called: "REFERENCE-LAYFRZ"

I would use the if function to check the following:

1. that layer is not the current layer otherwise LAYFRZ command will fail:

(if
 (and
  (/= "REFERENCE-LAYFRZ" (getvar"clayer"))
 )
 (progn
 ) ; progn
) ; if

2. make sure there are objects all that layer by doing a selection set:

(if
 (and
  (/= "REFERENCE-LAYFRZ" (getvar"clayer"))
  (setq ss(ssget "_X" '((8 . "REFERENCE-LAYFRZ"))))
 )
 (progn
 ) ; progn
) ; if

Now if both of those cases are true, the LAYFRZ command requires an object selection point along with the entity itself so run the following:

(if
 (and
  (/= "REFERENCE-LAYFRZ" (getvar"clayer")) ; check not current layer
  (setq ss(ssget "_X" '((8 . "REFERENCE-LAYFRZ")))) ; get selection set
 )
 (progn
  (setq en(ssname ss 0)) ; get first entity in selection set
  (setq pt(cdr(assoc 10 (entget en)))) ; get base point of that entity
  (setq en1 (append en1 (list en pt))) ; build list with entity and point
  (command "_.LayFrz" "_S" "_B" "_B" en1) ; frz all objects on that layer
 ) ; progn
) ; if

Now you can set ltscale with either option:

(command "_.LTSCALE" "50") ; set ltscale using command
(setvar "LTSCALE" 50) ; set ltscale using system variable

 


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

melissa.quintrall
Explorer
Explorer

The "REFERENCE-LAYFRZ" is a block I created on the Reference layer that we are needing to be able to freeze in the lisp. The only way I could figure out how to get the lisp to do the command was to do this.

But even with the block indicated in the lisp, it doesn't freeze the layer without selecting the block and then the lisp doesn't continue to completion. It's the one hurdle I can't get past in this project.

I'm new to writing lisp and am building this one based on typed commands and the prompts they give me. 

0 Likes
Message 7 of 7

paullimapa
Mentor
Mentor

Having Block name doesn’t help because blocks can be placed on various layers. The only way LayFrz command works is by entity selection of the layer that’s on. Since you know the layer name then use that name in the sample code I provided previously. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes