TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jmcshane on March 28, 2022, 11:59:17 AM

Title: Get layout tab list without using Active X?
Post by: jmcshane on March 28, 2022, 11:59:17 AM
Hi guys,

Haven't posted here in a while. Just trying figure out if there is a way to get a list of layout tabs without using active X or the Layoutlist command.
Looking at doing some acoreconsole work and it doesn't handle activeX.
I am trying to delete layouts which don't have the same name as the drawing.

Would be grateful if someone could point me in the right direction.

Cheers

John
Title: Re: Get layout tab list without using Active X?
Post by: VovKa on March 28, 2022, 12:06:23 PM
(dictsearch (namedobjdict) "ACAD_LAYOUT")
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 28, 2022, 12:16:20 PM
Oh now that's neat!!

Please excuse my next question as its been a few years since I coded properly and am a bit rusty.....

I was going to stick the result of this into a list and just delete whatever layout didn't match with a foreach loop, how can I just grab all the assoc 3 pairs?

Thanks in advance,

John
Title: Re: Get layout tab list without using Active X?
Post by: ronjonp on March 28, 2022, 02:19:14 PM
Oh now that's neat!!

Please excuse my next question as its been a few years since I coded properly and am a bit rusty.....

I was going to stick the result of this into a list and just delete whatever layout didn't match with a foreach loop, how can I just grab all the assoc 3 pairs?

Thanks in advance,

John
Just check within your loop like so:
Code - Auto/Visual Lisp: [Select]
  1. (foreach x (dictsearch (namedobjdict) "ACAD_LAYOUT")
  2.   (if (= 3 (car x))
  3.       ;; Do stuff
  4.   )
  5. )
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 28, 2022, 05:48:07 PM
Thanks a million Guys, that's exactly what I needed.
Really appreciate the help.

John
Title: Re: Get layout tab list without using Active X?
Post by: Lee Mac on March 28, 2022, 07:19:48 PM
You could alternatively use dictnext in a manner analogous to how you might use tblnext to iterate over a symbol table, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (defun mylayoutlist ( / dic itm rtn )
  2.     (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout"))))
  3.         (while (setq itm (dictnext dic (not itm)))
  4.             (setq rtn (cons (cdr (assoc 1 (member '(100 . "AcDbLayout") itm))) rtn))
  5.         )
  6.     )
  7.     (reverse rtn)
  8. )
Title: Re: Get layout tab list without using Active X?
Post by: Stefan on March 29, 2022, 05:03:56 AM
What is wrong with
Code - Auto/Visual Lisp: [Select]
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 29, 2022, 09:03:29 AM
What is wrong with
Code - Auto/Visual Lisp: [Select]

(LayoutList) works fine when used normally, but for some reason it wouldn't work when using acoreconsole.
I'm thinking it might be based on ActiveX which isn't supported in acoreconsole as far as I know.

Cheers,

John
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 29, 2022, 09:06:20 AM
You could alternatively use dictnext in a manner analogous to how you might use tblnext to iterate over a symbol table, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (defun mylayoutlist ( / dic itm rtn )
  2.     (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout"))))
  3.         (while (setq itm (dictnext dic (not itm)))
  4.             (setq rtn (cons (cdr (assoc 1 (member '(100 . "AcDbLayout") itm))) rtn))
  5.         )
  6.     )
  7.     (reverse rtn)
  8. )

Thanks Lee, you'll have to excuse my lack of knowledge here, but what benefits would this have over the other way?

Thanks in advance,

John
Title: Re: Get layout tab list without using Active X?
Post by: Lee Mac on March 29, 2022, 10:17:28 AM
You could alternatively use dictnext in a manner analogous to how you might use tblnext to iterate over a symbol table, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (defun mylayoutlist ( / dic itm rtn )
  2.     (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout"))))
  3.         (while (setq itm (dictnext dic (not itm)))
  4.             (setq rtn (cons (cdr (assoc 1 (member '(100 . "AcDbLayout") itm))) rtn))
  5.         )
  6.     )
  7.     (reverse rtn)
  8. )

Thanks Lee, you'll have to excuse my lack of knowledge here, but what benefits would this have over the other way?

No particular benefit, just another way to skin the cat  :-)
Title: Re: Get layout tab list without using Active X?
Post by: VovKa on March 29, 2022, 11:45:12 AM
I'm thinking it might be based on ActiveX which isn't supported in acoreconsole as far as I know.
(layoutlist) is defined inside acapp.arx which is not loaded by acoreconsole
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 29, 2022, 12:26:59 PM
Thanks guys, really appreciate all the information and help.

John
Title: Re: Get layout tab list without using Active X?
Post by: BlackBox on March 30, 2022, 07:02:29 AM
I'm thinking it might be based on ActiveX which isn't supported in acoreconsole as far as I know.
(layoutlist) is defined inside acapp.arx which is not loaded by acoreconsole

So simply load it in the Script:

Code: [Select]
_.arx L "acapp.arx"
(setq foo (layoutlist))

Core Console supports loading ARX/.NET assemblies.

Cheers
Title: Re: Get layout tab list without using Active X?
Post by: jmcshane on March 30, 2022, 09:09:37 AM
Thanks BlackBox, I didn't know you could do that.