sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Volumetric visualization

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 377 Views 3 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.
    • M Offline
      martinspixis
      last edited by

      Hello Experts!

      for study purposes I need to create a SketchUp Ruby script for volumetric visualization of radiation dose. Dose volume must be divided into voxels where each voxel have x;y;z coordinates and value V which represents dose intensity, besides the voxels must be colored in different colors regarding to value V. For example, if 5>V>3, then color = blue, but if 10>V>5, then color = green et cetera.
      Can someone suggest a script to modify for my needs or help solve this problem?

      P.S. I am not an IT professional, my field of study is physics, so scripting is not an ordinary activity for me πŸ˜„

      Thanks in advance,

      Martins

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        How is the data input into SketchUp ?
        I imagine you don't want to type x,y,z,v in for every one !
        If it is the form of Comma Separated Values in a CSV file - read/writable in Excel - then as the data is plain text you can read in the lines as individual voxels.
        I recommend that 1 unit in the file is represented by 1" in SketchUp [makes the number crunching easier].
        So then we have an array called 'voxels' containing several array of [x,y,z,v] data.
        Your tool needs to start by making a 'voxel' component - I suggest a 1x1x1 cube - easily done by making a definition and adding a 1x1 face from 4 points and pushpulling it by 1.
        Next you need to set up some colored materials to use later [suggest material.alpha= opacity at ~0.4] - you can specify by name - e.g. 'red' or create your own colors etc.
        Now make add a group in the model.entities to contain the voxel 'instances'.
        Now iterate the vowels and to the group.entities add an instance of the voxel definition.
        Read that voxel's array x,y,z,v values - use .to_f to convert the imported strings into numbers
        Make a point3d based on these x,y,z values.
        Use that point3d in a new Transformation.
        instance = group.entities.add_instance(voxel, transformation)
        The new instance of a voxel is added at x,y,z, it uses the default material.
        Now use a series of 'case' or 'if' tests to decide on the 'instance.material=' you use for that instance.
        You can also set the instance.name=v.to_s so the Entity Info can tell you the exact value of a selected voxel.
        After all of the voxels are processed you now have a stack of cubes colored by their 'v'.
        If the color has transparency then you can see through them, or Xray view-mode ?

        There are several plugin/code examples on SCF for the reading of CSV data, use of .to_f, making materials/colors, making components, adding instances with transformations, making tests assigning materials and so on

        TIG

        1 Reply Last reply Reply Quote 0
        • AdamBA Offline
          AdamB
          last edited by

          Your best bet is to extract the iso-surface from your data using marching-cubes rather than generate zillions of cubes.

          It would mean you could create N colored surfaces representing each of your threshold values for V.

          If you're asking whether its a trivial 10 minute script. The answer is unfortunately, No. 😒

          Adam

          Developer of LightUp Click for website

          1 Reply Last reply Reply Quote 0
          • M Offline
            martinspixis
            last edited by

            Thank's to all, problem solved!

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

            Advertisement