LAYOUTSTODWGS - Modification?

LAYOUTSTODWGS - Modification?

vaughan.giles7AGEV
Advocate Advocate
514 Views
11 Replies
Message 1 of 12

LAYOUTSTODWGS - Modification?

vaughan.giles7AGEV
Advocate
Advocate

Hi everyone,

 

I am not well-versed in LISP programming and would like what would hopefully be a simple modification made to this LISP routine please!

 

https://jtbworld.com/autocad-export-layouts-to-drawings-layoutstodwgs-lsp 

^
Basically, I'd like to remove the window-popup during the command process, so that it is fully automated once run.

 

I imagine it's more complicated than simply removing this part of the code:

vaughangiles7AGEV_0-1748555312945.png

 

Could I please get some help?!

Thank you!

0 Likes
515 Views
11 Replies
Replies (11)
Message 2 of 12

paullimapa
Mentor
Mentor

If you're referring to the fact that at the end of the command it opens the TEXT window to display the results:

paullimapa_1-1748558614386.png

Then just put a comma in front of this line of code towards the end of the file so it won't be executed:

paullimapa_2-1748558680368.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 12

vaughan.giles7AGEV
Advocate
Advocate

Hi Paul,

No not the command window that appears at the end, rather I'm referring to the pop-up that asks "Include AutoCAD Map information in the export?" and you are forced to say "yes or no".
It's a problem when you have ~20-50 sheets and have to click it for each Layout!

0 Likes
Message 4 of 12

paullimapa
Mentor
Mentor

I believe that's driven by the content of the dwg. If that information is in there it will prompt for confirmation.

Instead of the WBLOCK method, try my revised SAVEAS method attached.

Also as stated on the website by Jimmy Bergmark:

"Below code is not the latest. The latest is on the Autodesk App Store." 

Autodesk App Store does have the version that offers the option to use SAVEAS:

JTB LayoutsToDwgs | AutoCAD | Autodesk App Store

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 12

pendean
Community Legend
Community Legend

@JTBWorld might be the best person to engage with to help you customize their tools to suit your exact needs @vaughan.giles7AGEV 

0 Likes
Message 6 of 12

JTBWorld
Advisor
Advisor

This dialog box should not show. 

Did you try the latest app from the Autodesk App Store?

What version and variant of AutoCAD do you have? 


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 7 of 12

david.waight
Contributor
Contributor

Slightly off topic, but it would be great to be able to have a command similar to EXPORTLAYOUT and save as a DXF, rather than just as a DWG.

 

This would then just give you a file that doesn't have all the other entities that are in the Model tab, but has all the title block information pertinent to this particular part of the overall drawing that the recipient needs.

 

It would be especially useful to send to clients or suppliers who don't have AutoCAD, but work with DXF files.

0 Likes
Message 8 of 12

paullimapa
Mentor
Mentor

Attached is another modification of Jimmy Bergmark's original LayoutsToDwgs.lsp but now renamed and modified to saveas to dxf as LayoutsToDxfs.lsp


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 12

david.waight
Contributor
Contributor

@paullimapa, thanks very much for your efforts, I wasn't actually expecting you to do anything 🙂

 

As I said, it was slightly off-topic because what I was trying to explain (obviously quite badly) was a routine that worked more like EXPORTLAYOUT, but the result is a DXF as opposed to a DWG.

 

Jimmy Bergmark's routine means you still end up with all the Model space information and a layout, which wasn't my intention.

 

What I was alluding to was a DXF file as you get when using DXFOUT (so you can choose the version etc.) that gives you all the contents of the layout, so your title block border and information, as well as the drawing entities within the Viewport itself.

 

Please don't do anything, as this is a requirement that is probably quite specific to my industry, as my drawings are always 1:1, as they will be used for making tools in a CNC and laser cutting environment.

 

I appreciate that this probably seems a strange way to do it, but I was just thinking it was a way to transfer all the pertinent information from a Layout and the drawing itself, just like you would when printing or creating a PDF, but you can actually use the DXF.

 

Once again, thank you, Paul, for your kind assistance.

0 Likes
Message 10 of 12

paullimapa
Mentor
Mentor

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 12

ronjonp
Mentor
Mentor

@david.waight 

 

Here's something I put together about 10 years ago! It will remove all modelspace objects prior to export if there are not paperspace viewports within the tab. Hope this helps.

(defun c:layoutstodwgs (/ *error* _unlocklayers	_undobegin _undoend parsestring	_dir dir doc layouts
			msg pre	suf vars x
		       )
  (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)))
  (defun _unlocklayers nil
    (vlax-for x	(vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
      (if (eq (vla-get-lock x) :vlax-true)
	(vla-put-lock x :vlax-false)
      )
    )
  )
  (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")
  (_unlocklayers)
  (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)
)
0 Likes
Message 12 of 12

david.waight
Contributor
Contributor

Thanks for this ronjonp, I appreciate you posting this routine.

 

Unfortunately, it still works the same as the JTB routine.

 

I imagined it working more like the EXPORTLAYOUT command, but saved as a DXF file.

 

Attached is what I want to end up with (basically a version 11/12 DXF file), so it can be opened by other programs other than AutoCad, that can't read DWG, but can read DXF files.

 

Hopefully, this makes sense.

 

But please don't worry about doing anything, it was just the initial post that got me thinking about something that could be useful to me in the future.

0 Likes