Author Topic: ssget in layouts  (Read 2392 times)

0 Members and 1 Guest are viewing this topic.

w64bit

  • Newt
  • Posts: 78
ssget in layouts
« 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")))
« Last Edit: May 09, 2021, 10:03:01 AM by w64bit »

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ssget in empty layouts
« Reply #1 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")))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

w64bit

  • Newt
  • Posts: 78
Re: ssget in empty layouts
« Reply #2 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".
« Last Edit: May 09, 2021, 09:33:59 AM by w64bit »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: ssget in empty layouts
« Reply #3 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")))

w64bit

  • Newt
  • Posts: 78
Re: ssget in empty layouts
« Reply #4 on: May 09, 2021, 10:02:38 AM »
Yes. Yes. Yes.
Thank you very much.


Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: ssget in layouts
« Reply #6 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, 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. )

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: ssget in layouts
« Reply #7 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?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: ssget in layouts
« Reply #8 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: ssget in layouts
« Reply #9 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".

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: ssget in layouts
« Reply #10 on: May 12, 2021, 11:34:02 AM »
I believe that the draworder can be set using activex calls, can't it?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: ssget in layouts
« Reply #11 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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: ssget in layouts
« Reply #12 on: May 12, 2021, 12:02:25 PM »
Ah, I missed that one, leave it to him to beat me to it.