Announcement

Collapse
No announcement yet.

How to obtain the path of V-Ray file assets through Ruby?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to obtain the path of V-Ray file assets through Ruby?

    Hi,

    I'm new at Ruby language. Now that I have some locally existing files in the V-Ray File Path Editor in my .skp scene file, and I need to get these file paths through the Ruby scripts. I have read the online SketchUP Ruby API but cannot find the answer. Could anyone help me?

    Thanks so much.

  • #2
    I tried these commands, and it works now. I'd be grateful if anyone could tell me better ways. Thanks.


    scene = VRay::Context.active.scene
    scene.each { |plugin| puts "name: #{plugin.name}, category: #{plugin.category}, ies_file: #{plugin[:ies_file]}, file: #{plugin[:file]}" }

    Comment


    • #3
      You can checkout the documentation for the Plugin#each method. It yields 4 arguments, one of which is a flag letting you know if the parameter is a file path. Here is a snippet that will return an array of paths in a given context scene.

      Code:
      file_paths = VRay::Context.active.scene.each.map{ |plugin|
        plugin.each.select{ |_, _, _, is_file_path|
          is_file_path
        }.map { |_, value, _, _|
           value
        }
      }.flatten.uniq.reject(&:empty?)​
      ​
      Hope this is what you're after

      Comment


      • #4
        Originally posted by noel.warren View Post
        You can checkout the documentation for the Plugin#each method. It yields 4 arguments, one of which is a flag letting you know if the parameter is a file path. Here is a snippet that will return an array of paths in a given context scene.

        Code:
        file_paths = VRay::Context.active.scene.each.map{ |plugin|
        plugin.each.select{ |_, _, _, is_file_path|
        is_file_path
        }.map { |_, value, _, _|
        value
        }
        }.flatten.uniq.reject(&:empty?)​
        ​
        Hope this is what you're after
        Hi, thanks for your reply.

        Yes, I have used the Plugin#each method to resolve it, just like you pointed out. Thank you so much.

        Comment

        Working...
        X