<?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: Schedule category in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7284046#M56785</link>
    <description>&lt;P&gt;That was very &amp;nbsp;helpful. I was able to use viewschedule.Definition.CategoryId and compare it with doc.Settings.Categories to get the desired results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Document doc = this.Document;
			ViewSchedule mvs = doc.ActiveView as ViewSchedule;
			
			Category mcat = null;
			
			using (Transaction t = new Transaction(doc, "create Schedule")) 
			{
				t.Start();
				{
					foreach (Category c in doc.Settings.Categories) 
					{
						if (c.Name.ToLower() == "mechanical equipment") 
						{
							mcat = c;
						}
					}
					//is the schedule for Mechanical equipment?					
					if(mvs.Definition.CategoryId==mcat.Id)
					{
						//Schedule Definition
						ScheduleDefinition msd = mvs.Definition;
						//Add parameters to schedule
						ScheduleField mnamefield = msd.AddField(new SchedulableField(ScheduleFieldType.Instance, new ElementId(BuiltInParameter.ALL_MODEL_MARK)));
						
					}&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2017 13:23:00 GMT</pubDate>
    <dc:creator>will.wydock</dc:creator>
    <dc:date>2017-08-08T13:23:00Z</dc:date>
    <item>
      <title>Schedule category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7282743#M56783</link>
      <description>&lt;P&gt;I am currently working on a routine that i would be able to add additional columns to an existing schedule.&amp;nbsp;However, would like to limit the routine to only be able to work on mechanical equipment. I have tried using Viewschedule.Category.Name to try to narrow that down but i don't seem to be getting anywhere with it. Is it possible to retrieve the&amp;nbsp;category information from the schedule?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public void addtoschedule()
		{
			Document doc = this.Document;
			ViewSchedule mvs = doc.ActiveView as ViewSchedule;
			Category mcat = null;
			using (Transaction t = new Transaction(doc, "create Schedule")) 
			{
				t.Start();
				{

					if(mvs.Category.Name.ToLower()=="mechanical equipment")
				{
					ScheduleDefinition msd = mvs.Definition;
					ScheduleField mnamefield = msd.AddField(new SchedulableField(ScheduleFieldType.Instance, new ElementId(BuiltInParameter.ALL_MODEL_MARK)));
				}
				else
				{
					TaskDialog.Show("Warning","The active schedule is not for mechanical equipment.");
					                
				}
							
				t.Commit();
				}
			}&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 00:01:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7282743#M56783</guid>
      <dc:creator>will.wydock</dc:creator>
      <dc:date>2017-08-08T00:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7283691#M56784</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2527511"&gt;@will.wydock&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Well, if the category has any elements, you just get the category of the first element in the viewschedule. Using a new FilteredelementCollector(doc, viewshed.Id).&lt;/P&gt;
&lt;P&gt;If the schedule doesn't have any elements, then viewschedule.Definition.CategoryId is supposed to get the elementId of the category. It showed up as Null in RevitLookup though, so you may want to check it.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 11:16:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7283691#M56784</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-08-08T11:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7284046#M56785</link>
      <description>&lt;P&gt;That was very &amp;nbsp;helpful. I was able to use viewschedule.Definition.CategoryId and compare it with doc.Settings.Categories to get the desired results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Document doc = this.Document;
			ViewSchedule mvs = doc.ActiveView as ViewSchedule;
			
			Category mcat = null;
			
			using (Transaction t = new Transaction(doc, "create Schedule")) 
			{
				t.Start();
				{
					foreach (Category c in doc.Settings.Categories) 
					{
						if (c.Name.ToLower() == "mechanical equipment") 
						{
							mcat = c;
						}
					}
					//is the schedule for Mechanical equipment?					
					if(mvs.Definition.CategoryId==mcat.Id)
					{
						//Schedule Definition
						ScheduleDefinition msd = mvs.Definition;
						//Add parameters to schedule
						ScheduleField mnamefield = msd.AddField(new SchedulableField(ScheduleFieldType.Instance, new ElementId(BuiltInParameter.ALL_MODEL_MARK)));
						
					}&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:23:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7284046#M56785</guid>
      <dc:creator>will.wydock</dc:creator>
      <dc:date>2017-08-08T13:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7284089#M56786</link>
      <description>&lt;P&gt;Or simply:&lt;/P&gt;
&lt;PRE&gt;Public Shared Function GetBuiltinCategory(ByVal categoryId As DB.ElementId) _
     As DB.BuiltInCategory  
  Return DirectCast( _
     [Enum].Parse(GetType(DB.BuiltInCategory), categoryId.IntegerValue), _
     DB.BuiltInCategory)
End Function&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:35:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/schedule-category/m-p/7284089#M56786</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-08-08T13:35:04Z</dc:date>
    </item>
  </channel>
</rss>

