bradb Posted June 28, 2012 Posted June 28, 2012 Trying to get this lisp to save a dxf to a specific folder ex. C:\My Documents\DXF\. I tryed putting that in the code but I'm not writing it right or something. Could someone point me in the right direction. (defun c:dxf () (vl-load-com) (vlax-for LAYOUT (vla-get-layouts(vla-get-activedocument(vlax-get-acad-object))) (vl-catch-all-apply 'vla-delete (list LAYOUT)) ) (command "CHANGE" "ALL" "" "P" "LA" "0" "") (command "-PURGE" "ALL" "" "N") (nowdxf) ) (defun nowdxf () (command "saveas" "dxf" "") ) Quote
David Bethel Posted June 28, 2012 Posted June 28, 2012 I'd look into the DXFOUT command in lieu of saveas Also you will need \\ or use / for directory locations in lieu of the single \ -David Quote
bradb Posted June 29, 2012 Author Posted June 29, 2012 Tryed this. Its still not working. By usings just the saveas or dxfout, it works but I want to force it to this folder with out have to select it. (defun c:dxf () (vl-load-com) (vlax-for LAYOUT (vla-get-layouts(vla-get-activedocument(vlax-get-acad-object))) (vl-catch-all-apply 'vla-delete (list LAYOUT)) ) (setvar "CLAYER" "0") (command "change" "all" "" "p" "la" "0" "") (command "-purge" "all" "" "n") (nowdxf) ) (defun nowdxf (/ dxfname) (setq dxfname (getstring "n\DXF Name: ")) (command "_SAVEAS" "DXF" "" (strcat "C:\\Users\\My Documents\\DXF\\" DXFNAME)) (princ) ) Quote
BlackBox Posted June 29, 2012 Posted June 29, 2012 If you're trying to avoid the SaveAs dialog, then consider this example: (defun c:FOO ( / fileName) (vl-load-com) (if (setq fileName (getstring T "\nEnter a file name: ")) (vla-saveas (vla-get-activedocument (vlax-get-acad-object)) (strcat "C:\\Users\\My Documents\\DXF\\" fileName ".dxf") ac2010_dxf) ) (princ) ) Quote
BlackBox Posted June 29, 2012 Posted June 29, 2012 Oh - Almost forgot... For reference: ActiveX SaveAs Method Quote
bradb Posted June 29, 2012 Author Posted June 29, 2012 How different would this code look if dxfout were used instead of saveas. Just curious Quote
BlackBox Posted June 29, 2012 Posted June 29, 2012 Pseudo code: (defun c:FOO () (vl-load-com) (vlax-for oLayout (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (vl-catch-all-apply 'vla-delete (list oLayout))) (setvar 'clayer "0") (command "._change" "all" "" "properties" "layer" "0" "") (command "._-purge" "all" "" "no") (command "._dxfout" (vl-string-subst ".dxf" ".dwg" (strcat (getvar 'dwgprefix) (getvar 'dwgname))) 16) (princ)) Quote
bradb Posted June 29, 2012 Author Posted June 29, 2012 Cool. Still trying to learn this visiual lisp. Thanks Quote
BlackBox Posted June 29, 2012 Posted June 29, 2012 Cool. Still trying to learn this visiual lisp. Thanks No worries; we all start somewhere... Here's a thread where I learned one of my first lessons from Mr. Bell himself (he like most of 'us' geeks have an appreciation for SW humor). Quote
Lee Mac Posted June 29, 2012 Posted June 29, 2012 (edited) For those who prefer Visual LISP... (defun LM:dxfout ( doc fname / err sel ) (setq err (vl-catch-all-apply 'vla-export (list doc (strcat (vl-filename-directory (vl-string-translate "/" "\\" fname)) "\\" (vl-filename-base fname) ) "dxf" (setq sel (vla-add (vla-get-selectionsets doc) (rtos (getvar 'date) 2 8))) ) ) ) (vla-delete sel) (if (vl-catch-all-error-p err) (prompt (vl-catch-all-error-message err)) t ) ) (vl-load-com) (princ) (LM:dxfout (vla-get-activedocument (vlax-get-acad-object)) <DXF Filename>) Edited March 30, 2023 by Lee Mac Quote
BlackBox Posted June 29, 2012 Posted June 29, 2012 For those who prefer Visual LISP... This is _so_ me (one who prefers vla- code). Separately, and also interesting is the fact that the DXF extension is conveniently missing from the (albeit non-Autodesk) online ActiveX Developer Documentation: Export Method I'm also surprised that the extension is a string, rather than an ac####_dxf Enum, as is the case with the SaveAs Method. Nice find, thanks Lee. Quote
Lee Mac Posted June 29, 2012 Posted June 29, 2012 I'm guessing the .dsf should be .dxf (since also 's' is close to 'x' on a qwerty), but yes, one must read between the lines with the ActiveX Documentation... You're welcome Renderman Quote
vanowm Posted March 30, 2023 Posted March 30, 2023 On 6/29/2012 at 3:45 PM, Lee Mac said: For those who prefer Visual LISP... (defun LM:dxfout ( doc fname / err sel ) (setq err (vl-catch-all-apply 'vla-export (list doc (strcat (vl-filename-directory (vl-string-translate "/" "\\" fname)) "\\" (vl-filename-base fname) ) "dxf" (setq sel (vla-add (vla-get-selectionsets doc) (rtos (getvar 'date) 2 )) ) ) ) (vla-delete sel) (if (vl-catch-all-error-p err) (prompt (vl-catch-all-error-message err)) t ) ) (vl-load-com) (princ) (LM:dxfout (vla-get-activedocument (vlax-get-acad-object)) <DXF Filename>) There is a missing closing parentesis: (setq sel (vla-add (vla-get-selectionsets doc) (rtos (getvar 'date) 2 ))) How do I export only selection if anything is selected or entire document if nothing is selected? Quote
Lee Mac Posted March 30, 2023 Posted March 30, 2023 7 hours ago, vanowm said: There is a missing closing parentesis: (setq sel (vla-add (vla-get-selectionsets doc) (rtos (getvar 'date) 2 ))) This caused by the change to the forum software which removed all instances of "8)" from code... I've now updated my earlier post. 1 Quote
vanowm Posted March 31, 2023 Posted March 31, 2023 So is there a way export only selected entites? Quote
Lee Mac Posted March 31, 2023 Posted March 31, 2023 12 hours ago, vanowm said: So is there a way export only selected entites? Yes, but not using the ActiveX Export method - per the documentation: Quote When exporting to EPS or DXF formats, the selection set is ignored and the entire drawing is exported. Instead, you'll need to use the DXFOUT command with the Objects option. Quote
mhupp Posted March 31, 2023 Posted March 31, 2023 Working with selection sets I think you could do. (setvar 'saveformat #) ;verson of your dxf you want o save Wblock command feed selection set. rest saveformat to default settings. Quote
Recommended Posts
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.