DimStyleTable CurrentDimensionStyleIndex fails

Hi @dale, @Alain,

the example python script in the RhinoCommon help gives an error:

Message: ‘TextEntity’ object has no attribute ‘Index’

Apart from that, I used CurrentDimensionStyleIndex in V5 but in V6 i get this error:

Message: ‘DimStyleTable’ object has no attribute ‘CurrentDimensionStyleIndex’

as a replacement i used CurrentDimensionStyle.Index in V6, but it would be preferred if there is the same method which works in V5 and V6.

_
c.

The method DimensionStyleArrowType works in V5 and fails in V6 with this error:

Message: ‘Rhino.DocObjects’ object has no attribute ‘DimensionStyleArrowType’

if i try to replace it with this:

style.ArrowType = Rhino.DocObjects.DimensionStyle.ArrowType.SolidTriangle

i get this error:

Message: attribute ‘ArrowType’ of ‘DimensionStyle’ object is read-only

Trying to use CenterMarkSize, FontIndex, LengthFormat, LeaderArrowType, TextAlignment of a dimension style in V5 worked fine using this:

style.CenterMarkSize = 2.5
style.FontIndex = scriptcontext.doc.Fonts.FindOrCreate("Arial", False, False)
style.LeaderArrowType = Rhino.DocObjects.DimensionStyleArrowType.SolidTriangle
style.LengthFormat = Rhino.DocObjects.DistanceDisplayMode.Decimal
style.TextAlignment = Rhino.DocObjects.TextDisplayAlignment.AboveLine

but fail in V6 with these errors:

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.

_
c.

@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:

grafik

I think the message you get in V5 when doing this was better and should be added:

grafik

_
c.

Hi Clement,

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:

annotation.Index = doc.DimStyles.CurrentDimensionStyleIndex

you’d use:

annotation.DimensionStyleId = doc.DimStyles.CurrentId

Dimensions have changed considerably from v5 to 6

#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.

Hope this helps

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.

_
c.

@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.

@clement,
Would you mind uploading that font file?

I will send you via PM as it is a corporate font.

_
c.

The issue about AddLinearDimension not using the 'Current` annotation style is logged.