• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Script to automate Texturing a surface -> Render

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 1 Posters 480 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    Carpeggio
    last edited by 18 Apr 2016, 20:22

    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
    end
    

    It 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;
    http://i.imgur.com/jXTMik5.png

    but in the output I only see the original texture;
    http://i.imgur.com/XNxZpWt.png

    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.

    1 Reply Last reply Reply Quote 0
    • C Offline
      Carpeggio
      last edited by 18 Apr 2016, 20:34

      Here's what my input/output folders look like after the script: http://i.imgur.com/9yTBr90.png

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        2/2
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement