@whaat said:
Is it possible to enter 'component edit mode' with Ruby?
Is it possible to prompt the user to browse for a file folder (not a file)?
If not, consider these requests for the next service release of SU.
Thanks.
I used a trick to edit groups [PC only] - components could be done similarly...
require 'sketchup'
require 'win32ole.so'
def edit_group
### an example of access SUp tools not otherwise available...
### make shortcut here if NOT set already = ctrl+alt+shift+G
### check that you have one group selected and if so do this...
WIN32OLE.new("WScript.Shell").SendKeys("+^%{g}")
end#def
### run it from within other tools
### the menu here for test only...
if(not file_loaded?("edit_group.rb"))
UI.menu("Plugins").add_item("Edit Group"){edit_group}
end#if
file_loaded("edit_group.rb")
###
This is how I find a directory - you do need to pick a file in it though...
require 'sketchup.rb'
#-----------------------------------------------------------------------------
def materialimporter
model= Sketchup.active_model
materials= model.materials
model.start_operation ("Import Materials") ###undo - see commit at end
pwd= Dir.getwd.split("/").join("\\")+"\\" ### fix for SU
drctry= UI.openpanel "To Pick this Directory; Pick Any Image File + OK...", pwd , "*.???"
return nil if not drctry
drctry= File.dirname(drctry)
return nil if not drctry
cwd= Dir.chdir(drctry)
images= Dir["*.{jpg,png,tif,bmp,gif,tga,epx}"]### for all supported image file types
for image in images
imgname= image.split(".")[0..-2].join(".") ### removes .jpg etc from end
mat= materials.add(imgname)
mat.texture= image
end#for image###
model.commit_operation ###undo all if needed
end#def###
.