Jump to content

Send Wipeout to Back of Draworder within Block Definition


b_gum

Recommended Posts

So I have been trying to figure this out with several approaches now and I need some help. 

I would like to send all Wipeouts, or really any specified entity type, within a block to the back of the draw order. 

 

Is there a way to do this using Lee Mac's Apply To Block Objects routine?  I tried this in conjunction with his draw order routines but the MovetoBottom command kept failing. I'm pretty rough with VisualLisp which is part of the issue when trying to troubleshoot his great routines. 

 

Or what about this approach? (I dont really understand it, again Visual Lisp)

 

Below is what I tried. 

I do understand Vanilla Lisp. Visual Lisp I barely know the basics, but eager to learn. 

Please help me improve my capabilities. I love autolisp. Thank you. 

 

The issue is clearly with the lambda function and my improper use of it Im sure. The ssget I am trying to do is incorrect approach for use with his function. 

 

;===========================================================
; 11/Sep/2020 10:09 AM[Friday]	AUTHOR: Brandon Gum
;--
;DESCRIPTION: 
;Select block with wipeout. 
;Will send wipeout objects the back of the draw orer
;===========================================================
(defun c:test ( / s )
    (princ "\nSelect Block: ")
    (if (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
        (LM:ApplytoBlockObjects
            (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
            (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))
           '(lambda ( obj ) (BG:WipeoutToBottom))
        )
    )
    (princ)
)
(vl-load-com) (princ)


(defun BG:WipeoutToBottom( / )
    
	(LM:movetobottom (ssget "X" '((0 . "WIPEOUT"))))
    ;(princ)
);end of defun
;===============Below here are Lee's draw order functions==============

 

My LeeMac Based Approach.LSP

Link to comment
Share on other sites

Hi,

Here is one way and the simplest one.

(defun c:Test ( / sel)
  ;; Tharwat - 11.Sep.2020	;;
  (and (princ "\nSelect a block: ")
       (setq sel (ssget "_+.:S:E:L" '((0 . "INSERT"))))
       (progn
         (command "_.bedit" (cdr (assoc 2 (entget (ssname sel 0)))))
         (if (setq sel (ssget "_X" '((0 . "~WIPEOUT"))))
           (command "_.draworder" sel "" "Front")
         )
         (if (setq sel (ssget "_X" '((0 . "WIPEOUT"))))
           (command "_.draworder" sel "" "Back")
         )
         (command "_.bclose" "Save")
       )
  )
  (princ)
)

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, b_gum said:

So I have been trying to figure this out with several approaches now and I need some help. 

I would like to send all Wipeouts, or really any specified entity type, within a block to the back of the draw order. 

 

Is there a way to do this using Lee Mac's Apply To Block Objects routine?  I tried this in conjunction with his draw order routines but the MovetoBottom command kept failing. I'm pretty rough with VisualLisp which is part of the issue when trying to troubleshoot his great routines. 

 

Or what about this approach? (I dont really understand it, again Visual Lisp)

 

Below is what I tried. 

I do understand Vanilla Lisp. Visual Lisp I barely know the basics, but eager to learn. 

Please help me improve my capabilities. I love autolisp. Thank you. 

 

The issue is clearly with the lambda function and my improper use of it Im sure. The ssget I am trying to do is incorrect approach for use with his function. 

 


;===========================================================
; 11/Sep/2020 10:09 AM[Friday]	AUTHOR: Brandon Gum
;--
;DESCRIPTION: 
;Select block with wipeout. 
;Will send wipeout objects the back of the draw orer
;===========================================================
(defun c:test ( / s )
    (princ "\nSelect Block: ")
    (if (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
        (LM:ApplytoBlockObjects
            (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
            (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))
           '(lambda ( obj ) (BG:WipeoutToBottom))
        )
    )
    (princ)
)
(vl-load-com) (princ)


(defun BG:WipeoutToBottom( / )
    
	(LM:movetobottom (ssget "X" '((0 . "WIPEOUT"))))
    ;(princ)
);end of defun
;===============Below here are Lee's draw order functions==============

 

My LeeMac Based Approach.LSP 4.07 kB · 0 downloads

 

Try

 

(defun c:test ( / s )
    (princ "\nSelect Block: ")
    (if (setq s (ssget "_+.:E:S" '((0 . "INSERT"))))
        (LM:ApplytoBlockObjects
            (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
            (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))
           '(lambda ( obj ) (if (= "AcDbWipeout" (vlax-get obj 'objectname)) (LM:movetobottom (list obj))))
        )
    )
    (princ)
)
(vl-load-com) (princ)

 

This will not alter dynamic blocks or some blocks with attributes as these will be anonymous and the routine gets the effectivename property which will point to the parent block. If you want it to work on anonymous blocks change (vla-get-effectivename ...) to (vla-get-name...)

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 9/11/2020 at 11:40 PM, Tharwat said:

Hi,

Here is one way and the simplest one.

(defun c:Test ( / sel)
  ;; Tharwat - 11.Sep.2020	;;
  (and (princ "\nSelect a block: ")
       (setq sel (ssget "_+.:S:E:L" '((0 . "INSERT"))))
       (progn
         (command "_.bedit" (cdr (assoc 2 (entget (ssname sel 0)))))
         (if (setq sel (ssget "_X" '((0 . "~WIPEOUT"))))
           (command "_.draworder" sel "" "Front")
         )
         (if (setq sel (ssget "_X" '((0 . "WIPEOUT"))))
           (command "_.draworder" sel "" "Back")
         )
         (command "_.bclose" "Save")
       )
  )
  (princ)
)

 

 

 

What do I need to edit if I don't want to select a block?

I need this to work on dynamic blocks btw...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...