Shrubs71 Posted August 24, 2011 Share Posted August 24, 2011 I have a large AutoCAD 2010 3D model .DWG (solids) which I need to export to .SAT for import to Finite Element Ananysis software. I would like to automate the process to permit export of each layer in the .dwg to an individual .SAT, with a name matching the source layer. I have seen a similar query, exporting to WBLOCK.dwg, and excellent response at http://www.cadtutor.net/forum/showthread.php?10359-save-each-layer-in-a-separate-file/page2 Unfortunately I have no programming knowledge and my attempts to edit the code provided at this link to suit my needs have failed miserably. I am currently going through this laborious process (450 layers) by isolating each layer and using the _EXPORT command. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 24, 2011 Share Posted August 24, 2011 Hi Shrubs, Below is a modification to my 'Layers2Drawings' program found here, to export to .sat files. ;;--------------------=={ Layers 2 SAT }==--------------------;; ;; ;; ;; Exports all active layers to separate SAT files, saved to ;; ;; working directory ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; (defun c:Lay2SAT ( / *error* _UniqueFilename _UniqueItem acdoc acsel fseed name ) (defun *error* ( msg ) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (defun _UniqueFileName ( seed extn / i file ) (setq i 1) (if (findfile (strcat (setq file seed) extn)) (while (findfile (strcat (setq file (strcat seed "(" (itoa (setq i (1+ i))) ")")) extn))) ) file ) (defun _UniqueItem ( collection seed / i ) (setq i 1) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list collection (strcat seed (itoa (setq i (1+ i))))) ) ) ) ) (strcat seed (itoa i)) ) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)) fseed (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))) acsel (vla-get-selectionsets acdoc) acsel (vla-add acsel (_UniqueItem acsel "lay2sat")) ) (vlax-for layer (vla-get-layers acdoc) (if (not (wcmatch (setq name (vla-get-name layer)) "*|*")) (progn (vla-select acsel acselectionsetall nil nil (LM:SafearrayVariant vlax-vbinteger '() (LM:SafearrayVariant vlax-vbvariant (list name)) ) (if (not (zerop (vla-get-count acsel))) (vla-export acdoc (_UniqueFilename (strcat fseed "_" name) ".sat") "sat" acsel) ) (vla-clear acsel) ) ) ) (vla-delete acsel) (princ) ) ;;------------------=={ Safearray Variant }==-----------------;; ;; ;; ;; Creates a populated Safearray Variant of a specified ;; ;; data type ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; datatype - variant type enum (eg vlax-vbDouble) ;; ;; data - list of static type data ;; ;;------------------------------------------------------------;; ;; Returns: VLA Variant Object of type specified ;; ;;------------------------------------------------------------;; (defun LM:SafearrayVariant ( datatype data ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray datatype (cons 0 (1- (length data)))) data ) ) ) (vl-load-com) (princ) Hope this helps! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 24, 2011 Share Posted August 24, 2011 Welcome to CADTutor! I am unfamiliar with exporting to .SAT file, but from what I could dig up quickly, this code 'framework' might get you started: (defun c:FOO () (vl-load-com) ((lambda (acDoc path / layerName ss) (vlax-for x (vla-get-layers acDoc) (if (and (= :vlax-false (vla-get-lock x)) (setq layerName (vla-get-name x)) (setq ss (ssget "_x" (list '(0 . "BODY,REGION,SOLID") (cons 8 layerName))))) (progn (command "._acisout" ss "" pause))))) (vla-get-activedocument (vlax-get-acad-object)) (getvar 'dwgprefix)) (princ)) Please note that I simply tried drawing a simple SOLID entity, and get the following message: No solids, regions or ShapeManager bodies selected. I'd be happy to test a bit more, but I'd require a sample drawing that you know will successfully export to .SAT file. Hope this helps! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 24, 2011 Share Posted August 24, 2011 ^^ Scratch that, I just saw Lee's post. Quote Link to comment Share on other sites More sharing options...
Shrubs71 Posted August 24, 2011 Author Share Posted August 24, 2011 Thank you both. I am both amazed and impressed at the speed of your responses to my query. I will give this a go and get back to you. Quote Link to comment Share on other sites More sharing options...
Shrubs71 Posted August 29, 2011 Author Share Posted August 29, 2011 Just to let you know, I successfully exported all 450 Layers to .sat in a matter of minutes, using your routine Lee Mac, and imported my model to my FEA package. Thanks again for your help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 29, 2011 Share Posted August 29, 2011 You're welcome Shrubs, happy that I could save you some time (& money!) Quote Link to comment Share on other sites More sharing options...
CarlosM Posted October 9, 2019 Share Posted October 9, 2019 Hi Lee Mac, I found this post and I believe it's kinda the holy grail for some AutoCAD Civil 3D to Revit Workflows. I tried running the lisp Routine above in Civil3D 2018 and keep becomming the following message: "Falsch formatierte Liste in Eingabe" ("Bad Elements in Arguments List"). I'm using the German Version of the Programm, may be it has something to do with how lists are defined (comma or semicolon). I took a look at the code but I can't find nothing faulty about it. Even this post is almost 8 years old, I still find it very useful. Hopefully you can help me. Best Regards, CarlosM. Quote Link to comment Share on other sites More sharing options...
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.