Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*amy
Message 1 of 16 (1,246 Views)

Delete layout Tab?

1246 Views, 15 Replies
12-12-2002 03:59 AM
hi:
I would like to delete ALL the paper space layout tabs except ModelSpace.
What Lisp or vlisp function can do this?

thanks
*Middleton, Cliff
Message 2 of 16 (1,246 Views)

Re: Delete layout Tab?

12-12-2002 04:52 AM in reply to: *amy
(vla-delete )

"amy" wrote in message
news:805E3C4A43B8C191FCBCA21F5506DD01@in.WebX.maYIadrTaRb...
> hi:
> I would like to delete ALL the paper space layout tabs except ModelSpace.
> What Lisp or vlisp function can do this?
>
> thanks
>
>
*Oquendo, Frank
Message 3 of 16 (1,246 Views)

Re: Delete layout Tab?

12-12-2002 04:57 AM in reply to: *amy
amy had this to say
:
> I would like to delete ALL the paper space layout tabs except
> ModelSpace. What Lisp or vlisp function can do this?

Be aware that you will always have one paperspace layout even if you
delete them all.

(defun delLayouts (/ layouts)
(vl-load-com)
(setq layouts
(vla-get-layouts
(vla-get-activedocument (vlax-get-acad-object))
)
)
(mapcar '(lambda (layout)
(vla-delete (vla-item layouts layout))
)
(layoutlist)
)
(princ)
)

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
*Piercey, Jason
Message 4 of 16 (1,246 Views)

Re: Delete layout Tab?

12-12-2002 05:09 AM in reply to: *amy
;; Purpose:
;; Delete layout tabs sepcfied by [Names]
;; Arguments:
;; [Names] - string, name of layout to be deleted
;; wildcard patterns allowed
;; Usage:
;; (DeleteLayouts "Layout1,Layout2")
;; (DeleteLayouts "Layout*")
(defun DeleteLayouts (Names / Layouts Tmp)
(vl-load-com)
(setq
Layouts
(vla-get-layouts
(vla-get-activedocument
(vlax-get-acad-object))) )

(vlax-for x Layouts
(setq Tmp (strcase (vla-get-name x)))
(if (and (/= "Model" Tmp) (wcmatch Tmp (strcase Names)))
(vla-delete x))
)
)

--


-Jason

Member of the Autodesk Discussion Forum Moderator Program

"amy" wrote in message
news:805E3C4A43B8C191FCBCA21F5506DD01@in.WebX.maYIadrTaRb...
> hi:
> I would like to delete ALL the paper space layout tabs except ModelSpace.
> What Lisp or vlisp function can do this?
>
> thanks
>
>
Valued Contributor
structuralsteel
Posts: 85
Registered: ‎12-05-2003
Message 5 of 16 (1,246 Views)

Re:

12-12-2002 05:14 AM in reply to: *amy
Click on the first tab, then hold down the shift key and click on the last tab. This will highlight them all. Now right-click and choose the Delete option. You'll get a message to make sure you know what you'll be doing. Click ok or cancel.
*amy
Message 6 of 16 (1,246 Views)

Re:

12-12-2002 05:18 AM in reply to: *amy
Cliff:
thank you!
Am I missing something?

(defun c:dl ()
(vl-load-com)
(setq acadobj (vlax-get-acad-object))
(setq doc (vla-get-activedocument acadobj))
(setq layouts (vla-get-Layouts doc))
(setq lauoutCnt (vla-get-Count layouts))
(repeat lauoutCnt
(vla-delete layouts)
)

I am getting an error: Automation Error. Cannot be erased by caller









"Cliff Middleton" wrote in message
news:BFC900D71A72A9F85F7C03B17283F49B@in.WebX.maYIadrTaRb...
> (vla-delete )
>
> "amy" wrote in message
> news:805E3C4A43B8C191FCBCA21F5506DD01@in.WebX.maYIadrTaRb...
> > hi:
> > I would like to delete ALL the paper space layout tabs except
ModelSpace.
> > What Lisp or vlisp function can do this?
> >
> > thanks
> >
> >
>
>
*Oquendo, Frank
Message 7 of 16 (1,246 Views)

Re:

12-12-2002 05:24 AM in reply to: *amy
amy had this to say
:
> Am I missing something?

In fact, you're not missing anything and that's the problem. The code
you posted will attempt to delete the model tab and that is not allowed.

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
*Piercey, Jason
Message 8 of 16 (1,246 Views)

Re:

12-12-2002 05:42 AM in reply to: *amy
How about the fact that she is attempting to delete the layout collection,
rather than a layout object?

--


-Jason

Member of the Autodesk Discussion Forum Moderator Program

"Frank Oquendo" wrote in message
news:09CD065D8A6985F643815A60B1F6AEF1@in.WebX.maYIadrTaRb...

> In fact, you're not missing anything and that's the problem. The code
> you posted will attempt to delete the model tab and that is not allowed.
*Oquendo, Frank
Message 9 of 16 (1,246 Views)

Re:

12-12-2002 05:42 AM in reply to: *amy
Jason Piercey had this to say
:
> How about the fact that she is attempting to delete the layout
> collection, rather than a layout object?

That's another possibility. :smileywink:

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
*Middleton, Cliff
Message 10 of 16 (1,246 Views)

Re:

12-12-2002 06:17 AM in reply to: *amy
The layouts variable is a collection of all the layout objects so you must
go through them one by one. The vlax-for function is designed to do that
(works like foreach). Borrowing from Jason's code...

(vlax-for layout Layouts
(if (/= "Model" (vla-get-name x))
(vla-delete x))
)
)

I didn't test the code so some tweaking may be required. Or, Frank's will
work just as well. Jason's requires you to supply the list (or rather a
string) of layout names you want deleted. BTW Jason, your Tmp variable will
never equal "Model" since it is always all upper-case.
--
Cliff


"amy" wrote in message
news:FC4ED07CF045163A07585F5DA1698258@in.WebX.maYIadrTaRb...
> Cliff:
> thank you!
> Am I missing something?
>
> (defun c:dl ()
> (vl-load-com)
> (setq acadobj (vlax-get-acad-object))
> (setq doc (vla-get-activedocument acadobj))
> (setq layouts (vla-get-Layouts doc))
> (setq lauoutCnt (vla-get-Count layouts))
> (repeat lauoutCnt
> (vla-delete layouts)
> )
>
> I am getting an error: Automation Error. Cannot be erased by caller
>
>
>
>
>
>
>
>
>
> "Cliff Middleton" wrote in message
> news:BFC900D71A72A9F85F7C03B17283F49B@in.WebX.maYIadrTaRb...
> > (vla-delete )
> >
> > "amy" wrote in message
> > news:805E3C4A43B8C191FCBCA21F5506DD01@in.WebX.maYIadrTaRb...
> > > hi:
> > > I would like to delete ALL the paper space layout tabs except
> ModelSpace.
> > > What Lisp or vlisp function can do this?
> > >
> > > thanks
> > >
> > >
> >
> >
>
>
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.