<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Revit Duplicating 1000s of Line Styles in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6868396#M60311</link>
    <description>&lt;P&gt;Hi guys - I ran a search but haven't found a solution to this specific problem so here goes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I believe this is a problem I'll need to address through the Revit API -&amp;nbsp;I've tried deleting these line styles using PythonRevitShell, SharpDevelop and Dynamo.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having problems with Revit 2015 duplicating line styles. This is similar to other problems I've read about where Site Designer duplicates line styles (with the prefix 'SW'). This problem seems to have been fixed in Revit 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A highly-detailed write-up of the problem (with images links and previous attempted approaches) can be found here:&amp;nbsp;&lt;BR /&gt;&lt;A href="https://forum.dynamobim.com/t/revit-duplicating-1000s-of-line-styles/9492" target="_blank"&gt;https://forum.dynamobim.com/t/revit-duplicating-1000s-of-line-styles/9492&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any ideas on how to approach deleting these duplicate linestyles I'd love to hear your suggestions!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for reading (and sorry if this isn't in the spirit of the API forum - if it's totally the wrong place please feel free to delete this question)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ollie&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2017 10:16:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-02-10T10:16:35Z</dc:date>
    <item>
      <title>Revit Duplicating 1000s of Line Styles</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6868396#M60311</link>
      <description>&lt;P&gt;Hi guys - I ran a search but haven't found a solution to this specific problem so here goes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I believe this is a problem I'll need to address through the Revit API -&amp;nbsp;I've tried deleting these line styles using PythonRevitShell, SharpDevelop and Dynamo.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having problems with Revit 2015 duplicating line styles. This is similar to other problems I've read about where Site Designer duplicates line styles (with the prefix 'SW'). This problem seems to have been fixed in Revit 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A highly-detailed write-up of the problem (with images links and previous attempted approaches) can be found here:&amp;nbsp;&lt;BR /&gt;&lt;A href="https://forum.dynamobim.com/t/revit-duplicating-1000s-of-line-styles/9492" target="_blank"&gt;https://forum.dynamobim.com/t/revit-duplicating-1000s-of-line-styles/9492&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any ideas on how to approach deleting these duplicate linestyles I'd love to hear your suggestions!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for reading (and sorry if this isn't in the spirit of the API forum - if it's totally the wrong place please feel free to delete this question)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ollie&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 10:16:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6868396#M60311</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-10T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Revit Duplicating 1000s of Line Styles</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6872792#M60312</link>
      <description>&lt;P&gt;The problem are not LineStyles, but subCategories of the following BuiltInCategories:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;OST_GenericAnnotation&lt;/LI&gt;
&lt;LI&gt;OST_DetailComponents&lt;/LI&gt;
&lt;LI&gt;OST_GenericModel&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code will remove all&amp;nbsp;the subCategories with "PTE" in the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]

    public class Remove_PTEDuplicates : IExternalCommand
    {
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            try
            {
                Document doc = revit.Application.ActiveUIDocument.Document;

                List&amp;lt;ElementId&amp;gt; toDelete = new List&amp;lt;ElementId&amp;gt;();
                IList&amp;lt;GraphicsStyle&amp;gt; GraphicStyleList = new FilteredElementCollector(doc)
                .OfClass(typeof(GraphicsStyle))
                .Cast&amp;lt;GraphicsStyle&amp;gt;()
                .ToList();

                foreach (var _g in GraphicStyleList)
                {

                    if (_g.GraphicsStyleCategory.Name.Contains("PTE"))
                    {
                        if (!toDelete.Contains(_g.GraphicsStyleCategory.Id))  toDelete.Add(_g.GraphicsStyleCategory.Id);
                    }
                }
                using (Transaction t = new Transaction(doc, "purge PTEStyles"))
                {
                    t.Start();
                    doc.Delete(toDelete);
                    t.Commit();
                }
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                TaskDialog.Show("catch", ex.ToString());
                return Result.Failed;
            }
        }
    }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 23:42:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6872792#M60312</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-02-12T23:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Revit Duplicating 1000s of Line Styles</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6873390#M60313</link>
      <description>&lt;P&gt;Amazing - thank you fair59!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 09:52:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-duplicating-1000s-of-line-styles/m-p/6873390#M60313</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-13T09:52:54Z</dc:date>
    </item>
  </channel>
</rss>

