Jump to content

deleting a layout tab by name


BIGAL

Recommended Posts

I have no problems acessing the layout tabs just need help deleting a particular layout tab by its name.

 

(vlax-for lay (vla-get-Layouts doc)
 (setq plotabs (cons (vla-get-name lay) plotabs))
)
(setq plottablist (acad_strlsort plotabs))
(setq len (length plottablist))
(setq x 0)
(repeat len
 (setq name (nth x plottablist))
 (if (= name "layout to be deleted") 
delete tab ?

Link to comment
Share on other sites

(defun DelLay (name )
      (foreach nm (layoutlist)
             (if (eq nm name)
              (vla-delete
                    (vla-item
                          (vla-get-layouts
                                (vla-get-ActiveDocument
                                      (vlax-get-acad-object)))
                          nm))
                 )
             )
     (princ)
     )

Link to comment
Share on other sites

Another, supply with Document Object:

 

(defun DeleteLayout ( doc name / item )
   (if
       (not
           (vl-catch-all-error-p
               (setq item
                   (vl-catch-all-apply 'vla-item (list (vla-get-layouts doc) name))
               )
           )
       )
       (not (vla-delete item))
   )
)

 

e.g.:

 

(DeleteLayout (vla-get-activedocument (vlax-get-acad-object)) "Layout1")

 

Returns T if Layout is deleted, otherwise nil if Layout is not found.

  • Like 1
Link to comment
Share on other sites

The code is fine we have a Plotting for Dummy's system here just makes it easier not to have to delete any unwanted plotted layouts. The rest is written in VL so doc is already called. will paste in prior to creating plot list.

Link to comment
Share on other sites

The code is fine we have a Plotting for Dummy's system here just makes it easier not to have to delete any unwanted plotted layouts. The rest is written in VL so doc is already called. will paste in prior to creating plot list.

 

Deos you PfD generate a random layout names?

Link to comment
Share on other sites

No Layout is always a fixed name thanks Pbe for asking trying out my Television at moment for screen but unfortunately still need glasses to see keyboard. Wish I had learnt to rouuchh ype prroperrly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...