Jump to content

creating layout tabs using lisp


nopasaran

Recommended Posts

Hello! I am looking for a lisp, that could help me with creating layout tabs.

 

First of all I explain what situation I have. I have several similar drawings in model tab that I want to export to layouts (every drawing has it's own layout). Drawings differ only in length, so layouts have to have different length (in plot size) and height is constant.

 

What I would like to do is have a lisp that colud create layout tabs using different plot size (it would be great if I could choose one) for every tab.

 

Please feel free to contact me here or directly with any questions or comments.

 

Any help or guidance will be appreciated. Thanks in advance.

 

PS. English isn't my native language so I'm sorry for mistakes.

Link to comment
Share on other sites

You can create a new layout using the vla-add method:

 

(defun NewLay (lay)
 (vl-load-com)
 
 (setq *adoc* (cond (*adoc*) ((vla-get-ActiveDocument
                                (vlax-get-acad-object)))))

 (if (vl-catch-all-error-p
       (setq lay (vl-catch-all-apply (function vla-add)
                   (list (vla-get-layouts *adoc*) lay))))
   
   (vl-catch-all-error-message lay) lay))

 

PS> Welcome to CADTutor :)

Link to comment
Share on other sites

This will deep clone a selection of objects to a new Layout:

 

;; lay = New Layout Name  (Will be Created if non-existent)

(defun CopytoLayout (lay / ss NewLay ObjLst)
 (vl-load-com)
 ; Lee Mac  ~  27.01.10

 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *adoc* (cond (*adoc*) ((vla-get-ActiveDocument *acad*))))

 (cond (  (not (snvalid lay)))

       (  (ssget)

          (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *adoc*))
            (setq ObjLst (cons Obj ObjLst)))         
          (vla-delete ss)

          (if (vl-catch-all-error-p
                (setq NewLay (vl-catch-all-apply
                               (function vla-item)
                                 (list (vla-get-Layouts *adoc*) lay))))
            
            (setq NewLay (vla-Add (vla-get-Layouts *adoc*) lay)))

          (vla-CopyObjects *adoc*
            
            (vlax-make-variant
              (vlax-safearray-fill
                (vlax-make-safearray vlax-vbObject
                  (cons 0 (1- (length ObjLst))))
                
                (reverse ObjLst)))
            
            (vla-get-Block NewLay)))))

  • Thanks 1
Link to comment
Share on other sites

Thanks for your fast reply.

to: LeeMac

I haven't managed to try your solution, because I'm not very good at lisp yet so i will try to look it later but Thank you for your help!

to: mdbdesign

Tried this programm...It is very good and I find it very useful in further work...but at the moment I am looking for a solution that could enable me to choose the plot size of each specific tab in one window. For example in this programm that you offered could be a control (for example Modify) that allows to change plot size like you do it in Page setup manager.

 

I am not sure if it is possible...but if it is I would be very grateful if you could recomend me any solution.

 

Thanks a lot for your reply.

 

PS. I am a newguy in lisp programming and I have very few knowledge so could you add some explonation how it shoud be used to work correctly.

Link to comment
Share on other sites

Hi,

 

You can set the Plot size for a new layout, but you would need to use DCL (or a derivative of such), to be able to select an option from a window.

 

To use the code that I posted above, you could run it in the Visual LISP Editor in AutoCAD (VLIDE at command-line), or you could just run it from the command-line directly.

 

It takes one argument, the layout name, hence:

 

(CopytoLayout "New Layout)

 

Lee

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