How to label 3D instances?


Continuing the discussion from Dev to hire for simple script creation?:

Continuing the discussion from Dev to hire for simple script creation?:

Now I’ve found out how to modify Jim’s plugin to add the Z value and PC Name to each cube. How can I add a label to the front face of the cube with the device name? It is stored in an array so I set the name like this = String(@@s[i][3])

inside the instance creation code
for i in 0…@@num_desks do
vec =[i].x,@@s[i].y,@@s[i].z)
trans = Geom::Transformation.translation(vec)
inst = Sketchup.active_model.entities.add_instance(@@compdef,trans)
inst.layer = layer = String(@@s[i][3])


I just woke up and I can see that you’ve been really busy (like one of the Keebler elves) :smile:

Give me a little bit to get some caffeine in me … meanwhile, here’s a line of code I clipped from some of my other code:


IIRC, if you don’t provide a leader, I believe that you get just the text part.


I’ve just “solved” it. It is not as I’d like on the face and tends to orient itself to the camera, so I don’t know if it is too bad. I will test yours, meanwhile I’ve added this line to your code

text = Sketchup.active_model.entities.add_text String(@@s[i][3]), [@@s[i].x+10,@@s[i].y+10,@@s[i].z+25]

What is the last part of your line? The [1,0,0]? I will read it anyways :smile:


You can add it as flat 3d text and glue it to the a point, for clarity I would add it to each face…


Seems better for sure, but how to “glue” it in a spot?

I see the documentation saying this

The add_3d_text is used to create 3D text. It will be added as edges and faces drawn at the origin.

Can the location be changed or how to associate it to a face?