Is it possible to change the arrow type for leaders using Rhinoscriptsyntax or rhinocommon? Here’s what I have so far.
import rhinoscriptsyntax as rs
import Rhino
def LeaderArrowType():
leaders = rs.GetObjects(“Choose leaders to change”, rs.filter.annotation, preselect=True)
if not leaders: return
for leader in leaders:
leader = rs.coercerhinoobject(leader)
arrowStyle = Rhino.DocObjects.DimensionStyle.ArrowType.Dot
leader.Geometry.LeaderArrowType = arrowStyle
LeaderArrowType()
This doesn’t seem to be working. I’m guessing that “leader.Geometry.LeaderArrowType” can on get the arrow type, not set it?
Thanks All 
Hi, does this discussion help?
Are you using version 5 or 6? Windows or mac?
Seems it makes a difference
Windows version 6.
That thread seems to be about altering dimstyles rather than overriding a particular instance.
I was thinking I could delete the leader and create a new one from scratch, but
Rhino.Geometry.Leader.Create(text, Plane, dimstyle, points)
Doesn’t set the arrow type on creation, so it would be the same issue with overriding a particular instance as before.
I think that I first need to create an overiding dimension style:
overideStyle = Rhino.DocObjects.DimensionStyle()
then change the properties of the instance to change:
leader.Geometry.SetOverrideDimStyle(overideStyle)
I don’t yet know how to modify the overideStyle dimension style to have a different arrow type though…
Hi @Alasdair, may below helps, works in Rhino 6:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
def DoSomething():
leader_id = rs.GetObject("Select leader", rs.filter.annotation, True, False)
if not leader_id: return
leader_obj = rs.coercerhinoobject(leader_id, True, True)
if not isinstance(leader_obj, Rhino.DocObjects.LeaderObject): return
new_style = Rhino.DocObjects.DimensionStyle()
new_style.LeaderArrowType = Rhino.DocObjects.DimensionStyle.ArrowType.Dot
leader_obj.Geometry.SetOverrideDimStyle(new_style)
leader_obj.CommitChanges()
DoSomething()
_
c.
3 Likes
Yep that does the job! Thanks
Do you know if there’s a way to access/modify horizontal justification of a leader in python (R6)?
Hi @Asterisk, you might try below code in above example which creates an override, or use it in your dimension style:
h_align = Rhino.DocObjects.TextHorizontalAlignment.Right
new_style.LeaderTextHorizontalAlignment = h_align
_
c.
2 Likes
Thanks! This works.
Ldr = rs.coercerhinoobject(Ldr_GUID, True, True)
Ldr.LeaderGeometry.LeaderTextHorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Right
Ldr.CommitChanges()
Is there any other way to create “Rhino.DocObjects.TextHorizontalAlignment.Right” variable?
1 Like
Hi @Asterisk, i don’t think so, it seems to be RhinoCommon only.
_
c.