Using add_3d_text
-
Yeah, this is definitely ruby stuff.
BTW welcome, Greg, but what do you mean by "done"?
-
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'?
-
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
-
@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? )
-
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...
http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=2954&p=20077&hilit=texttag#p20077
-
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#iftag=model.place_component(compo)]
If so, I can't figure out the relationship between your compo (components) and my grpEnts (entities).
Greg
-
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...
-
Thanks TIG, I'll do this.
Greg
-
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
-
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.collectThis was copied from ldraw.rb.
Greg
-
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.
-
Thanks TIG,
I'll apply your suggestions and evaluate the results.
Greg
Advertisement