Hi There…
Anybody help me to get the “Layer Name” of an object and use it in a DOT with a script?
Thx
Hi There…
Anybody help me to get the “Layer Name” of an object and use it in a DOT with a script?
Thx
Does it need to be rhinoscript? (I’m more proficient with python) What’s your end goal?
Thanks. python will be great !!
I want to select an object… It should create a DOT TEXT or Leader (or smiliar) showing the layer name… See attached pic pls. Text in DOTs are the layer names of the object…
okay, Assume you select the object, and then run the script, where should it place the tag? What if the object is on a nested layer?
Actually, there is only 1 object on each layer and the tag would be placed where i click on the object while selecting
just a quick attempt, though you need to select and then pick the insertion point.
tagobject.py (288 Bytes)
To use the Python script use RunPythonScript
, or a macro:
_-RunPythonScript "Full path to py file inside double-quotes"
Hi @yigit and @Gijs
actually this is already possible with PETER’S TOOLS (by Peter Harris).
Have a look here or just search inside PackageManager
as shown here
I use some of Peters Tools almost daily, and the text dot naming is a fantastic little tool
Your are the best Any possibility to write only the sublayer instead of full layer three?
see:
tagobject.py (321 Bytes)
Sorry to bother you… Tried whole weekend but coudnt find any solution…
Any possibility to use the object snap of “_OnPOlySurface” while;
pt = rs.GetPoint(“pick tag location”)
Thank you in advance.
Rg,
hi @yigit see this one, still needs two clicks, but it will constrain to the surface you picked on the (poly)surface
tagobject_onsrf.py (938 Bytes)
Here’s one I wrote a long time ago that works with a single mouse click, and has the text dot inherit the objects colour. Maybe this could help as well.
import rhinoscriptsyntax as rs
def LayerDot():
object = rs.GetObjectEx("Select object to label with a TextDot", 0, True)
if object is None: return
layer = rs.ObjectLayer(object[0])
if layer is None: return
colour = rs.ObjectColor(object[0])
if object[3]:
layerName = layer.split("::")[-1]
if layerName:
dot = rs.AddTextDot(layerName, object[3])
rs.ObjectColor(dot, colour)
rs.ObjectLayer(dot, layer)
if __name__ == "__main__":
LayerDot()
now thats handy to keep the colour of the objects layer, might come in useful for me, forever organising stuff on layers and naming them, and adding text dots in the GA drawings, cheers Dan
edit: @DanBayn is it possible to make this script have the ability to select multiple objects ? It only allows for 1 object at a time (apologies I know nothing about scripting)
Try this:
import rhinoscriptsyntax as rs
def LayerDot():
object = rs.GetObjectsEx("Select objects to label with a TextDot", 0, True)
if object is None: return
for obj in object:
layer = rs.ObjectLayer(obj[0])
if layer is None: return
colour = rs.ObjectColor(obj[0])
if obj[3]:
layerName = layer.split("::")[-1]
if layerName:
dot = rs.AddTextDot(layerName, obj [3])
rs.ObjectColor(dot, colour)
rs.ObjectLayer(dot, layer)
if __name__ == "__main__":
LayerDot()
Just be careful with grouped objects. I didn’t add any code to deal with that. The labels will pile up on your pick point if you use it on grouped objects.
Thanks,
Dan
@DanBayn very handy, much appreciated
Thank you …
I had a few minutes this afternoon to look at that grouping issue, and all you have to do is change the GetObjectEX parameter from True to False. It will then behave correctly with grouped objects.
Try this version. I think it’s a little nicer to use:
import rhinoscriptsyntax as rs
def LayerDot():
while True:
object = rs.GetObjectEx("Select object to label with a TextDot", 0, False )
if object is None: return
layer = rs.ObjectLayer(object[0])
if layer is None: return
colour = rs.ObjectColor(object[0])
if object[3]:
layerName = layer.split("::")[-1]
if layerName:
dot = rs.AddTextDot(layerName, object [3])
rs.ObjectColor(dot, colour)
rs.ObjectLayer(dot, layer)
if __name__ == "__main__":
LayerDot()