Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with a routine

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
msarqui
229 Views, 4 Replies

Help with a routine

Hello!

 

I am trying to select objects with a window selection. After this, bring to front all Mtexts, and send to back all Dimensions. 

Any help?

 

(defun c:test (/ sel1)
(princ "\nSelect a Mtext or Dimension")

 

(setq sel1 (ssget))

 

 (cond
     ((= sel1 "DIMENSION"); If Dimension
     (command "draworder" sel1 "" "b"); send it to back
     );eq


     ((= sel1 "MTEXT"); If Mtext
     (command "draworder" sel1 "" "f"); bring to front
     );eq
 ); cond
  
); defun

4 REPLIES 4
Message 2 of 5
_Tharwat
in reply to: msarqui

Try this ...

 

(defun c:Test (/ ss)
(princ "\nSelect Mtexts and Dimensions")
  (if (setq ss (ssget "_:L" '((0 . "MTEXT,*DIMENSION"))))
    ((lambda (i / sn )
       (while (setq sn (ssname ss (setq i (1+ i))))
         (if (= (cdr (assoc 0 (entget sn))) "MTEXT")
           (command "draworder" sn "" "f")
           (command "draworder" sn "" "b")
           )
         )
       ) -1 )
    )
  (princ)
  )

 

Message 3 of 5
hmsilva
in reply to: msarqui

Another

 

(defun c:Demo (/ ss ssD ssM)
  (prompt "\nSelect Mtexts and Dimensions")
  (if (setq ss (ssget "_:L" '((0 . "MTEXT,*DIMENSION"))))
    (progn
      (setq ssM (ssget "_P" '((0 . "MTEXT"))))
      (command "_.select" ss "")
      (setq ssD (ssget "_P" '((0 . "*DIMENSION"))))
      (if ssM
	(command "_.draworder" ssM "" "_F")
      )
      (if ssD
	(command "_.draworder" ssD "" "_B")
      )
    )
  )
  (princ)
)

 

HTH

Henrique

EESignature

Message 4 of 5
msarqui
in reply to: hmsilva

Many thanks to both of you.


The two answers are realy good. I will accept Henrique's answer as a solution because the two separate "If". It suits better for my purposes. Kudos to Tharwat

Message 5 of 5
hmsilva
in reply to: msarqui

You're welcome, msarqui
Glad I could help

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost