This is the code I could glue from examples in the web, but don’t know more than this.
How to point the “path” to components Browser?
Is “Sketchup.find_support_files” the right command to get the list?
Will try that for a single object, thank you.
I am trying to get and process a list of 500 components after .DAE Batch importing.
Inserting each by name is out of question.
Was expecting something like:
clist = [abc, def, ghi, etc] #Components list that I get from component browser (How?)
clist.each do | ??? |
instance = entities.add_instance(my_def, transform)
Perhaps you can check if these components already have an instance inserted into model, if not then you can find it:
The ComponentDefinition #count_used_instances method is used to count the total number of component instances in a model using this component definition. This method takes into account the full hierarchy of the model.
model = Sketchup.active_model
definitions = model.definitions
clist = definitions.select{|d| d.count_used_instances == 0 }
## Or alias method
# clist = definitions.find_all{|d| d.count_used_instances == 0 }
clist.each do | clist_element |
instance = entities.add_instance(clist_element, transform)
end