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
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.
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?
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.
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
@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
c.
Yep, this will be fixed in the next service release
thank you !
c.
Excellent! Thank you Clement.
Is there a way to add a standard suffix for DimArea Annotations as well? Like for example the suffix “m²”, so I don’t have to write it after the value manually
Hi Jascha -
No, there isn’t a way to set that up so that the suffix is automatically added.
I’ve put the request on the list as RH-70008 DimArea: Add units suffix option
For now, if you have to make many of those, you could either use the script that was posted earlier in this thread or make an annotation text with the Area
text field and manually add m²
to that one instance. Then, select that annotation text and run the Testmatchannotationfields
command. That will prompt you to select a different shape and will then add a new annotation text object with the correct data for that different shape.
-wim
Hi @Jaxx, below is a python script which allows to set prefix and suffix for _DimArea
:
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
import scriptcontext
def AddCustomDimAreaLeader():
# enter your favourite text below in quotes
prefix = "A: "
suffix = " m²"
result = rs.Command("_DimArea")
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 = "{0}{1}{2}".format(prefix, old_text, suffix)
leader_object.Geometry.Text = new_text
leader_object.CommitChanges()
scriptcontext.doc.Views.Redraw()
if __name__ == "__main__":
AddCustomDimAreaLeader()
to use only the suffix, change the code so it has only the 2 double quotes for the prefix:
prefix = ""
_
c.
Hi All.
Will bump this topic with a wish to have prefix and suffix parameters for leaders in Dimension styles.
I have a case when I need to have some leaders with text in round brackets. And it could transition to another state without them. So it would be perfect to just have two Dim styles not only for dims but for leaders too.
So usage of scripts is not a convenient way as I think.
And such tune up of Dimension styles will work for many other cases (not only my round brackets).
Hi -
I’ve added your vote to RH-26117 Prefix and suffix for Leader
-wim
I swear I’m not looking for these on purpose but a literal decade since this thread was created and I just ran into it…