TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: w64bit on May 09, 2021, 08:37:18 AM

Title: ssget in layouts
Post by: w64bit on May 09, 2021, 08:37:18 AM
I use this code for some DWGs but sometimes it stops.
Can anyone tell me what I have to add to make it working?
Thank you
Code: [Select]
(foreach tab (layoutlist) (setvar 'CTAB lay) (if (setq selblk (ssget "_X" '((0 . "INSERT"))))(command "_DRAWORDER" selblk "" "_BACK")))
Title: Re: ssget in empty layouts
Post by: ribarm on May 09, 2021, 08:49:40 AM
I don't know where the problem lies, but personaly I'd do it this way...

Quote
(foreach tab (layoutlist) (if (setq selblk (ssget "_X" (list '(0 . "INSERT") (cons 410 tab))))(command "_DRAWORDER" selblk "" "_BACK")))
Title: Re: ssget in empty layouts
Post by: w64bit on May 09, 2021, 09:14:04 AM
The code stops on several drawings with:
Code: [Select]
Select objects:   4 found
4 were not in current space.

Select objects:
Command: _BACK Unknown command "BACK".
Title: Re: ssget in empty layouts
Post by: Marc'Antonio Alessi on May 09, 2021, 09:46:32 AM
(foreach tab (layoutlist) (setvar 'CTAB tab) (if (setq selblk (ssget "_X" (list '(0 . "INSERT") (cons 410 tab))))(command "_DRAWORDER" selblk "" "_BACK")))
Title: Re: ssget in empty layouts
Post by: w64bit on May 09, 2021, 10:02:38 AM
Yes. Yes. Yes.
Thank you very much.
Title: Re: ssget in layouts
Post by: Marc'Antonio Alessi on May 09, 2021, 12:40:12 PM
Prego  :)
Title: Re: ssget in layouts
Post by: Lee Mac on May 10, 2021, 12:16:21 PM
For what it's worth, if you were to download & load my set of Draw Order Functions (http://lee-mac.com/draworderfunctions.html), you can use the following program to achieve the same result without the need to switch the active layout:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:blk2back ( )
  2.     (foreach tab (layoutlist)
  3.         (LM:movetobottom (ssget "_X" (list '(0 . "INSERT") (cons 410 tab))))
  4.     )
  5.     (princ)
  6. )
Title: Re: ssget in layouts
Post by: cmwade77 on May 11, 2021, 07:59:05 PM
Please correct me if I am wrong, but shouldn't ssget "_X" be able to select everything in the entire drawing if you don't use (cons 410 tab) ?

Or is this a case where you only want to select these objects if they are in paperspace, but not modelspace?
Title: Re: ssget in layouts
Post by: ronjonp on May 11, 2021, 09:38:19 PM
Please correct me if I am wrong, but shouldn't ssget "_X" be able to select everything in the entire drawing if you don't use (cons 410 tab) ?

Or is this a case where you only want to select these objects if they are in paperspace, but not modelspace?
That is correct but most likely a limitation of the command call.
Title: Re: ssget in layouts
Post by: Marc'Antonio Alessi on May 12, 2021, 02:39:18 AM
Please correct me if I am wrong, but shouldn't ssget "_X" be able to select everything in the entire drawing if you don't use (cons 410 tab) ?

Or is this a case where you only want to select these objects if they are in paperspace, but not modelspace?
As Ron wrote: That is correct but most likely a limitation of the command call.
See replay #2
Code: [Select]
Select objects:   4 found
4 were not in current space.

Select objects:
Command: _BACK Unknown command "BACK".
Title: Re: ssget in layouts
Post by: cmwade77 on May 12, 2021, 11:34:02 AM
I believe that the draworder can be set using activex calls, can't it?
Title: Re: ssget in layouts
Post by: ronjonp on May 12, 2021, 11:37:12 AM
I believe that the draworder can be set using activex calls, can't it?
Yes .. that was Lee's contribution :)
http://www.theswamp.org/index.php?topic=56731.msg604592#msg604592
Title: Re: ssget in layouts
Post by: cmwade77 on May 12, 2021, 12:02:25 PM
Ah, I missed that one, leave it to him to beat me to it.