Author Topic: Cycle Through Layouts  (Read 918 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 837
Cycle Through Layouts
« 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.

Lee Mac

  • Seagull
  • Posts: 10110
  • AutoCAD 2015 Windows 7 London, England
Re: Cycle Through Layouts
« Reply #1 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. )

 :?

cmwade77

  • Swamp Rat
  • Posts: 837
Re: Cycle Through Layouts
« Reply #2 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.


Lee Mac

  • Seagull
  • Posts: 10110
  • AutoCAD 2015 Windows 7 London, England
Re: Cycle Through Layouts
« Reply #3 on: March 07, 2012, 02:54:39 pm »
You're welcome  :-)  I was confused as to the restrictions you imposed, but that makes sense  :-)

Tharwat

  • Bull Frog
  • Posts: 369
  • Hypersensitive
Re: Cycle Through Layouts
« Reply #4 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)
)
Get learn and learn and practice , to become experienced guy .

fixo

  • Swamp Rat
  • Posts: 856
  • My location is not in the Hitleropa
Re: Cycle Through Layouts
« Reply #5 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'~
\\\"Always drink upstream from the herd."\\\ - Will Rogers, was died in 1935 plane crash

--> Donate to TheSwamp <--

cmwade77

  • Swamp Rat
  • Posts: 837
Re: Cycle Through Layouts
« Reply #6 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.
« Last Edit: March 07, 2012, 04:45:32 pm by cmwade77 »

dgorsman

  • Water Moccasin
  • Posts: 1786
Re: Cycle Through Layouts
« Reply #7 on: March 07, 2012, 05:13:58 pm »
If you can't open AutoCAD, .NET is completely out of the picture.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cmwade77

  • Swamp Rat
  • Posts: 837
Re: Cycle Through Layouts
« Reply #8 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.
« Last Edit: March 07, 2012, 05:31:39 pm by cmwade77 »

dgorsman

  • Water Moccasin
  • Posts: 1786
Re: Cycle Through Layouts
« Reply #9 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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cmwade77

  • Swamp Rat
  • Posts: 837
Re: Cycle Through Layouts
« Reply #10 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.

Jeff H

  • Needs a day job
  • Posts: 4733
Re: Cycle Through Layouts
« Reply #11 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

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.

cmwade77

  • Swamp Rat
  • Posts: 837
Re: Cycle Through Layouts
« Reply #12 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

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.

Jeff H

  • Needs a day job
  • Posts: 4733
Re: Cycle Through Layouts
« Reply #13 on: March 07, 2012, 08:01:42 pm »
I just meant for working across platforms.
 
Cocoa for the mac maybe?