RhinoScript: Editing Individual Leader Properties

Is it possible, to say, edit a single leader’s arrowhead. None of the documentation seems to indicate it’s possible. But it seems like it shouldn’t be that hard considering RhinoScript seems to handle much more complicated tasks well.

In a nutshell, I’m trying to: Create a Leader (solved) and then have the script change the leader type property (which is otherwise done manually).

I thought about creating multiple annotation styles just with different leader arrowheads, but since I have to create a separate annotation style for each scale…

Hi,
Here’s a sample script where you select a leader and change it’s arrow.

import rhinoscriptsyntax as rs
from scriptcontext import doc
from Rhino.DocObjects import DimensionStyle

id = rs.GetObject()
o = doc.Objects.FindId(id)
ldr = o.Geometry
ldr.LeaderArrowType = DimensionStyle.ArrowType.Dot
o.CommitChanges()

Let me know if that solves the problem.

3 Likes

It WILL solve the problem :slight_smile: , once I dive into PythonScript a little deeper. . I’m actually using VBScript and will eventually use C# once I get up to speed in the language. I can see that it won’t take long to get a handle on PythonScript (at least for this one-off task) so I might go that route.

I was going to post my VB Script but “lost” it somehow. I’ll post what I come up with sometime either on the weekend or next week.

Thank’s a bunch!!

hi @keithscadservices ,

What Alain did with Python (actually RhinoCommon via Python) is not possible in RhinoScript directly.
However it’s possible to use the code and run it inside RhinoScript (with some modifications) - i had to resort to it many times before to keep the old RhinoScripts up to date without a need to rewrite the whole thing.
Here is a sample of how to make it work:
ChangeLeadersStyle.rvb (1.5 KB)

hth,

–jarek

2 Likes

That is slick! Also learned how to do a few other things I didn’t want to ask about (to avoid spamming the forum) in order to decipher what was going on.

thanks a ton for your help!!

The best way to learn is to ask, I can try to help with RhinoScript part. Btw, the forum has its share of spam and still doing fine ; )

In case other’s are following I decided to post what I have so far. Note the line to change the layer. I decided to go with PythonScript in spite of barely knowing how to code with it (it’s relatively quick to learn). To be honest I barely understand how your code snippet works. When I changed the variable names (“id” in particular) I couldn’t get it to run. Left it as-is (other than plugging-in the newly created leader) and works like a charm. Now I just have to read into the object model a little further; I have no idea what the actual names of the arrows are (changing “Dot” to “Arrow” doesn’t work) among other things (yes the code is pretty knarly looking).

import rhinoscriptsyntax as rs
from scriptcontext import doc
from Rhino.DocObjects import DimensionStyle

def leaderWithDot():

    rs.Prompt("\nSelect Leader Points")
    pointArray = rs.GetPoints(True)

    leaderObject = rs.AddLeader(pointArray)

    if leaderObject:
    
     rs.ObjectLayer(leaderObject, "#-ANNO") #WARNING - NO ERROR CATCHING IF LAYER DOESN'T EXIST
     id = leaderObject
     o = doc.Objects.FindId(id)
     ldr = o.Geometry
     ldr.LeaderArrowType = DimensionStyle.ArrowType.Dot
     o.CommitChanges()

if __name__ == '__main__':
   leaderWithDot()
1 Like