<?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 Re: ApplyTemplate() not working? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3097414#M81593</link>
    <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if I will be able to help you however I have a similar issue. Can you please include the code where you setup the ExportView collection and the dwgExportOptions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2011 01:11:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-07-20T01:11:06Z</dc:date>
    <item>
      <title>ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3095006#M81592</link>
      <description>&lt;P&gt;Hey, I am having a problem with a recursive file export which applies templates to views prior to exporting.&lt;/P&gt;&lt;P&gt;Not exactly certain why it's not working, but the first recursion of the view seems to always export a 12.0kb file with no contents, and for the second view it seems to export the view properly, but not actually apply the template, so each view is identical...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;Autodesk.Revit.DB.ViewSet NewViewSet = new Autodesk.Revit.DB.ViewSet();
            switch (comboBox1.SelectedItem.ToString())
            {
                case "DWG":
                    foreach (Autodesk.Revit.DB.View view in ViewsToExport)
                    {
                        foreach (Autodesk.Revit.DB.View template in Templates)
                        {
                            Application.DoEvents();
                            FileName = textBox2.Text + "_" + textBox3.Text + "_" + "#VWRP#" + "_" + "#TMRP#" + "_" + textBox5.Text + "_" + textBox4.Text;
                            FileName = FileName.Replace("#VWRP#", view.ViewName);
                            FileName = FileName.Replace("#TMRP#", template.ViewName);
                            IList&amp;lt;Autodesk.Revit.DB.ElementId&amp;gt; ExportView = new List&amp;lt;Autodesk.Revit.DB.ElementId&amp;gt;();
                            Autodesk.Revit.DB.View NewView = view;
                            NewView.ApplyTemplate(template);
                            NewViewSet.Insert(NewView);
                            ExportView.Add(NewView.Id);
                            if (ComData.Application.ActiveUIDocument.Document.Export(textBox1.Text, FileName, ExportView, dwgExportOptions))
                            {
                                progressBar1.Value++;
                                continue;
                            }
                            else
                            {
                                MessageBox.Show("Exporting failed on...\nView: " + view.ViewName + "\nTemplate: " + template.ViewName);
                                break;
                            }
                        }
                    }
                    break;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any help or information regarding this method, or why my implementation of it is not working would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Kurt &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2011 15:36:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3095006#M81592</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-18T15:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3097414#M81593</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if I will be able to help you however I have a similar issue. Can you please include the code where you setup the ExportView collection and the dwgExportOptions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 01:11:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3097414#M81593</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-20T01:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3097916#M81594</link>
      <description>&lt;P&gt;Hey David, the ExportView collection actually just consists of one view on each iteration because I don't want to make a viewset consisting of up to possibly 200 views, as this would use a lot of memory. Instead, I iterate through a viewset of views, and a viewset of template views, and create a new view each iteration, settings it's default to the view, and then attempting to apply the template to the view. I then add it to the ExportViews List, and singularly export that one view, rinse and repeat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like I said though, it doesn't seem to be working as I'd hoped. Haha.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Picture included shows the code.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 12:45:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3097916#M81594</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-20T12:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3099324#M81595</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much for the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps with your issue you could try putting the apply template within a transation and commit before exporting the view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2011 03:36:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3099324#M81595</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-21T03:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3099652#M81596</link>
      <description>&lt;P&gt;I actually thought maybe that was the issue earlier as well, but when I tried it, it didn't change my results.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2011 12:13:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3099652#M81596</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-21T12:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3101658#M81597</link>
      <description>&lt;P&gt;Bumping out of desperation. &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 15:07:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3101658#M81597</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-22T15:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3102788#M81598</link>
      <description>&lt;P&gt;Not sure if this solves your issue, but the line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                            Autodesk.Revit.DB.View NewView = view;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doesn't actually create a new view - the 'NewView' variable just gets a reference to the original view object. &amp;nbsp;So, the following line...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                            NewView.ApplyTemplate(template);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is actually applying the template to the original view.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 00:45:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3102788#M81598</guid>
      <dc:creator>MattSiebert</dc:creator>
      <dc:date>2011-07-25T00:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3103234#M81599</link>
      <description>&lt;P&gt;This has helped me solve one minor issue, thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It still however seems to not be applying the actual view template with the method.&lt;/P&gt;&lt;P&gt;Each view exported with different templates applied keeps coming out identically.&lt;/P&gt;&lt;P&gt;In fact, if I make custom templates, and apply them within Revit, it works fine. But, if I apply them through ApplyTemplate(), nothing happens. Here, one picture shows the result of applying the template within Revit, the other picture shows the exported view with the template apparently applied via ApplyTemplate(), though it's clearly not applied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Perhaps I need to apply the template within a transaction?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:27:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3103234#M81599</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-25T13:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: ApplyTemplate() not working?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3103482#M81600</link>
      <description>&lt;P&gt;I have solved my problem, thanks. If anyone runs into this same issue and needs help, send me a message, or an email @ kurt.schempp.9999@gmail.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 15:37:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/applytemplate-not-working/m-p/3103482#M81600</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-25T15:37:25Z</dc:date>
    </item>
  </channel>
</rss>

