Moving 3d text
-
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 -
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 sety_text=0
SO it won't move as you transform it to the same point !!!
You then resety_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!!!!!!!!!!!!!!!
-
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
-
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:ineach' 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):0The first 3d-text is created at the origin. So I don't know what to do.
-
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...
-
works
. thanks a lot.
Advertisement