sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Using add_3d_text

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 1.7k Views 4 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.
    • G Offline
      Greg
      last edited by

      Done means I moved the posting to this forum, Ruby Discussions, from the 'Newbie' forum. Actually, I copied this from the 'Newbie' forum to this forum, 'Ruby Discussions'. I don't know how to move a posting.

      Is there a more appropriate forum then 'Ruby Discussions'?

      1 Reply Last reply Reply Quote 0
      • G Offline
        Greg
        last edited by

        Just a follow-up to clarify my question: How do I set the (x,y,z) coordinates of the text to control it's orientation?

        I am programmatically assigning 3dtext as pallet labels to the front and top of pallets in a virtual warehouse created from ruby code generated from a c# application accessing inventory data from a SQL database, 2 to 3 thousand pallets.

        Right now, the text just lays flat on an x,y plane. That works for printing text on the top of pallets, but I can't orient the text upright so that it properly prints on the front of pallets.

        I hope this makes sense.

        Thank you.

        Greg

        1 Reply Last reply Reply Quote 0
        • GaieusG Offline
          Gaieus
          last edited by

          @greg said:

          Done means I moved the posting to this forum, Ruby Discussions, from the 'Newbie' forum. Actually, I copied this from the 'Newbie' forum to this forum, 'Ruby Discussions'. I don't know how to move a posting.

          Ok, I see. I also moved your topic nd then found that you copied it here so I merged the two.

          @unknownuser said:

          Is there a more appropriate forum then 'Ruby Discussions'?

          No, this is the finest forum for this (in the World? 😉 )

          Gai...

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

            See my TextTag script that does this. The 3d-text is grouped, it appears at 0,0,0, it's then transformed to where you want it, snapping to faces etc as desired...

            301 Moved Permanently

            favicon

            (www.sketchucation.com)

            TIG

            1 Reply Last reply Reply Quote 0
            • G Offline
              Greg
              last edited by

              Thanks TIG,

              I actually used your code as a guide to get as far as you see here. But I don't see how to programmatically snap the 3dtext to the front and side of a cubed-shaped object (pallet) without user intervention. I need the application to snap the text to the pallet automatically.

              Is this the section of your code I should reference for the 'snapto' functionality?

              %(#FF0040)[compo.behavior.always_face_camera=true if @cfacing=="Yes" ### faces camera
              if @asnap=="Yes"
              compo.behavior.is2d=true
              compo.behavior.snapto=0 ### snaps to Any surface
              end#if

              tag=model.place_component(compo)]

              If so, I can't figure out the relationship between your compo (components) and my grpEnts (entities).

              Greg

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

                After you have auto-placed the grp containing the 3d-text you need to rotate it in Z, then so it's vertical. You need to make a "rotation transformation"...

                transformation=Geom::Transformation.rotation(anchor_point,vector_axis,angle_radians)

                e.g. for a right-angle about Z try -

                rotate=Geom::Transformation.rotation(pointN.[0,0,1],90.degrees)

                e.g. for a right-angle about Y try -

                rotate=Geom::Transformation.rotation(pointN.[0,1,0],90.degrees)

                etc

                Mess around to find which you need for which group...

                TIG

                1 Reply Last reply Reply Quote 0
                • G Offline
                  Greg
                  last edited by

                  Thanks TIG, I'll do this.

                  Greg

                  1 Reply Last reply Reply Quote 0
                  • G Offline
                    Greg
                    last edited by

                    TIG,

                    I have tried variations of the code but I can't get it to work.

                    %(#FF0040)[txtPt = Geom::Point3d.new(x+w,y,z+(h/2))
                    t=Geom::Transformation.new(txtPt)
                    grp=entities.add_group(); grpEnts=grp.entities
                    grpEnts.add_3d_text("hey mon", 1, "Verdana", false, false, 4.inch, 1.mm, 0, false, 0)
                    grp.move!(t)

                    grp = Geom::Transformation.rotation(txtPt,[0,0,1],90.degrees) # these are variations
                    txtPt = Geom::Transformation.rotation(txtPt,[0,0,1],90.degrees) # these are variations
                    t = Geom::Transformation.rotation(txtPt,[0,0,1],90.degrees) # these are variations
                    rotate = Geom::Transformation.rotation(grp,[0,0,1],90.degrees) # these are variations]

                    I don't understand the relationship of 'Geom::Transformation.rotation(point,vector,angle)' to grpEnts.add_3d_text.

                    What am I overlooking?

                    Thank you.

                    Greg

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      Greg
                      last edited by

                      TIG,

                      Thanks for your help. The following code 'status = grpEnts.transform_entities t, grpEnts.collect' rotates the 3D-Text:

                      txtPt = Geom::Point3d.new(x+w,y,z+(h/2))
                      t=Geom::Transformation.new(txtPt)
                      grp=entities.add_group(); grpEnts=grp.entities
                      grpEnts.add_3d_text("hey mon", 1, "Verdana", false, false, 4.inch, 1.mm, 0, false, 0)
                      grp.move!(t)

                      t = Geom::Transformation.rotation(txtPt,[1,0,0],90.degrees)
                      status = grpEnts.transform_entities t, grpEnts.collect

                      This was copied from ldraw.rb.

                      Greg

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

                        I'd expect this to work for the 't' rotation - note that I prefer to keep things inside parentheses () - although it will work without (usually):

                        grpEnts.transform_entities(t,grpEnts)

                        or for the group rather than it's entities

                        grp.transform!(t)

                        (it's similar to grp.move!(t) ...)

                        Now you just have to copy this group of 3d-text (grp2=grp.copy!) and move! it around the corner and rotate transform! it to suit.

                        In SketchUp Ruby here are often several ways of doing the same complex thing - like transformations -, BUT sometimes there's NOT one way of doing some simple thing !!! For example finding the active section-plane or finding if sections-cuts are currently being shown in the view (something I'm looking at currently) - even the SDK doesn't access these shortcomings in the API...

                        Glad you fixed it.

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          Greg
                          last edited by

                          Thanks TIG,

                          I'll apply your suggestions and evaluate the results.

                          Greg

                          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