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

    Moving 3d text

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 794 Views 3 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.
    • K Offline
      kiesewetter
      last edited by

      Hallo!
      I'm trying to write a script that creates a list of 3d texts. One 3d text should be diplayed, then it should be moved (in negative y-direction), then the next 3d text should be created and so on.
      With my code the Translation of the text doesn't work.
      Here is the code:

      
      y_text=0
      zaehler=0 #counter
      textarray=[]
      @bauabschnitte.each{|b|
                           tr = Geom;;Transformation.new [0,y_text,0]
      		     anzeige =  b.getname #the text the should be displayed by the 3d text
                           textarray[zaehler]=ents.add_3d_text anzeige, TextAlignRight,"Arial",false,false,10,5,0,true,1
      		     ents.transform_entities tr, textarray[zaehler] #here the 3d text should be moved...
      		     y_text = y_text-15
      		     zaehler = zaehler+1
      		    }
      
      

      Thanks for your time.
      Tim

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

        Initially 3D text is always placed at the ORIGIN = [0,0,0]
        Your code sets a new point as a tr-ansformion = [0,y_text,0]
        BUT you have just set y_text=0
        SO it won't move as you transform it to the same point !!!
        You then reset y_text = y_text-15 BUT that's after the tr-ansformation was invoked!!!
        Set a point that isn't [0,0,0] and you will see the 3D text move!!!!!!!!!!!!!!!
        😒

        TIG

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Hi,
          TIG, good point, quite obvious 😉

          @unknownuser said:

          tr = Geom::Transformation.new [0,y_text,0]

          Better like this: tr = Geom::Transformation.new([0,y_text,0])
          or: tr = Geom::Transformation.translation([0,y_text,0])
          Always put arguments within parenthesis, such as:
          textarray[zaehler]=ents.add_3d_text(anzeige, TextAlignRight,"Arial",false,false,10,5,0,true,1)

          Tschüss

          DB

          1 Reply Last reply Reply Quote 0
          • K Offline
            kiesewetter
            last edited by

            The translation should be done with the elments of the array @bauabschnitte exept the first one.
            So y_text is set to 0 at the beginning an gets raised every time the code passes the "each" part.

            Here is the error-message that appears in sketchup every time I load the code:

            Error: #<TypeError: C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253:in transform_entities': wrong argument type (expected Sketchup::Entity)> C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253 C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253:in balkendiagramm'
            C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:249:in each' C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:249:in balkendiagramm'
            C:/Users/tim/Desktop/test_balkendiagramm.rb:5
            (eval):0:in `load'
            (eval):0

            The first 3d-text is created at the origin. So I don't know what to do.

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

              def texter
                  model=Sketchup.active_model
                  ents=model.active_entities
                  y_text=0
                  zaehler=0 #counter
                  @bauabschnitte=["Dog","Cat","Mouse","Spider","Fly"] ### TIG faked up 'name' list here***
                  textarray=[]
                  @bauabschnitte.each{|b|
                      anzeige =  b ###b.getname #the text the should be displayed by the 3d text - 
                      ###***what is 'b.getname' ?  If 'b' is a component then use 'b.name' ???
                      gp=ents.add_group() ### must group 3D text
                      gp.entities.add_3d_text(anzeige,TextAlignRight,"Arial",false,false,10,5,0,true,1)
                      tr = Geom;;Transformation.new(Geom;;Point3d.new(0,y_text,0))
                      textarray[zaehler]=gp ### add gp to array
                      ents.transform_entities(tr, textarray[zaehler]) #here the 3d text should be moved...
                      y_text = y_text-15
                      zaehler+=1 ### increment counter
                  }
              end
              

              This works type 'texter' to run. When you make a piece of 3D text it returns 'true' if successful so your array was 'booleans' NOT 'entities'. Here I add the 3D text to a group and THEN add the group to the array, that way you CAN transform the group as needed...

              TIG

              1 Reply Last reply Reply Quote 0
              • K Offline
                kiesewetter
                last edited by

                works 😄 . thanks a lot.

                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