Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete layout Tab?

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
8693 Views, 15 Replies

Delete layout Tab?

hi:
I would like to delete ALL the paper space layout tabs except ModelSpace.
What Lisp or vlisp function can do this?

thanks
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

(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
>
>
Message 3 of 16
Anonymous
in reply to: Anonymous

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
Message 4 of 16
Anonymous
in reply to: Anonymous

;; 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
>
>
Message 5 of 16
structuralsteel
in reply to: Anonymous

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.
Message 6 of 16
Anonymous
in reply to: Anonymous

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
> >
> >
>
>
Message 7 of 16
Anonymous
in reply to: Anonymous

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
Message 8 of 16
Anonymous
in reply to: Anonymous

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.
Message 9 of 16
Anonymous
in reply to: Anonymous

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. 😉

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
Message 10 of 16
Anonymous
in reply to: Anonymous

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
> > >
> > >
> >
> >
>
>
Message 11 of 16
Anonymous
in reply to: Anonymous

> BTW Jason, your Tmp variable will
> never equal "Model" since it is always all upper-case.

Indeed, thanks Cliff.


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

Be sure and change the "x"'s to "layout" also, or layout back to an "x"


--


-Jason

Member of the Autodesk Discussion Forum Moderator Program
Message 12 of 16
Anonymous
in reply to: Anonymous

> Be sure and change the "x"'s to "layout" also, or layout back to an "x"
>

See, didn't I warn her? Thanks, Jason.
--
Cliff
Message 13 of 16
Anonymous
in reply to: Anonymous

I saw the warning 🙂 , just thought I'd point it out anyway.

--


-Jason

Member of the Autodesk Discussion Forum Moderator Program

"Cliff Middleton" wrote in message
news:77087BBCDA75411D505452F4213CD43A@in.WebX.maYIadrTaRb...
> > Be sure and change the "x"'s to "layout" also, or layout back to an "x"
> >
>
> See, didn't I warn her? Thanks, Jason.
> --
> Cliff
>
>
Message 14 of 16
Anonymous
in reply to: Anonymous

Thak you to all of your reply!

Merry X'mas

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
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.
Message 15 of 16
Anonymous
in reply to: Anonymous

-- I don't think that matters.. Model cannot be deleted... or am I wrong?

"Jason Piercey" wrote in message
news:F91542C8AC148C376E6E740D778A4060@in.WebX.maYIadrTaRb...
> > BTW Jason, your Tmp variable will
> > never equal "Model" since it is always all upper-case.
>
> Indeed, thanks Cliff.
>
>
Message 16 of 16
Anonymous
in reply to: Anonymous

That is correct, however the code will puke unless you exclude the model tab
or trap the error.

--


-Jason

Member of the Autodesk Discussion Forum Moderator Program

> -- I don't think that matters.. Model cannot be deleted... or am I wrong?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost