individually export all components to .dwg

individually export all components to .dwg

Postby janunes65 » Tue Apr 14, 2020 11:49 am

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
0

janunes65 
 

Re: individually export all components to .dwg

Postby TIG » Tue Apr 14, 2020 1:44 pm

https://ruby.sketchup.com/Sketchup/Mode ... nce_method

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...
1
TIG
User avatar
TIG 
Global Moderator
 

Re: individually export all components to .dwg

Postby janunes65 » Tue Apr 14, 2020 4:47 pm

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.
0

janunes65 
 

Re: individually export all components to .dwg

Postby TIG » Tue Apr 14, 2020 5:49 pm

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...
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 6 guests

Visit our sponsors: