Display image using Ruby API
-
Can anyone tell me how to display an image which is located in other directory using Ruby API in SketchUP?
-
Add an Image entity? Or add a material with a texture?
@blue_orchid said:
located in other directory
Other than what?
-
What I wanted to do is display an image after I click the object.
-
Please don't 'report' a post when you mean to 'reply'
OK... back to your 'question'...
What 'object' do you want to click ?
It is quite possible to add an Image to a SKP... or use an image-file as a texture for a new material in a SKP [and use it on a face]...
So, do you perhaps mean to use an image as a new textured-material on a selected [clicked?] face ?
How are you expecting to determine this 'image' size/scaling/orientation etc...More info needed for a definitive response...
-
AND.. by "other directory"... do you mean:
1) other than the directory that the model is saved in ?
2) other than the "images" directory used by SketchUp ?
Note that in Ruby, you can always specify an absolute full filepath (as long as there are no multibyte unicode characters in the path for PC.)
Or you can change the current working directory.. via:` prevdir = Dir.getwd
Dir.chdir( "C:/some/path/to/imagedir" )do your file handling command
Dir.chdir( prevdir )`
When Ruby (and Sketchup,) starts up, the current working dir, is set to the user's profile folder, which is
ENV['USERPROFILE']
(on PC,) orENV['HOME']
(on the Mac.)
It is always a good idea to save it, and restore it when your done using another working directory, .. or else possibly another plugin may "lose it's way" if the author did not write his/her path handling in a defensive manner. (as shown above.) -
"Directory" means just the folder in your computer.
What I wanted to do: On clicking dynamic component, image should pop up.
-
Is this Image one of several in the DC ?
If so you just hide them all except the one wanted OR have an onClick to unhide the Image wanted ??? -
You mean open a window with an image - like a WebDialog?
-
Ya, WebDialog is also fine.
Advertisement