Jump to content

Batch convert ACIS (.sat) to .dwg


SLW210

Recommended Posts

This is what I have to generate a script file to process a folder. You will have to rewrite the script part tho.

 

;;----------------------------------------------------------------------------;;
;; Generate a Script file for drawings in a folder
(defun C:Gen-Script (/ Path UserFile BlkLst F1 FileName)
  (setq UserFile (getfiled "Choose a Folder to Process" (getvar 'DWGPREFIX) "*" 16)
        Path (vl-filename-directory UserFile)
        BlkLst (vl-directory-files Path "*.sat" 1) ;change extention to find dwg or dxf
        BlkLst (vl-remove (getvar 'DWGNAME) blkLst) ;if Active Drawing is in the same folder remove
        BlkLst (vl-sort blkLst '<)
        F (open (strcat (getenv "userprofile") "\\Documents\\Script.scr") "w") ;Save script in My Documents
  )
  (if BlkLst
    (progn
      (foreach FileName BlkLst
        (write-line (strcat "_.Import \"" Path "\\" FileName "\"") F) ;; maybe idk
        ;.... other stuff
        (write-line "_.qsave" F)
      )
    )
    (prompt "\nNo Files Found in Folder")
  )
  (close F)
  (prompt (strcat "\nScript File for " (itoa (length BlkLst)) " Files Created"))
  (if (= (ACET-UI-MESSAGE "Do you Want to run the Script Now?" "User Input" (+ Acet:YESNO Acet:ICONWARNING)) 6) ;Yes
    (vl-cmdf "_.Script" (strcat (getenv "userprofile") "\\Documents\\Script.scr"))
  )
  (princ)
)

 

Edited by mhupp
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Had trouble getting the message working, had to change it to this format:

 

(ACET-UI-MESSAGE "\nDo you want to Run Script Now?" "Title" 52)

 

 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks mhupp! I got on command line  (error: no function definition: CHECKI) then commented out the (CHECK) and it worked. That LISP is a great start!

 

I'll look at your bit later Steven P,  I get the Script.scr, but at the end no message working and on the command line (Usage: (acet-ui-message <text> [<caption> [<type>]])
; error: ADS request error). So looks like what you posted is correct.

 

Not sure when I'll get back to this, hopefully today.

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

The LISP is working very well.

 

I can't seem to get a script to run past creating the first .dwg, even not using the LISP.

 

Pretty much tried a lot of ways, maybe I need to run a separate batch routine ( I have a VBA one that might be modified) to individually open drawings and run the script.

 

;;; This seems to work fine manually to create a .dwg and import a .sat I have tried several ways to Aarrange the script, even every line on a new row.

		;;;ACIS (.sat) to .dwg Script;;;																						
;;;Open DWG		Kill Dialog Box							ACIS File to Convert			ZOOM EXTENTS				SAVEAS;;;								

FileDia 0
QNEW 
FileDia 0 ACISIN "H:\Blocks\3D Blocks\SAT  Files\.5 FLAT WASHER FOR SOFT MATERIALS.SAT" ZOOM EXTENTS SAVEAS 2018 "H:\Blocks\3D Blocks\SAT-DWG\.5 FLAT WASHER FOR SOFT MATERIALS.SAT"
Close
QNEW 
FileDia 0 ACISIN "H:\Blocks\3D Blocks\SAT  Files\.5 Flat Washer SAE.SAT" ZOOM EXTENTS SAVEAS 2018 "H:\Blocks\3D Blocks\SAT-DWG\.5 Flat Washer SAE.SAT"
Close

 

 

Here is my latest version of the LISP. I put separate lines hoping to get hard enters.

 

;;;*********************************************************************************************************************************;;;
;;; Generate a Script file for drawings in a folder mhupp-https://www.cadtutor.net/forum/topic/78123-batch-convert-acis-sat-to-dwg/
;;; Adapted to create a script to create seperate drawings from ACIS (.sat) files by SLW210.
;;; Original Modification-08/15/2023
;;;*********************************************************************************************************************************;;;

(defun C:Gen-Script-ACISIN (/ Path UserFile BlkLst F1 FileName)
  (setq	UserFile (getfiled "Choose a Folder to Process"
			   (getvar 'DWGPREFIX)
			   "*"
			   16
		 )
	Path	 (vl-filename-directory UserFile)
	BlkLst	 (vl-directory-files Path "*.sat" 1)
					;change extention to find dwg or dxf
	BlkLst	 (vl-remove (getvar 'DWGNAME) blkLst)
					;if Active Drawing is in the same folder remove
	BlkLst	 (vl-sort blkLst '<)
	F	 (open (strcat (getenv "userprofile") "\\Documents\\ACISIN.scr")
		       "w"
		 )			;Save script
  )
  (if BlkLst
    (progn
      (foreach FileName	BlkLst
        
        
   ;;;////////***Start adding lines and commands for the script here***\\\\\\\\;;;

	(write-line "Filedia" F)
         (write-line "0" F)                                               ;FileDia = 0        
	 (write-line "qnew" F)                                            ;Open new drawing
	(write-line "Filedia" F)
         (write-line "0" F)                                               ;FileDia = 0
	(write-line (strcat "_.ACISIN \"" Path "\\" FileName "\"")F)      ;Import .sat (ACIS) files
         (write-line "Zoom" F)
        (write-line "Extents" F)                                          ;Zoom Extents
	 (write-line (strcat "_.saveas "" \"" Path "\\" FileName "\"") F) ;SaveAs with same folder and name.dwg
	(write-line "Close" F)				                  ;Close the drawing	
      )
    )
    (prompt "\nNo Files Found in Folder")
  )
  (close F)
  (prompt (strcat "\nScript File for "
		  (itoa (length BlkLst))     ;write the script
		  " Files Created"
	  )
  )
  (if (= (ACET-UI-MESSAGE
	   "Do you Want to run the Script Now?"
	   "User Input"
	   (+ Acet:YESNO Acet:ICONWARNING))6)					;Yes
    (vl-cmdf "_.Script"
	     (strcat (getenv "userprofile") "\\Documents\\ACISIN.scr")
    )
  )
  (princ)
)

 

I must be doing something wrong, I get on the commandline  for drawing I start the script in...

 

Command: Filedia

Enter new value for FILEDIA <1>: 0

Command: qnew

Command: Regenerating model.

Command:

 

The commandline for the newly opened drawing...

 

Command:
Command:

Command:
Command: 0
Unknown command "0".  Press F1 for help.

Command: Regenerating model.

Command:

 

  • Like 1
Link to comment
Share on other sites

I found an old Dgn to Dwg LISP and modified it a little. Still needs some work, but the output folder issue was in the original. I'll fix that when I have time.

 

All credit goes to the originators. I am considering making a DCL version if the need arises or continue with a VBA and or .NET version. I need the practice.

 

From what I can tell, no one has an ACISIN script file working in batch, looks like the FILEDIA is the issue ? I might head back down that road just to solve it.

 

I would like to thank everyone for their help.

 

;;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;;;                                                                                                                       |
;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Modified to Import ACIS (.sat) to AutoCAD (.dwg)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|
;;;                                                                                                                       |
;;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;;;
;;;  Original versions I got from here 
;;;  https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-convert-dgn-to-dwg/td-p/3237978
;;;
;;;* DGNIMPORT.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings
;;;                  Start command by typing DGNI
;;;
;;;                  Make the necessary adjustments to the following variables:
;;;                  ---------------------------------------------------------
;;;                  tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported,
;;;                        names of *.dgn drawings may be written without extension, as well as with extension,
;;;                        in plain text format, no return after the last line.
;;;                  tx2 = the path for the input folder, containing the actual *.dgn files to import.
;;;                  tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved,
;;;                        (routine assumes that the *.dwg files do not exist yet)
;;;                  tx4 = name of the drawing model to import
;;;
;;;
;;;                  The routine reads drawing names from the file given in tx1 line-for-line.
;;;                  In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing,
;;;                  does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3,
;;;                  and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop.
;;;
;;;                  The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation
;;;                  between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings).
;;;
;;;                  The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma,
;;;                  I advise to rename drawings having this issue.
;;;
;;;                  Written by M. Moolhuysen. Modified by C. Matthews
;;;
;;;                  This software may not be sold as commercial product or included as part of a commercial product.
;;;
;;;
;;;***********************************************************************************************************************
;;;***********************************************************************************************************************
;;;                    Converts a list of Spatial® ACIS® *.sat drawings into AutoCAD® *.dwg drawings                     *
;;;                                        Start command by typing SAT2DWG                                               *
;;;                                                                                                                      *
;;;                   Modified by SLW210 A.K.A. Steve Wilson from DGN import to ACIS® import 08/21/2023                  *
;;;***********************************************************************************************************************
;;;***********************************************************************************************************************


(defun C:SAT2DWG (/ fil tx1 tx2 tx3 tx4 tx5)
  (princ "Please select input folder. \n")
  (setq tx1 (vl-directory-files (setq tx2(acet-ui-pickdir)) "*.sat"))          ; select the folder containing *.sat files to be imported.

  (princ "Please select output folder. \n")
  (setq tx3 (acet-ui-pickdir)                                                  ; select folder for the *.dwg files to be exported into.
                                                                               ;(doesn't seem to work, the files go to the folder
                                                                               ;containing the folder selected) I'll work on it.
        tx4 "Default"                                                          
  )
  (setvar "FILEDIA" 0)
  
  (foreach tx5 tx1
    (if (wcmatch tx5 "*`.???")
      (setq tx5 (substr tx5 1 (- (strlen tx5) 4)))
    )
    (command "_UNDO" "_MARK"
             "ACISIN" (strcat tx2 "\\" tx5) tx4 "" ""
             "_ZOOM" "_E"
             "._DELAY" 500
             "_SAVEAS" "2018(LT2018)" (strcat tx3 tx5)	 
    )
	(command "_ERASE" "ALL" "")                ;erases everything on the page after the save
	(command "_.purge" "_all" "" "_no")        ;purges everything so you don't carry it over to the next drawing
	(command "_.purge" "_regapp" "" "_no")
	(command "_QNEW")                          ;opens a new drawing

  (setvar "FILEDIA" 0)   
  )

  (command "_QUIT" "_Y")
  (princ)

)

 

Sat Files.png

Sat to Dwg.png

Link to comment
Share on other sites

  • 2 months later...

Updated Code to fix minor saving DWG to directory issue and file naming when saving dwg is now the same as the original.  Included some instructions below for anyone that needs them.  All credit to original creators and editors.

 

To use:  Copy and paste the entire code to a file and save with extension .lsp   for example: conversatfiles.lsp.

 

----------------------------------------Copy and paste everything below this line and  above the line at the bottom and save to a file -------------------------

 

;;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;;;                                                                                                                       |
;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Modified to Import ACIS (.sat) to AutoCAD (.dwg)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|
;;;                                                                                                                       |
;;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
;;;
;;;  Original versions I got from here 
;;;  https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-convert-dgn-to-dwg/td-p/3237978
;;;
;;;* DGNIMPORT.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings
;;;                  Start command by typing DGNI
;;;
;;;                  Make the necessary adjustments to the following variables:
;;;                  ---------------------------------------------------------
;;;                  tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported,
;;;                        names of *.dgn drawings may be written without extension, as well as with extension,
;;;                        in plain text format, no return after the last line.
;;;                  tx2 = the path for the input folder, containing the actual *.dgn files to import.
;;;                  tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved,
;;;                        (routine assumes that the *.dwg files do not exist yet)
;;;                  tx4 = name of the drawing model to import
;;;
;;;
;;;                  The routine reads drawing names from the file given in tx1 line-for-line.
;;;                  In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing,
;;;                  does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3,
;;;                  and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop.
;;;
;;;                  The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation
;;;                  between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings).
;;;
;;;                  The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma,
;;;                  I advise to rename drawings having this issue.
;;;
;;;                  Written by M. Moolhuysen. Modified by C. Matthews
;;;
;;;                  This software may not be sold as commercial product or included as part of a commercial product.
;;;
;;;
;;;***********************************************************************************************************************
;;;***********************************************************************************************************************
;;;                    Converts a list of Spatial® ACIS® *.sat drawings into AutoCAD® *.dwg drawings                     *
;;;                                        Start command by typing SAT2DWG                                               *
;;;                                                                                                                      *
;;;                   Modified by SLW210 A.K.A. Steve Wilson from DGN import to ACIS® import 08/21/2023                  *
;;;                                    *
;;;***********************************************************************************************************************
;;;***********************************************************************************************************************

(defun C:SAT2DWG (/ fil tx1 tx2 tx3 tx4 tx5)
  (princ "Please select input folder. \n")
  (setq tx1 (vl-directory-files (setq tx2 (acet-ui-pickdir)) "*.sat")) ; Select the folder containing *.sat files to be imported.
  
  (princ "Please select output folder. \n")
  (setq tx3 (acet-ui-pickdir)                                             ; Select folder for the *.dwg files to be exported into.
        tx4 "Default"                                                    
  )
  (setvar "FILEDIA" 0)
  
  (foreach tx5 tx1
    (if (wcmatch tx5 "*`.???")
      (setq tx5 (substr tx5 1 (- (strlen tx5) 4)))
    )
    (command "_UNDO" "_MARK"
             "ACISIN" (strcat tx2 "\\" tx5) tx4 "" ""
             "_ZOOM" "_E"
             "._DELAY" 500
             "_SAVEAS" "2018(LT2018)" (strcat tx3 "\\" tx5 ".dwg") "_N"     
    )
    (command "_ERASE" "ALL" "")                ;erases everything on the page after the save
    (command "_.purge" "_all" "" "_no")        ;purges everything so you don't carry it over to the next drawing
    (command "_.purge" "_regapp" "" "_no")
    (command "_QNEW")                          ;opens a new drawing

  (setvar "FILEDIA" 0)   
  )

;;;    (command "_QUIT" "_Y")
  (princ)
)



-------------------------------------------------------------------------Copy and Paste everything above this line   and save to file -------------- ------------------------------
To use this to convert do the following


Must have AutoCAD installed.
Create a directory for the SAT files to be converted. Copy the SAT files to this directory
Create a directory for the converted DWG files.  The DWG files will be saved here
 

Usage:

1. Open AutoCAD and create a new blank file

2. Access the command line:

   Enter F2 to get to command line

On the command Line Enter:

APPLOAD

A window will open.  Chooose the converter file name (whatever you named the file) for example convertsatfiles.lsp

Click Load and the message: convertsatfiles.lsp successfully loaded will show.  click Close


On the command line Enter:

sat2dwg  -  A window will open.  

Navigate to the source directory and choose this directory (this is where the SAT files are kept) next

Navigate to the target directory and choose (this is where the DWG files will be kept)

 

conversion processing will begin immediately.  You will see activity happening in the command line window as the files are updated.  It will convert all files in the SAT directory to DWG

     

Edited by SLW210
Added Code Tags!
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...