@rubine said:
do you see a chance to rebuild the "create component" with ruby?
i.e. writing your own "create component" method (creating a ComponentDefinition)
You can easily make and place components with ruby methods, such as.
Definitionlist.add("componentdefinitionname")
ComponentDefinition.entities
Group.entities
Group.to_component
entities have lots of 'add' methods: http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Entities.html#add_instance
You can't 'save_as' components in current Ruby - but you can do it manually.
I've discovered that in the SDK there's a kind of ...Group.SaveAs() method that would allow us to write something like a dll or a socket that could then access that function. In a script you'd have to say something like:
require 'GroupExporter.so'
...
GroupExporter.new(group,filepath)
...
This would then save a specified group to a .skp file at a specified name/location. These kinds of variables can be got/set in earlier bits of Ruby coding...
To get it to export a Component all we'd need to do is make a temporary group, that's then named after the component-definition and even with a copy of its description if any (that way the final exporter component matches the original in the model...). Then to that group's entities we add an instance of the component (and explode it inside the group?). We then use GroupExporter.new(group,filepath) and finally erase the group to tidy up. If we want it done 'silently' we can specify the filepath - say as the model's folder_path/group_name.skp - or we could prompt for a component name and/or location...
All I need now is someone who can make this dll/so with the SDK - my C++ is too poor to do it...