Create multiple scenes on the X axis (or globally in XYZ matrix) by ruby code

Hi,

I am rather new with a ruby. I am looking for a code to create bunch of scene but moved on X (or Y, Z) axes. Scenes are expected to be alike the first one, but moved.

To explain the goal - I want to show the room design changes. Changes are tiny. So it is easier for me to copy the same room 20 times (for example each 10m in x-axis), make changes for each and then have 20 models, seperated certain distance in X direction (or with a lot of scenes - maybe in X and Y).

Then, I would like to have exaclty the same scene for each model, based on the scene in the first one.

So - I would like to write a script to create a loop that will generate certain number of scenes alike the first one, but moved along axis/line or whatever. Or more complex - in XY or even XYZ matrix.

After all I can render them in a batch and show changes easily.

It seems likely you can do what you seek leaving all versions at a single location and using tags to control visibility of alternatives. No Ruby needed.

1 Like

Nope, if I am to create 1000 designs I need to automate it. Especially that I may get lost what is changed and what isn’t
I have bunch of more ideas how to use it - just don’t know how to make this I guess simple code

Without more information, I don’t understand what changes from one version to the next. Unless it is something very systematic, hence describable by a few parameters, it seems like programming the variations won’t be all that much easier than drawing them by hand. I must be missing the point, as what you describe sounds very inefficient.

1 Like

Maybe this way it will be easier - I found this code from this thread:

It makes scenes around the object.

I want the same idea, but to make scenes on the line. It may be also used for animations - so maybe I need to make a large amout of scenes.

:thinking:

scenes_by_moved_onX

concept code:
(Note: executing it more than ones, cause duplicate scene names, which need to be programmed to avoid)

def scenes_by_moved_onX(distance, times)
  vec = Geom::Vector3d.new(1,0,0)
  vec.length = distance
  model =  Sketchup.active_model
  cam = model.active_view.camera
  pages = model.pages
  eye = cam.eye
  tar = cam.target
  up = cam.up
  
  move = Geom::Transformation.translation(vec)
  times.times{|i|
    cam.set(eye, tar, up)
    pages.add("Scene " + (i+1).to_s)
    eye.transform!(move)
    tar.transform!(move)
  }
end
scenes_by_moved_onX(6000.mm, 5)
2 Likes

We usually prefer that you at least make an attempt to write the code.

1 Like

Thank you, that is exactly what I was looking for !

1 Like