Model.import fails to import dwg's
-
I am using the model.import method on a batch of DWG files without success. Every import attempt yields this error as a window in the SU application (not the console):
Error opening AutoCAD import file: Invalid group code
This does not appear to be a valid AutoCAD DWG or DXF file or the file is write protected.These are good 2004 dwg files which open in ACAD and audit without errors.
Oddly, these dwg's import fine with the file:import in SketchUp
This error occurs in Su6 and Su7 identically.
I have saved down to 2000 dwg with the same error.
I am using the free version of SU, both on Mac and PC.This is the Ruby code:
model = Sketchup.active_model
status = Sketchup.open_file templatename
status = model.import(fileone)
status = model.import(filetwo) if filetwo != "no match"
status = model.save(destinpath + filename)I am creating simple test dwg's to see if I can get the model.import to work at all. I will also try dxf format.
Any insight?
John Welin, architectural modelmaker in Chicago
-
Alright, the error popped up because of an error in the file path (fileone or filetwo in the code).
Silly mistake made frustrating by a misleading error message.However, I have these observations:
model.import and model.export have a second parameter which suppresses the summary window.
This works exporting, and importing skp files, but does not suppress the summary for dwg files. So the user must click on the OK button for every file which is imported.model.save does not function as the application's file:saveas command, in that the open skp file does not assume the name of the saved file. model.save functions more like file:save a copy as.
These two points, along with the lack of a method to close a file (have I missed it?) makes automating any sort of batch processing difficult. Perhaps its intentional, but it limiting for a scripting language.
Advertisement