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

Individually export all components to .dwg

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 2 Posters 5.1k Views
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
    janunes65
    last edited by 14 Apr 2020, 10:49

    I haven't managed I need help

    ` model = Sketchup.active_model
    modelpath=File.dirname(model.path)
    modeltitle=model.title

    clist = []
    for c in model.definitions
    if c.count_instances > 0 and c.group? != true
    clist = clist.push([c.name ])
    Sketchup.active_model.selection.add( Sketchup.active_model.definitions[c.name ].instances )
    sel = Sketchup.active_model.selection
    #export(modelpath + "/" + c.name + ".dwg",false)
    sel.export(modelpath + "/" + c.name + ".dwg",false)
    end
    end`

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 14 Apr 2020, 12:44

      Link Preview Image
      Class: Sketchup::Model

      This is the interface to a SketchUp model.

      favicon

      SketchUp Ruby API Documentation (ruby.sketchup.com)

      export(modelpath + "/" + c.name + ".dwg", options_hash )

      You need to construct the options hash to only export the selection etc...
      however I don't know what hash items will work with DWG and your SketchUp version...

      An alternative workaround would be to do the individual exports in a model.start_operation(...) block in which you need to get a reference to each component-definition in turn, erase all of the model with model.entities.clear!, then place an instance of chosen component at the origin, then purge unused definitions, layers and materials etc to tidy up, then do the export to DWG, finally immediately run mode.abort_operation which undoes all of the changes...
      The export of just that one definition as a DWG will survive... but the model itself will revert to how it was before that export operation.
      Process the next definition in the same way until all are done...

      TIG

      1 Reply Last reply Reply Quote 0
      • J Offline
        janunes65
        last edited by 14 Apr 2020, 15:47

        3D Autocad (DWG/DXF)
        :acad_version - Specifies the autocad_version to export.

        values: "acad_12", "acad_13", "acad_14", "acad_2000", "acad_2004", "acad_2007", "acad_2010", "acad_2013"

        :faces_flag - Boolean to indcate whether to export faces.

        :construction_geometry - Boolean to indicate whether to export construction geometry.

        :dimensions - Boolean to indicate whether to export dimensions.

        :text - Boolean to indicate whether to export text objects.

        :edges - Boolean to indicate whether to export edges.

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 14 Apr 2020, 16:49

          So if that is the extent of the options, then 'selection' is not there ?
          So look at my alternative idea of deleting 'everything' but the chosen component instance, then aborting...

          TIG

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

          Advertisement