<?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: Create Revit Sheets from Excel in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4853171#M77468</link>
    <description>&lt;P&gt;I would recommend starting with using CSV files and not Excel if you're never done it before. &amp;nbsp;It will be a lot easier to get up and running that way. &amp;nbsp;Here's a sample I cobbled together using some code from the ScheduleCreation SDK sample and some other stuff I've written in the past. &amp;nbsp;Tested it in a macro and it seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;UIDocument uiDoc = this.ActiveUIDocument;
Document doc = uiDoc.Document;
string fileName;
			
System.Windows.Forms.OpenFileDialog openDlg = new System.Windows.Forms.OpenFileDialog();
openDlg.Title = "Select a file";
openDlg.Filter = "Comma Separated Values (*.csv)|*.csv|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openDlg.RestoreDirectory = true;

System.Windows.Forms.DialogResult result = openDlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
  fileName = openDlg.FileName;
  System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
                
  //Create a filter to get all the title block types.
  FilteredElementCollector collector = new FilteredElementCollector(document);
  collector.OfCategory(BuiltInCategory.OST_TitleBlocks);
  collector.WhereElementIsElementType();
				
  //Get ElementId of first title block type.
  ElementId titleBlockId = collector.FirstElementId();
				
  string csvLine = null;
                
  Transaction t = new Transaction(doc, "Create Sheets");
  t.Start();
  while ((csvLine = sr.ReadLine()) != null)
  {
    char[] separator = new char[] { ',' };
    string[] values = csvLine.Split(separator, StringSplitOptions.None);
    
    // Make sure both values are valid
    if(values[0] != null &amp;amp;&amp;amp; values[0].Length &amp;gt; 0 &amp;amp;&amp;amp; values[1] != null &amp;amp;&amp;amp; values[1].Length &amp;gt; 0 )
    {
      ViewSheet sheet = ViewSheet.Create(doc, tbId);
      sheet.Name = values[1];
      sheet.SheetNumber = values[0];
    }
  }
  t.Commit();
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Mar 2014 22:25:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-03-03T22:25:08Z</dc:date>
    <item>
      <title>Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4851911#M77467</link>
      <description>&lt;P&gt;Afternoon All,&lt;/P&gt;&lt;P&gt;I have an Excell document with 2 columns and 20 rows. The left column contains names and the right colum contains numbers.&lt;/P&gt;&lt;P&gt;Is it possible to write a plugin to read the data from the excel file (Name and Number) and then create a sheet for each row of data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there any SDK samples which might assist with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2014 14:56:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4851911#M77467</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-03T14:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4853171#M77468</link>
      <description>&lt;P&gt;I would recommend starting with using CSV files and not Excel if you're never done it before. &amp;nbsp;It will be a lot easier to get up and running that way. &amp;nbsp;Here's a sample I cobbled together using some code from the ScheduleCreation SDK sample and some other stuff I've written in the past. &amp;nbsp;Tested it in a macro and it seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;UIDocument uiDoc = this.ActiveUIDocument;
Document doc = uiDoc.Document;
string fileName;
			
System.Windows.Forms.OpenFileDialog openDlg = new System.Windows.Forms.OpenFileDialog();
openDlg.Title = "Select a file";
openDlg.Filter = "Comma Separated Values (*.csv)|*.csv|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openDlg.RestoreDirectory = true;

System.Windows.Forms.DialogResult result = openDlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
  fileName = openDlg.FileName;
  System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
                
  //Create a filter to get all the title block types.
  FilteredElementCollector collector = new FilteredElementCollector(document);
  collector.OfCategory(BuiltInCategory.OST_TitleBlocks);
  collector.WhereElementIsElementType();
				
  //Get ElementId of first title block type.
  ElementId titleBlockId = collector.FirstElementId();
				
  string csvLine = null;
                
  Transaction t = new Transaction(doc, "Create Sheets");
  t.Start();
  while ((csvLine = sr.ReadLine()) != null)
  {
    char[] separator = new char[] { ',' };
    string[] values = csvLine.Split(separator, StringSplitOptions.None);
    
    // Make sure both values are valid
    if(values[0] != null &amp;amp;&amp;amp; values[0].Length &amp;gt; 0 &amp;amp;&amp;amp; values[1] != null &amp;amp;&amp;amp; values[1].Length &amp;gt; 0 )
    {
      ViewSheet sheet = ViewSheet.Create(doc, tbId);
      sheet.Name = values[1];
      sheet.SheetNumber = values[0];
    }
  }
  t.Commit();
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2014 22:25:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4853171#M77468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-03T22:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4857476#M77469</link>
      <description>&lt;P&gt;Thanks for the reply I will try looking at that SDK sample and using a CSV file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2014 12:38:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4857476#M77469</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-05T12:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4859828#M77470</link>
      <description>&lt;P&gt;Hi miketurpin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you confirm if this is resolved ? Or do you need any further help ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 07:29:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4859828#M77470</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-06T07:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4860080#M77471</link>
      <description>Partha,&lt;BR /&gt;All resolved thanks.&lt;BR /&gt;Have accepted as solution.</description>
      <pubDate>Thu, 06 Mar 2014 10:04:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4860080#M77471</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-03-06T10:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4960476#M77472</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;thanks for the script.&lt;/P&gt;&lt;P&gt;can you please explain step by step&amp;nbsp;that how can i run the script...?i dont know VB.net or C#.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;need to create empty sheets&amp;nbsp;of 500 dwgs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thankyou very much..&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 12:08:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4960476#M77472</guid>
      <dc:creator>karthik_dkk</dc:creator>
      <dc:date>2014-04-15T12:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4964478#M77473</link>
      <description>&lt;P&gt;If you don't know anything about creating macros, you may want to start with the basics of creating a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-071913D8-214A-45AB-A798-A81653E77F88" title="Revit Help" target="_blank"&gt;http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-071913D8-214A-45AB-A798-A81653E77F88&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a lot to cover if you've never done it before, but you should be able to copy/paste the code from above into your macro. &amp;nbsp;I noticed a couple of errors where I wrote the wrong variable name, once writing 'document' instead of the actual variable 'doc', and a second one where i wrote 'tbid' instead of the actual variable named 'titleBlockId'. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll also have to add a reference to System.Windows.Forms under the References section in order for it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="AddReference.png" src="https://forums.autodesk.com/t5/image/serverpage/image-id/93906i562861710B8B9341/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="AddReference.png" align="center" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2014 15:25:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/4964478#M77473</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-16T15:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/5427760#M77474</link>
      <description>&lt;P&gt;might be nice if you closed the if statement, too.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Nov 2014 03:05:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/5427760#M77474</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-29T03:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7385535#M77475</link>
      <description>&lt;P&gt;Could you please explain the process ( step by step ) just general, in visual studio and not in macro?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2017 21:45:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7385535#M77475</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-16T21:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7386674#M77476</link>
      <description>I have not done anything in Revit API for quite some time, sorry.&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Sep 2017 05:28:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7386674#M77476</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-18T05:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7421871#M77477</link>
      <description>&lt;P&gt;Thanks for the code&lt;/P&gt;&lt;P&gt;I wanted to try this code by copy and paste and also added the windows form. but the only error I got is this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Task failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86. You may be able to solve the problem by doing one of the following:&amp;nbsp; 1) Install the Microsoft Windows SDK.&amp;nbsp; 2) Install Visual Studio 2010.&amp;nbsp; 3) Manually set the above registry key to the correct location.&amp;nbsp; 4) Pass the correct location into the "ToolPath" parameter of the task. (MSB3091)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also installed the microsoft&amp;nbsp;windoes&amp;nbsp;SDK, but still I got the same error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Sep 2017 00:34:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/7421871#M77477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-30T00:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create Revit Sheets from Excel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/10106573#M77478</link>
      <description>&lt;P&gt;This code works unless a sheet with the same number already exist. How would you handle that short of editing the the CSV file? How would you skip and resume next? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 22:33:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-revit-sheets-from-excel/m-p/10106573#M77478</guid>
      <dc:creator>J33C316</dc:creator>
      <dc:date>2021-02-23T22:33:28Z</dc:date>
    </item>
  </channel>
</rss>

