TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cmwade77 on March 07, 2012, 12:34:10 PM

Title: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 12:34:10 PM
Ok, so here is the deal, I need to get all layout names in a drawing and cycle through them, without using any of the following:
VLA or VLAX commands
LayoutList

VB.Net is acceptable, as long as I can use it in a stand alone .EXE file without AutoCAD running.

Any ideas would be greatly appreciated.
Title: Re: Cycle Through Layouts
Post by: Lee Mac on March 07, 2012, 12:47:08 PM
Code - Auto/Visual Lisp: [Select]
  1. (defun _getlayouts ( / lst )
  2.     (foreach pair (dictsearch (namedobjdict) "ACAD_LAYOUT")
  3.         (if (= 3 (car pair))
  4.             (setq lst (cons (cdr pair) lst))
  5.         )
  6.     )
  7.     (reverse lst)
  8. )

 :?
Title: Re: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 02:32:14 PM
Code - Auto/Visual Lisp: [Select]
  1. (defun _getlayouts ( / lst )
  2.     (foreach pair (dictsearch (namedobjdict) "ACAD_LAYOUT")
  3.         (if (= 3 (car pair))
  4.             (setq lst (cons (cdr pair) lst))
  5.         )
  6.     )
  7.     (reverse lst)
  8. )

 :?
Thank you Lee...this works perfectly for what I am working on. I honestly couldn't think of how to approach this, I prefer the vlax methods, but I need to build something that works across platforms (MAC & PC) without using the nice (layoutlist) function.

Title: Re: Cycle Through Layouts
Post by: Lee Mac on March 07, 2012, 02:54:39 PM
You're welcome  :-)  I was confused as to the restrictions you imposed, but that makes sense  :-)
Title: Re: Cycle Through Layouts
Post by: Tharwat on March 07, 2012, 03:16:19 PM
Another  :-)

Code: [Select]
(defun c:TesT (/ names)
  (mapcar (function (lambda (x)
                      (if (eq (car x) 3)
                        (setq names (cons (cdr x) names))
                      )
                    )
          )
          (dictsearch (namedobjdict) "ACAD_LAYOUT")
  )
  (print (reverse names))
  (princ)
)
Title: Re: Cycle Through Layouts
Post by: fixo on March 07, 2012, 03:23:59 PM
Ok, so here is the deal, I need to get all layout names in a drawing and cycle through them, without using any of the following:
VLA or VLAX commands
LayoutList

VB.Net is acceptable, as long as I can use it in a stand alone .EXE file without AutoCAD running.

Any ideas would be greatly appreciated.
try this windows forms project just for your interest
Tested on A2009 Win7 Framework 3.0
Be patience works slowly

~'J'~
Title: Re: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 04:38:02 PM
Ok, so here is the deal, I need to get all layout names in a drawing and cycle through them, without using any of the following:
VLA or VLAX commands
LayoutList

VB.Net is acceptable, as long as I can use it in a stand alone .EXE file without AutoCAD running.

Any ideas would be greatly appreciated.
try this windows forms project just for your interest
Tested on A2009 Win7 Framework 3.0
Be patience works slowly

~'J'~
Thank you, but the key portion was to not open AutoCAD as I am trying to make my routine run faster and opening AutoCAD slows it down dramatically.

To that end, does anyone have an ideas on how the following code can be sped up?
Code: [Select]
(if (= (getvar "pstylemode") 1) (setq pMode "Civil.ctb") (setq pmode "PDF & DWF.stb"))
(foreach pair (dictsearch (namedobjdict) "ACAD_LAYOUT")(if (= 3 (car pair))(if (/= (strcase (cdr pair)) "MODEL")(progn (command "layout" "S" (cdr pair))
(command "-plot" "Y" "" "DWG to PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "inches"
"Landscape"
"N"
"Extents"
"1:1"
"CENTER"
"Y"
pmode
"Y"
"Y"
"N"
"N"
(strcat "H:\\Projects\\117 Small Projects 11\\11-005 N. Sycamore Drive\\Sent\\PDF\\2012-03-07\\M-0.1 MECHANICAL GENERAL NOTES SYMBOLS LEGEND & SHEET INDEX_" (cdr pair) ".pdf")
"N"
"Y"
)))))
Again, with the same restrictions as at the beginning of this thread.
Title: Re: Cycle Through Layouts
Post by: dgorsman on March 07, 2012, 05:13:58 PM
If you can't open AutoCAD, .NET is completely out of the picture.
Title: Re: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 05:17:33 PM
If you can't open AutoCAD, .NET is completely out of the picture.
Not completely, see this article:
http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html

Combining this with scripts and .NET, you should be able to come up with some very creative tools that run considerably faster than what you can do as of right now, at least that is my guess based on how much faster they claim it opens than the traditional full version of AutoCAD.
Title: Re: Cycle Through Layouts
Post by: dgorsman on March 07, 2012, 06:30:00 PM
OK, if you want to be nit-picky.   :grazy:  Still running AutoCAD though, just without the UI.
Title: Re: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 06:31:08 PM
OK, if you want to be nit-picky.   :grazy:  Still running AutoCAD though, just without the UI.
True, but, much, much faster, just more limited.

Honestly, the above works great for my needs.
Title: Re: Cycle Through Layouts
Post by: Jeff H on March 07, 2012, 07:38:55 PM
If you can't open AutoCAD, .NET is completely out of the picture.
Not completely, see this article:
http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html (http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html)

Combining this with scripts and .NET, you should be able to come up with some very creative tools that run considerably faster than what you can do as of right now, at least that is my guess based on how much faster they claim it opens than the traditional full version of AutoCAD.

But then
 
Thank you Lee...this works perfectly for what I am working on. I honestly couldn't think of how to approach this, I prefer the vlax methods, but I need to build something that works across platforms (MAC & PC) without using the nice (layoutlist) function.

For now that officially puts .NET completely out of the picture.
Title: Re: Cycle Through Layouts
Post by: cmwade77 on March 07, 2012, 07:41:46 PM
If you can't open AutoCAD, .NET is completely out of the picture.
Not completely, see this article:
http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html (http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html)

Combining this with scripts and .NET, you should be able to come up with some very creative tools that run considerably faster than what you can do as of right now, at least that is my guess based on how much faster they claim it opens than the traditional full version of AutoCAD.

But then
 
Thank you Lee...this works perfectly for what I am working on. I honestly couldn't think of how to approach this, I prefer the vlax methods, but I need to build something that works across platforms (MAC & PC) without using the nice (layoutlist) function.

For now that officially puts .NET completely out of the picture.
Not entirely, now that I have the script right (this is the part that I need to work cross platform), it's just building out the interface, which is what I am using .NET for on the PC (mostly because it is what I know), then making a similar interface on the Mac shouldn't be too hard.
Title: Re: Cycle Through Layouts
Post by: Jeff H on March 07, 2012, 08:01:42 PM
I just meant for working across platforms.
 
Cocoa  (http://en.wikipedia.org/wiki/Cocoa_(API))for the mac maybe?