Purge/Delete Unused Line Patterns

Hi everyone.

Id like to use this code:

in a pushbutton:
image

But i get this error:

C# Traceback:
Define: REVIT2021;REVIT2021_2 
Reference: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.Emojis.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsFormsIntegration\v4.0_4.0.0.0__31bf3856ad364e35\WindowsFormsIntegration.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.NLog.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\IPY277\pyRevitLoader.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.Common.dll 
Reference: C:\Program Files\Autodesk\Revit 2021\RevitAPIUI.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.PyRevit.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\IPY277\Microsoft.Scripting.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.TargetApps.Revit.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll 
Reference: C:\Program Files\Autodesk\Revit 2021\AdWindows.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\IPY277\Microsoft.Dynamic.dll 
Reference: C:\Program Files\Autodesk\Revit 2021\Xceed.Wpf.AvalonDock.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.PyRevit.Runtime.Shared.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\IPY277\IronPython.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\IPY277\IronPython.Modules.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.CommonWPF.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.MahAppsMetro.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\engines\CPY385\pyRevitLabs.PythonNet.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit-Master\bin\pyRevitLabs.Json.dll 
Reference: C:\Program Files\Autodesk\Revit 2021\RevitAPI.dll 
Reference: C:\Program Files\Autodesk\Revit 2021\UIFramework.dll 
Reference: C:\WINDOWS\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll 
Reference: C:\Users\faust\AppData\Roaming\pyRevit\2021\pyRevit_2021_9ebc3578734d514f_PyRevitLabs.PyRevit.Runtime.dll 
C:\CAD\Revit\Toolbars\KD_Tools\KD_Tools.extension\KD_Tools.tab\Wichtige Tools Addins.panel\Bereinigt nichtgenutzte Linienmuster.pushbutton\script.cs(42,9): error CS1061: 'ThisApplication' does not contain a definition for 'Startup' and no accessible extension method 'Startup' accepting a first argument of type 'ThisApplication' could be found (are you missing a using directive or an assembly reference?) 
C:\CAD\Revit\Toolbars\KD_Tools\KD_Tools.extension\KD_Tools.tab\Wichtige Tools Addins.panel\Bereinigt nichtgenutzte Linienmuster.pushbutton\script.cs(43,9): error CS1061: 'ThisApplication' does not contain a definition for 'Shutdown' and no accessible extension method 'Shutdown' accepting a first argument of type 'ThisApplication' could be found (are you missing a using directive or an assembly reference?) 
C:\CAD\Revit\Toolbars\KD_Tools\KD_Tools.extension\KD_Tools.tab\Wichtige Tools Addins.panel\Bereinigt nichtgenutzte Linienmuster.pushbutton\script.cs(53,27): error CS1061: 'ThisApplication' does not contain a definition for 'ActiveUIDocument' and no accessible extension method 'ActiveUIDocument' accepting a first argument of type 'ThisApplication' could be found (are you missing a using directive or an assembly reference?)

Whats wrong?

With the Macro-Manager everything works like here:

Greets

Hi @Manuel486,
I dont use cs scripts in pyrevit (yet), but the error confim my suspicion that revit macros are not supported in pyrevit.

You have 2 options:

Just out of curiosity, and to help us help you in the most effective way: did you search for possible solutions anywhere prior to posting here? Did you look at the documentation, or you didn’t know it existed, or find it hard to reach it / ge the info from there?