sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Model.import fails to import dwg's

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 1 Posters 398 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jwelin
      last edited by

      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

      John Welin
      architectural model maker
      Chicago, USA

      1 Reply Last reply Reply Quote 0
      • J Offline
        jwelin
        last edited by

        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.

        John Welin
        architectural model maker
        Chicago, USA

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement