Bring Layers' objects to Front

Bring Layers' objects to Front

GeryKnee
Advocate Advocate
1,080 Views
5 Replies
Message 1 of 6

Bring Layers' objects to Front

GeryKnee
Advocate
Advocate

In the following lisp routine needed an if() insert to code, in order to abort i ss Collection is empty (If Layername doesn't represent any existant layer(s))


(defun C:LayerObjSendToFront (/)
(setq LayName (getstring "Layername : "))
(setq ss (ssget "X" (list ( cons 8 LayName))))
(command "draworder" ss "" "front")
(princ)
)

0 Likes
Accepted solutions (1)
1,081 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

@GeryKnee wrote:

In the following lisp routine needed an if() insert to code, in order to abort i ss Collection is empty (If Layername doesn't represent any existant layer(s))


(defun C:LayerObjSendToFront (/)
  (setq LayName (getstring "Layername : "))
  (if

    (setq ss (ssget "X" (list ( cons 8 LayName))))
    (command "draworder" ss "" "front")

  )
  (princ)
)


Unless I misunderstand, can it be as simple as that?

Kent Cooper, AIA
0 Likes
Message 3 of 6

GeryKnee
Advocate
Advocate

Hello Kent,

I can't undestand where is the error in following code

 


(defun fnLayerObjSendToFront (LayerName )
(if (setq ss (ssget "X" (list ( cons 8 LayName))))
(command "draworder" ss "" "front"))
(princ)
)
(defun c:LayerObjSendToFront(/)
(if (setq LayerName (getString "\nSpecify layer name: "))
(progn
(fnLayerObjSendToFront LayerName)
)
)
(princ)
)

when is executing  the following is sent

Command: LayerObjSendToFront

Specify layer name: L*

; error: bad SSGET list value

 

while when the same writen but with inside c:LayerObjSendToFront call (not using function fnLayerObjSendToFront ) works succesfully.

Where is the fault??

Thanks,

Gery

 

 

 

 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

(if (setq ss (ssget "X" (list ( cons 8 LayerName))))

Kent Cooper, AIA
Message 5 of 6

GeryKnee
Advocate
Advocate

Thank you Kent.

A simple Checker software is necessary i think so.

Or you have to be very carefull.

Thank you very much,\Regards,

Gery.

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Would it not be easier 

 

(setq layername (cdr (assoc 8 (entget (car (entsel"\nChoose object for layer"))))))