Hello,
How can I take an existing dimension and update it’s value text to a new value?
Essentially I just want to update the value of the dimension via a “Get String” prompt without opening the full Edit Dimension dialog.
Here’s my code attempt:
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
def EditDimension(dim_id):
# Get current value of the dimension
value = rs.DimensionText(dim_id)
print("Current Value:", value)
# Prompt the user for a new value
new_value = rs.GetString("Enter new value for dimension", value)
print("New value:", new_value)
# Update the dimension with the new value
if new_value:
# rs.DimensionText(dim_id, new_value)
print("Dimension updated successfully")
rg.Dimension.UpdateDimensionText(dim_id, new_value)
# Select a Dimension
dim_id = rs.GetObject("Select a Dimension", rs.filter.annotation, preselect=True)
if dim_id:
EditDimension(dim_id)
Thank you for your response!
EDIT:
Looks like longer term what I am after is actually just a linear dimension constraint. I saw in a gif that @Joshua_Kennedy posted here as a gif that the user can have a dimension constraint and then update the value and it of course updates the dimension and the object accordingly.
@Joshua_Kennedy are the constraints going to be returning as a Rhino 9 WIP feature?
Thanks for your response!