In the past we have used Mechanical en STEPIN to automatically import STEP files. No we're having problems with the STEPIN command. Some objects aren't imported with STEPIN, while using the IMPORT command everything is imported. So I've contacted the support desk and they told me to use the IMPORT command because it's newer and maybe it's time to drop de STEPIN function.
The problem I'm facing to automate this progress is that the IMPORT function needs an mouse input when the conversion is done. The second problem is that other commands (like setting the view and surface shading right) have to wait till the file is converted. Does anyone know if it's possible to automate the IMPORT command.
I've found a similar topic regarding this matter, but there were no answers so I thought let's see if someone has made progress with this.
this is what I have so far not complete but you should be able to put something together yourself
(defun c:sfimport(/ ALE_BrowseForFolder path ftype flist fname GetFolders extensiontype )
;; Original BrowseForFolder by Tony Tanzillo
(defun ALE_BrowseForFolder (PrmStr / ShlObj Folder FldObj OutVal)
(vl-load-com)
(setq
ShlObj (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 PrmStr 0)
)
(vlax-release-object ShlObj)
(if Folder
(progn
(setq
FldObj (vlax-get-property Folder 'Self)
OutVal (vlax-get-property FldObj 'Path)
)
(vlax-release-object Folder)
(vlax-release-object FldObj)
OutVal
)
)
)
(defun GetFolders (path / l c)
(if (setq l (vl-directory-files path nil -1))
(apply 'append (mapcar
(function (lambda (x) (cons (setq c (strcat path "\\" x)) (GetFolders c))))
(vl-remove "." (vl-remove ".." l))
)
)
)
)
(setq path (ale_browseforfolder "Select directory to get files:"))
(setq extensiontype ".step")
(setq ftype (vl-directory-files path "*" extensiontype ))
(setq flist (getfolders path)); get sub folders
(alert "\n\n Click OK to continue SFImport..")
;;; build your own stepImportRecursive
(foreach 3DModel ftype
(command "_import" (strcat path "\\" 3DModel) )
(setq fname (substr 3DModel 1 (- (strlen 3DModel) (+ ((strlen extensiontype) 1)))))
;;;export imported blockname possible wblock???
)
;;; end stepImportRecursive
(princ)
)
Maybe this will help you - AutoImportCAD