Problem to Remove Dim Styles with Python

Hello Guys i hope you can Help me,
i Import Templates with my script and my problem is that i use the Default Dim Style for that.

Here is my Test Code to Remove the Default Dim Style and Import that from my Files.

import rhinoscriptsyntax as rs
rs.AddDimStyle("Dummy")
rs.CurrentDimStyle("Dummy")
rs.DeleteDimStyle("Standard")

And here ist the Error i get from the Debug Console:

Message: 'DimStyleTable' object has no attribute 'DeleteDimensionStyle'

Traceback:
  line 219, in DeleteDimStyle, "C:\Users\PidollA\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\dimension.py"
  line 4, in <module>, "C:\Users\PidollA\AppData\Local\Temp\TempScript.py"

I Hope someone can Help me with this Issue.
Thanks

That actually looks like it might be a bug in rhinoscriptsyntax. For the dimension style table, there is no method DeleteDimensionStyle, only Delete.

Just as a test - does the following code work to delete the dimstyle without an error? If not, please post the error message.

import rhinoscriptsyntax as rs
import scriptcontext as sc

def DeleteDS(style_name):
    ds = sc.doc.DimStyles.FindName(style_name)
    if ds and sc.doc.DimStyles.Delete(ds.Index, True):
        return style_name

rs.AddDimStyle("Dummy")
rs.CurrentDimStyle("Dummy")
DeleteDS("Standard")
1 Like

import rhinoscriptsyntax as rs
import scriptcontext as sc

def DeleteDS(style_name):
ds = sc.doc.DimStyles.FindName(style_name)
if ds and sc.doc.DimStyles.Delete(ds.Index, True):
return style_name

rs.AddDimStyle(“Dummy”)
rs.CurrentDimStyle(“Dummy”)
DeleteDS(“Standard”)

This Works well Thank you for the fast Help :slight_smile:

OK, that means it is indeed a bug in the rhinoscriptsyntax library. Funny nobody has caught it up to now. The definition I wrote is just a corrected copy of rs.DeleteDimstyle. I will file a bug report.
https://mcneel.myjetbrains.com/youtrack/issue/RH-65174

For now you can use the above definition instead of rs.DeleteDimstyle.