sketchucation logo sketchucation
    • Login
    1. Home
    2. ruggiero.guida
    3. Posts
    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!
    πŸ”Œ Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
    R
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 12
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: How to detect changes in a model between two sessions

      Thanks TIG.

      I like this solution. It should work in principle for the objects whose properties I am going to change. I think I have to change the way I store the objects though. Let me explain.

      The goal is to produce an insolation contour across the development (at ground level). To do this I do the following:

      1 - mesh the surface that represents the interstitial space between buildings
      2 - for each grid node I cast rays to cover the whole hemisphere
      3 - for each ray I use raytest to verify whether I see the sky or I see an obstruction (this obstruction can be transparent or it can have an assigned temperature)

      Each Ray is an object with properties: direction, shaded_state, temperature, transparency and so on (there is no reference to Sketchup objects)

      Each grid node is represented by grid_node object with properties: coordinates and an array of Rays

      In order to implement your solution I think I will need to store the reference to the actual object that the Ray sees (if it does). I am not sure I can store a reference to a SketchUp object? Would the search in the datafile be faster than the re-calculation? I will test.

      Your proposed solution will not help though for the impact that a NEW object can have on specific grid nodes. My idea for this case was to replace the raytest with an intersection test between the new object (this is usually some form of local shading such trees, canopies, etc.) and the various rays for each grid node. I guess that the intersection test should be faster than raytest.

      Thanks again.

      posted in Developers' Forum
      R
      ruggiero.guida
    • How to detect changes in a model between two sessions

      (I have posted this also on the new forums.sketchup.com ... Not sure if this is considered cross-posting?)

      Hi,

      I'm using SU to perform radiation calculations in large developments. As part of the workflow I would like to be able to analyse different scenarios. My workflow at the moment is the following:

      1 - calculate a 'shading mask' for the points of interest. This shading mask contains also information about the surfaces that cast the shades such transparency, temperature, etc.

      2 - the shading mask information is all contained in an object. I use ruby marshal to dump this object on a file.

      3 - perform radiation calculations for a specified time interval

      4 - if I close sketchup and open it again because I need to analyse a different period, I load the marshal file and perform just the radiation calculation because the geometry information is already in the file

      5 - however, if I have to analyse a different scenario, because I have added shading, or I have changed the properties of some surfaces, I need to re-run the geometry calculation again. This can take even a few hours.

      It would be great if I could detect only the elements that have changed in the model and use this information to avoid having to rerun everything every time.

      Is there a way to do this?

      Thanks!

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      It worked beatifully.

      The only thing I had to change was a line of code where I use 'angle_between'. I just created a temporary Vector3D and solved the issue.

      I had to switch to Marshal because files were getting too big (180MB) and it was taking 15 minutes just to save.

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      Thanks a lot for the advice! I will try it out today.

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      eh that would be good!

      The speed is not an issue. I know that C++ would be better, but I don't know it and I really can't learn it in a week!! πŸ˜„ Maybe for the next project.

      Just one question. Is it possible in principle to serialize an object that contains various SketchUp specific classes? Like the object I have? This would solve all my problems.

      Thanks for your help. It's cool that the SketchUp developers get involved in this forum to help people.

      We are doing lots of stuff in my company with SketchUp from Openstudio to Daysim and various other simulations. In my team I am using SketchUp as the main modelling tool. A kind of repository for the geometries and then we export to the various simulation tools we use.

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      Hi,

      I'll give you a bit of background.

      I am working on a outdoor comfort analysis for a new development.

      I do not use Sketchup for visualization. I am using SketchUp to calculate the solar radiation for each point of a computational grid. The grid is fixed as it is imported from the CFD wind analysis. The surroundings are the 3D models of the buildings provided by the architects.

      SketchUp is great because it has lots of geometry operations embedded and easily accessible. And they are so fast! I use especially the raytest to check if a point is shaded or not.

      Now, for each point of the grid (ca 3000) I cast several rays to cover the sky. For each one of this ray I need to know if it is shaded, if not, how much radiation receives and which surface, if any, it intersects.

      I have an object that represent the node of the grid.

      class Point_SVF attr_accessor :grid_node # This is the node on the grid - Point3D attr_accessor :svf_array # This is an array of Rays objects def to_yaml "Coords: "+ self.grid_node.to_s#x.to_s + "," + self.grid_node.y.to_s + "," + self.grid_node.x.to_s end end

      The Ray object is used to store some info on the particular direction for that specific node.

      class Ray attr_accessor :vector #Vector3D object attr_accessor :shaded attr_accessor :solid_angle attr_accessor :transparency #Transparency of the FIRST intercepted surface attr_accessor :temperature #temperature of the FIRST intercepted surface end

      You can imagine that it can take a while to perform the analysis and the objects get quite big (SU sometime crashes).

      Also I need to test various shading scenario that will affect only some of the rays and I don't want to re-rerun the whole simulation all the time.

      That is where the serialization comes in. I would like to be able to serialize the array of Point_SVF objects. This array practically describes the whole geometry and it changes only partially when I test local shading.

      This is where I am stuck.

      Hope this gives a bit more context. πŸ˜„

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      Thanks. That explains it.

      This is an extract of the json I have produced by using .to_yaml on the array of Point_SVF objects.

      ` !ruby/object:Point_SVF
      grid_node: !ruby/object:Geom::Point3d {}
      svf_array:

      • !ruby/object:Ray
        vector: !ruby/object:Geom::Vector3d {}
        shaded: false
        solid_angle: 0.022817320094517073
      • !ruby/object:Ray
        vector: !ruby/object:Geom::Vector3d {}
        shaded: false
        solid_angle: 0.022817320094517073`

      Because this is just a string, it doesn't make sense to try to parse it back so it is of no use

      I have then tried to redefine the to_yaml method in my object, but it doesn't make any difference in the output.

      This is my object

      ` class Point_SVF
      attr_accessor :grid_node # This is the node on the grid - Point3D
      attr_accessor :svf_array # This is a Ray object
      def to_yaml
      "Coords: "+ self.grid_node.x.to_s + "," + self.grid_node.y.to_s + "," + self.grid_node.x.to_s
      end

      end`

      Calculations take even an hour and I am trying several shading options. I would like to be able to save my shading file (array of Point_SVF) and then just re-use it

      It would be great if you could point me in the right direction.

      Cheers

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      Hi there. Apologies for wasting your time. I just realized that I had commented all the requires because of a previous problem.

      Too many late nights and weekends trying to finish this project on time!

      The 'doesn't work' meant that I received the error

      Error: #<NoMethodError: undefined method `to_yaml' for #Array:0xe3023f8>

      Now I am trying to figure out how to dump an array of objects recursively. JSON only saves references to the objects, but YAML seems to work.

      Thanks again

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Full ruby installer

      Hi.

      I am using SketchUp 2014. I would like to test YAML and JSON. I have tried to add require at the beginning of the program, but that doesn't seem to work. Maybe I am missing something?

      posted in Developers' Forum
      R
      ruggiero.guida
    • Full ruby installer

      Dear Group,

      With my ruby script I am starting to create very big objects that require several minutes to be created. I was looking into serialization in order to save them on a file and realized that, at least from what I have understood, libraries like yaml, json are not included in the Sketchup Ruby version.

      Now I would like to install the full Ruby library 2.0.

      What is the right way to do it? Maybe it is a silly question, but I have a deadline next week and the last thing I want is to spend hours to fix a wrong installation that make my scripts unusable! πŸ˜„

      I have downloaded the last ruby from here

      Link Preview Image
      Downloads

      The easy way to install Ruby on Windows This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important...

      favicon

      (rubyinstaller.org)

      Thanks!

      posted in Developers' Forum
      R
      ruggiero.guida
    • RE: Functions in 'require' are not updated till restart..

      Thanks. Trying to make my head around modules. I am not planning to write plugins for distribution, I am just trying to keep my code cleaner.

      Cheers

      posted in Developers' Forum
      R
      ruggiero.guida
    • Functions in 'require' are not updated till restart..

      Dear Forum,

      I am developing a ruby script for shading calculations to integrate with my CFD analysis.

      I have a few functions within an external file (not in a module) that I include in the main code with 'require'.

      It has been working fine for the last few weeks, but a couple of days ago, I noticed that if I made a change in one of these external functions, these changes were not 'seen' until I restarted skethcup. The function worked once copied directly in the main script and I confirmed that the file was actually saved.

      Is there any specific directive that I have to use at the beginning of the main ruby script? Is it a name space issue? I will keep testing, but it would be good to understand what it is actually happening.

      This is what I have at the beginning of my code

      require 'sketchup.rb'
      require 'r/ReadMesh.rb'
      #require 'r/ReadCSVMesh.rb'
      require 'yaml'
      require 'csv'
      require 'r/readCSV'
      include Math

      ReadCSVMesh is the function incriminated...

      Thanks a lot

      posted in Developers' Forum
      R
      ruggiero.guida
    • 1 / 1