3d text appears to ignore z parameter

I’m trying to use 3d text in a plugin. When I fill it I get Z-fighting with the face it’s placed on.

I tried adding a Z value as a parameter, but it seems to be ignored. Is this a known bug? I can’t find any references to the problem, either on this forum, or from a general Google search.

right click the 3D text and find “unglue” then it will free itself.

How do I do that in Ruby? It is placed in a group, and isn’t a component, so I didn’t think it could have a ‘Glue to…’ attribute.

There is no Ruby parameter either to ‘glue’ or to ‘unglue’ it that I can see in the API docs.

ah, that’s Ruby.

anyone? Sages?

The ONLY entry for 3d_text I can find in the Ruby API Methods is the Entities.add_3d_text. If there are any other entries, I can’t see where.

I don’t want to Extrude it, since that much more than doubles the number of edges and faces generated.

The only workaround I can think of at the moment is to put the text inside a group of its own (it’s just part of a larger group now), then move the group up the local Z-axis. Haven’t time to try that just now, but failing any other solution, will give it a go.

If that IS the only way, seems that the z-parameter not working is a bug.

This is in the Ruby API forum, you know. :wink:

My bad :sob:

Actually the GUI, places the 3Dtext primitives within a component. The API does nothing, but create the primitives within the current active_entities context. So it is up to you, whether you want it in a component or group.

When the API doc says “origin” it refers to the origin of whatever context you place it in. This could be a new group you’ve just made. Or some other existing group or component,… might be nested, etc.

After creating the context (group or component,) for your 3DText, apply a transformation to move it, rotate it, scale it, whatever. So, just like the GUI command, the transformation (insertion point,) is not really set until the last step.

Re. groups vs components, you can always use the group#to_component() instance method. But in this case, if you want it a component, you might as well just do that from the start.

text = "Some text for my component"
defn = model.definitions.add(text)
# now defn's name is equal to the text,
# an appears in the EntityInfo dialog (nifty!)
  text, TextAlignLeft, "Arial",
  true, false, 1.0, 0.0, 0.5, true, 5.0
# create a transform for the text
t = Geom::Transformation::new( x, y, z )
# now place an instance where you will:
model.entities.add_instance( defn, t )

You definitely always want to put 3DText in a container of it’s own. If you prefer group:

text = "Some text for my component"
ents = model.active_entities
cpt = ents.add_cpoint([0,0,0])
grp = ents.add_group(cpt)
grp.name= text
# now defn's name is equal to the text,
# an appears in the EntityInfo dialog (nifty!)
  text, TextAlignLeft, "Arial",
  true, false, 1.0, 0.0, 0.5, true, 5.0
# create a transform for the text
t = Geom::Transformation::new( x, y, z )
# Now move the group where you will, ...
# relative to the active entities context's origin
grp.transform!( t )

You can erase the cpt but it may come in handy later for the user if they wish to move the text.

Dan, thanks. That clarifies things. When I said the ‘text is in a group’ I meant that I already insert it into an existing group - but I’ll put it inside a group of its own, inside the larger group. And maybe then move the text group up a bit on its Z axis to stop Z-fighting on a face.

Won’t need the cpoint here (it won’t be user-editable) after insertion, but I do use them.

I rarely use 3D text at all, and even more rarely through the GUI, so I had forgotten that the GUI inserts a component with a ‘glue to any’ attribute.

I’ve now figured out (more or less) why my Z value was having no apparent effect. It DOES do just what I expected, if I just insert the text at the origin with no movement - the text IS then displaced up the Z axis.

BUT … I was inserting it with an immediate move to put the centre of the bounding box on an existing point - and this negates the Z-displacement. When I tested again without the move, it does work as expected. So my confusion is of my own making!

Yep, they are used temporarily to prevent the group from getting garbage collected.

No problem. I did the same thing, … did one test, and made an incorrect assumption. Should have tested a bit more. (I removed the mistaken part of my previous post so as not to lead future readers astray.