Script to automate Texturing a surface -> Render
-
Hey guys,
New to Ruby and Sketchup. But making do with what resources I find.
# Ruby Script for Retexturing and Rendering Scene from source directory images. # Have top of board game/material selected (Just the top face) before running script. inputDir = Dir.open "C;/Users/XXXX/Downloads/Notes And Things/Photo_Illustrator_OddandEnds/SketchUp/Gameboard Modeling/TopCovers(Bulk)" i = 1 inputDir.each do |file| # Process through Sketchup. # Get a handle to the selection set. currentMaterial = Sketchup.active_model.materials.current currentMaterial.texture = File.absolute_path file UI.messagebox(file) # Save Render to outputDir. view = Sketchup.active_model.active_view view.write_image "C;/Users/XXX/Downloads/Notes And Things/Photo_Illustrator_OddandEnds/SketchUp/Gameboard Modeling/Renders/BulkOutput/testImage#{i}.png" i = i + 1 endIt runs, and produces output write_images. However, the material does not update. I cannot for the life of me figure out why.
Hoping to see these images get placed onto the model;

but in the output I only see the original texture;

The script requires that you have the material with the texture selected because of the line 'currentMaterial = Sketchup.active_model.materials.current' selects that.
In 'currentMaterial.texture = File.absolute_path file' I was hoping to find some syntactical error that would lead to nothing being applied, but I'm not seeing anything.
I'm taking screenshots right now with view.write_image just for proof of concept, but hopefully I'll upgrade that to one of two things;
Create a scene per texture, then Batch Render with Vray after all the textures have been put into a respective scene. OR... Render between retextures. I'm not sure which can work.
-
Here's what my input/output folders look like after the script: http://i.imgur.com/9yTBr90.png
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement