Jump to content

Recommended Posts

Posted

Hi everyone
hope you're doing well
I am looking for a lisp that can export the layouts of several separate files and put them in a new file in the model.
could you help me with that please?
 

Posted

Welcome to the forum :) .. give this a whirl.

(defun c:layoutstodwgs
       (/ *error* _undobegin _undoend parsestring _dir dir doc layouts msg pre suf vars x)
  ;; RJP » 2016-02-15
  (defun *error* (msg)
    ;; Reset variables on error
    (mapcar '(lambda (x) (setvar (car x) (cdr x))) vars)
    (if	(not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
      (princ (strcat "\nError: " msg))
    )
    (princ)
  )
  (defun _undobegin (doc) (_undoend doc) (vla-startundomark doc))
  (defun _undoend (doc) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc)))
  (setq	layouts	(vla-get-layouts (setq doc (vla-get-activedocument (vlax-get-acad-object))))
	pre	(getstring "\nEnter filename PREfix: ")
	suf	(getstring "\nEnter filename SUFfix: ")
	dir	(getvar 'dwgprefix)
	msg	""
	vars	(mapcar '(lambda (x) (cons x (getvar x))) '("filedia" "expert" "tilemode" "cmdecho"))
  )
  (mapcar '(lambda (a b) (setvar (car a) b)) vars '(0 5 1 0))
  (command "_ucs" "_w")
  (foreach l (layoutlist)
    (setvar 'ctab l)
    (if	(> (sslength (ssget "_X" (list (cons 410 l)))) 1)
      (progn (_undobegin doc)
	     ;; Check if there are viewports .. if not delete modelspace objects to keep file size down
	     (if (= 1 (sslength (ssget "_x" (list (cons 0 "VIEWPORT") (cons 410 l)))))
	       (progn (mapcar 'entdel (mapcar 'cadr (ssnamex (ssget "_x" '((410 . "Model"))))))
		      (setq msg (strcat l " has 0 viewports. Modelspace items removed..." "\n" msg))
	       )
	     )
	     ;; Remove all layout tabs except current
	     (vlax-for x layouts
	       (if (/= (getvar 'ctab) (vla-get-name x))
		 (vl-catch-all-apply 'vla-delete (list x))
	       )
	     )
	     ;; Wblock current layout
	     (command "_-wblock" (strcat dir pre l suf) "*")
	     (setq msg (strcat dir pre l suf ".dwg created.\n" msg))
	     ;; Undo end
	     (_undoend doc)
	     ;; Undo all the tabs deleted
	     (command "_u")
      )
      (setq msg (strcat l " has nothing on it and skipped." "\n" msg))
    )
  )
  (mapcar '(lambda (x) (setvar (car x) (cdr x))) vars)
  (princ msg)
  (princ)
)

 

  • Like 1
Posted (edited)

thank you very much for helping me
Actually, I have a file with several layouts and I want to output them all in one single new file in modelspace.(with their sheets)
And because there are many layouts, I don't want to export to model every single one of them.
Thanks for helping

Edited by Haniye

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