2

I'm trying to create a several cylinders with a loop, rotating each one slightly in 3 dimensions each time, a random amount.

Here's what I have so far:

until i == 200
        x += rand(10)
        y += rand(10)
        z += rand(10)
        xyz = rand(2)
        circle = entities.add_circle([x,y,z], axis[xyz], r, n)
        base = entities.add_face(circle)
        base.pushpull -h
        base.transform_entities(Geom::Transformation.rotation([0,0,0],[1,0,0],rand(360)),base)
        i += 1
        #sleep 0.2
    end

The transform_entities throws this error:

Error: #<NoMethodError: undefined method `transform_entities' for <Sketchup::Face:0x18836040>>

Any ideas how I can make this work? I've dug through the API docs but can't figure out a solution.

Thanks!

logic-unit
  • 4,195
  • 12
  • 47
  • 72
  • Sidenote - looks like you're trying to animate. In which case have a look at the `Animation` class: http://www.sketchup.com/intl/en/developer/docs/ourdoc/animation – thomthom Mar 18 '13 at 20:31
  • @thomthom kind of - trying to recursively generative elements. a very crude generative architecture algorithm. thanks for the pointer though, will check that out. – logic-unit Mar 19 '13 at 17:26

1 Answers1

3

I was incorrectly applying the transform to base rather than entities.

Should be:

entities.transform_entities(Geom::Transformation.rotation([0,0,0],[1,0,0],rand(360)),base)
logic-unit
  • 4,195
  • 12
  • 47
  • 72