• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Transforming an object with SketchUp Ruby

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 2.0k Views
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.
  • K Offline
    KevinKarney
    last edited by KevinKarney 3 Jul 2013, 09:54

    I am struggling a bit with Ruby and would really appreciate some help...

    I just want to add some 3D text to my model (which I can do)
    model = Sketchup.active_model entities = model.entities mytext = entities.add_3d_text('test', TextAlignCenter, "Arial", true, false, 2.0, 0.0, 0.0, true, 0)

    I then want to rotate the text about the z-axis with a transformation, such as
    tr1 = Geom::Transformation.rotation(ORIGIN, Z_AXIS, 45.degrees)

    I then want to translate the text with a transformation, such as
    tr2 = Geom::Transformation.translation Geom::Vector3d.new (0,1,0)

    I just cannot work out how to apply tr1, then tr2 to mytext. It's got to be simple, but everything I have tried produces an error.

    Thanks in advance from Wales
    Kevin

    Best Regards
    Kevin Karney

    1 Reply Last reply Reply Quote 0
    • A Offline
      Aerilius
      last edited by 3 Jul 2013, 10:16

      You need a reference to the object (of the text). Therefore it is usefule to create the text (edges and faces) inside a group and apply the transformations to the group.

      entities = model.entities group = entities.add_group group.entities.add_3d_text("test") group.transform!(tr1) group.transform!(tr2)

      1 Reply Last reply Reply Quote 0
      • K Offline
        KevinKarney
        last edited by 3 Jul 2013, 11:01

        Aerilius
        You are a star !
        Thanks a million
        Kevin

        Best Regards
        Kevin Karney

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

        Advertisement