Author Topic: Cycle Through Layouts  (Read 3094 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
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: 12905
  • 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: 1443
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: 12905
  • 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

  • Swamp Rat
  • Posts: 707
  • 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)
)

fixo

  • Guest
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'~

cmwade77

  • Swamp Rat
  • Posts: 1443
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: 2437
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: 1443
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: 2437
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: 1443
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: 6144
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: 1443
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: 6144
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?