Suffix for DimCurveLength leaders


#1

Anyone know how to automatically add a suffix (heck, prefix info as well) to DimCurveLength leaders? I want all my curve length annotation to end with ’ perimeter’ or ‘total cutting inches’ or something similar. Right now I’m just hand editing the text boxes.
thanks


(Wim Dekeyser) #2

Not automatically, but at least easier than hand editing all the text boxes: make a copy of your dim style and set a suffix and/or prefix to that one. Then apply this style to all your DimCurveLength dims.


#3

Wim,
dimcurvelength doesn’t seem to be affected by some of the dim settings, certainly not by prefix/suffix (not on my computer anyways). Does this work for you?


(Wim Dekeyser) #4

Sorry about that one, nope, it doesn’t. It’s a leader and therefore doesn’t take those arguments. Good wish, though; leaders with standard text.


#5

Hi Robert,

below is a RhinoScript to create the custom curve length leaders with your favourite prefix and suffix. If you want to ommit prefix or suffix, just empty the text inside the quotes for prefix or suffix. You can add spaces too if necessary as shown below:

Option Explicit
' script to add custom curve length leaders

Call Main()
Sub Main()
	
	Dim res, leader, prefix, suffix, old_text, new_text
	
	' enter your text in the two quotes below
	prefix = "prefix "
	suffix = " suffix"
	
	Rhino.Command "_DimCurveLength"
	If Rhino.LastCommandResult() = 0 Then
		leader = Rhino.LastCreatedObjects(False)(0)
		old_text = Rhino.LeaderText(leader)
		new_text = prefix & old_text & suffix
		Rhino.LeaderText leader, new_text
	End If
	
End Sub

To load and run the script from a button, copy & paste the above script into a text file, save it eg. as CustomCurveLengthLeader.rvb and then run it from a new toolbar button containing this button command:

! _-LoadScript "C:\EnterYourPathHere\CustomCurveLengthLeader.rvb"

Of course you will need to put into the correct path instead of the text i´ve used :smiley:

@stevebaer there seems to be something wrong with me or rs.LeaderText in rhinoscript for python, i was able to get the annotation text from the leader but not to set it. I´ve tried it hard using below python script:

import rhinoscriptsyntax as rs
import scriptcontext

def AddCustomCrvLengthLeader():
    "crv length leader with custom prefix and suffix"

    # enter your favourite text below in quotes
    prefix = "myprefix"
    suffix = "mysuffix"

    result = rs.Command("_DimCurveLength")
    if result:
        last_objs = rs.LastCreatedObjects()
        leader_object = scriptcontext.doc.Objects.Find(last_objs[0])
        if leader_object:
            old_text = leader_object.DisplayText
            new_text = str.join(" ", (prefix,old_text,suffix))
            print old_text
            print new_text
            leader_object.Geometry.Text = new_text
            leader_object.CommitChanges()
            scriptcontext.doc.Views.Redraw()

if __name__ == "__main__":
    AddCustomCrvLengthLeader()

btw, the python example in RhinoCommon did not work for me on leaders dimensioning the curve length. But i´m unshure if it is supposed to work on such objects :wink:

c.


(Steve Baer) #6

Yep, this will be fixed in the next service release


#7

thank you !

c.


#8

Excellent! Thank you Clement.