Message: ‘DimensionStyle’ object has no attribute ‘CenterMarkSize’
Message: ‘DimensionStyle’ object has no attribute ‘FontIndex’
Message: ‘DimensionStyle’ object has no attribute ‘LeaderArrowType’
Message: ‘DimensionStyle’ object has no attribute ‘LengthFormat’
Message: ‘DimensionStyle’ object has no attribute ‘TextAlignment’
Could you tell me how to set above listed dimension style properties ?
finally CommitChanges() is not found but still listed here a beeign valid.
_
c.
I am sorry, but there are more issues in V6. In V5 and V6 i can set the current dimension style, and this seems to work ok:
if Rhino.RhinoApp.ExeVersion == 5:
if scriptcontext.doc.DimStyles.CurrentDimensionStyleIndex != style_index:
scriptcontext.doc.DimStyles.SetCurrentDimensionStyleIndex(style_index, True)
else:
if scriptcontext.doc.DimStyles.CurrentDimensionStyle.Index != style_index:
scriptcontext.doc.DimStyles.SetCurrent(style_index, True)
When i add a new linear dimension in V5 after this, it uses the current dimension style. But in V6 it always uses the Default dimension style when the dimension is added via code ?
How can i make it use the dimension style which is current ? There is this method to get the dim style from the linear dimension obj, but nothing to set it, which is not required in V5.
@Pascal, when a dimension style is deleted in V6, all dimensions and even text objects using this style are deleted from all layout pages. The user only gets this message before deleting the style in V6:
I think the message you get in V5 when doing this was better and should be added:
If you look at the bottom of the page version info you’ll see CurrentDimensionStyleIndex is only supported in Rhino 5.
In Rhino 6 there’s been a general change to using Id s instead of Index es. Even in areas where there are methods taking or returning indexes it’s better to use ids when available.
So instead of:
#ds.ArrowType
ds.ArrowType1 = Rhino.DocObjects.DimensionStyle.ArrowType.Rectangle
ds.ArrowType2 = Rhino.DocObjects.DimensionStyle.ArrowType.Rectangle
ds.CentermarkSize = 1.0 # lowercase 'm'
#ds.FontIndex #-> Fonts have changed considerably in 6.0 and are still changing for the next SR
ds.LeaderArrowType = Rhino.DocObjects.DimensionStyle.ArrowType.Tick
#ds.LengthFormat #-> major change: formats are not independent of units. DimensionLengthDisplay : Rhino.DocObjects.LengthDisplay enum
#ds.TextAlignment -> TextVerticalAlignment, TextHorizontalAlignment
doc.DimStyles.Modify(ds, ds.Id, True)
The online API docs represent the current version and on the mac that’s 5.x and on windows it’s 6.0 so you have to pay attention to the version info at the bottom of the page. I know that can be confusing.
I’ll look more into why adding a linear dimension doesn’t use the current style.
Thanks @alain, i understand that there are major changes with dimensions and text in V6. My problem is just that i need to make my scripts compatible with R5, R6 and Rhino for Mac.
It is Ok, but it is a lot of work if you have much conditional code to add for every Rhino version and platform.I would prefer not do do this but i did not make that decision to keep V5 in the chain.
This is my biggest roadblock in the moment together with fonts. I have code which adds text objects to the document using a special font. The text is added properly using the custom font, but the Font dropdown is shown empty in properties. If i print the layout page, the custom font is just replaced with Arial.
@Alain, i noticed that what i wrote above also happens when using Rhino’s _Text command. I can add the text object using my custom font (it is a *.otf font file) and the text object is shown with the proper font. But when i select it, the field for “Font” in the dropdown of the object properties is empty. If i re-select the font, then unselect the object and select it again, the field is still empty.
…and if i double click the text object, the font displayed in the dialog drop down is Arial, but the font used for the object is clearly my custom font.
_
c.