<?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: Filter View Schedule by shared parameter &amp;amp; shared parameter in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11594336#M15291</link>
    <description>&lt;P&gt;I'm having a tough time with these schedules. I'm Closer to what I'm looking for though. This is what I have.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                    //Filter the view schedule by Vic_Sequence
                    //Filter the view schedule by Vic_FieldMaterial
                    //Filter the view schedule by Joint
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string Joint = "Joint";
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.Contains, Joint);
                        schedule.Definition.AddFilter(filter);
                        schedule.Definition.AddFilter(new ScheduleFilter(field.FieldId, ScheduleFilterType.Equal,
                            ("Vic_Sequence")));
                        schedule.Definition.AddFilter(new ScheduleFilter(field.FieldId, ScheduleFilterType.Equal,
                            ("Vic_FieldMaterial")));
                    }

                    //Filter the view schedule by Joint
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string Joints = "Joints";
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.Contains, Joints);
                        schedule.Definition.AddFilter(filter);
                    }

                    //Group and sort the view schedule by type
                    if (field.ParameterId == new ElementId(BuiltInParameter.ELEM_TYPE_PARAM))
                    {
                        ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);
                        sortGroupField.ShowHeader = true;
                        schedule.Definition.AddSortGroupField(sortGroupField);
                    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanHilsonN67V6_0-1670015989270.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1147652i4DFBEAB12543234B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanHilsonN67V6_0-1670015989270.png" alt="NathanHilsonN67V6_0-1670015989270.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanHilsonN67V6_1-1670016205716.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1147653i13B763BC1FB6049A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanHilsonN67V6_1-1670016205716.png" alt="NathanHilsonN67V6_1-1670016205716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2022 21:18:57 GMT</pubDate>
    <dc:creator>Nathan.HilsonN67V6</dc:creator>
    <dc:date>2022-12-02T21:18:57Z</dc:date>
    <item>
      <title>Filter View Schedule by shared parameter &amp; shared parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11589088#M15289</link>
      <description>&lt;P&gt;Just started digging into the api for schedules &amp;amp; trying to manipulate the Schedule creation to filter through parameters &amp;amp; shared parameters instead of builtinparameters. I'm guessing a element collector will be the route to go? Here is the code that I am using.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ScheduleCreationUtility:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//
// (C) Copyright 2003-2019 by Autodesk, Inc. All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.

//
// AUTODESK PROVIDES THIS PROGRAM 'AS IS' AND WITH ALL ITS FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Microsoft.Office.Interop.Excel;

namespace ScheduleCreationUT
{
    /// &amp;lt;summary&amp;gt;
    /// Utility class that contains methods of view schedule creation and schedule sheet instance creation.
    /// &amp;lt;/summary&amp;gt;
    class ScheduleCreationUtility
    {
        private static BuiltInParameter[] s_skipParameters = new BuiltInParameter[] { BuiltInParameter.ALL_MODEL_MARK };

        /// &amp;lt;summary&amp;gt;
        /// Create view schedule(s) and add them to sheet.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="uiDocument"&amp;gt;UIdocument of revit file.&amp;lt;/param&amp;gt;
        public void CreateAndAddSchedules(UIDocument uiDocument)
        {
            TransactionGroup tGroup = new TransactionGroup(uiDocument.Document, "Create schedules and sheets");
            tGroup.Start();

            ICollection&amp;lt;ViewSchedule&amp;gt; schedules = CreateSchedules(uiDocument);

            foreach (ViewSchedule schedule in schedules)
            {
                AddScheduleToNewSheet(uiDocument.Document, schedule);
            }

            tGroup.Assimilate();
        }

        /// &amp;lt;summary&amp;gt;
        /// Create a sheet to show the schedule.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="document"&amp;gt;DBDocument of revit file.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="schedule"&amp;gt;View schedule which will be shown on sheet.&amp;lt;/param&amp;gt;
        private void AddScheduleToNewSheet(Document document, ViewSchedule schedule)
        {
            //Create a filter to get all the title block types.
            FilteredElementCollector collector = new FilteredElementCollector(document);
            collector.OfCategory(BuiltInCategory.OST_TitleBlocks);
            collector.WhereElementIsElementType();

            Transaction t = new Transaction(document, "Create and populate sheet");
            t.Start();

            //Get ElementId of first title block type.
            ElementId titleBlockId = collector.FirstElementId();

            //Create sheet by gotten title block type.
            ViewSheet newSheet = ViewSheet.Create(document, titleBlockId);
            newSheet.Name = "Sheet for " + schedule.Name;

            document.Regenerate();

            //Declare a XYZ to be used as the upperLeft point of schedule sheet instance to be created.
            XYZ upperLeft = new XYZ();

            //If there is an existing title block.
            if (titleBlockId != ElementId.InvalidElementId)
            {
                //Find titleblock of the newly created sheet.
                collector = new FilteredElementCollector(document);
                collector.OfCategory(BuiltInCategory.OST_TitleBlocks);
                collector.OwnedByView(newSheet.Id);
                Element titleBlock = collector.FirstElement();

                //Get bounding box of the title block.
                BoundingBoxXYZ bbox = titleBlock.get_BoundingBox(newSheet);

                //Get upperLeft point of the bounding box.
                upperLeft = new XYZ(bbox.Min.X, bbox.Max.Y, bbox.Min.Z);
                //Move the point to the postion that is 2 inches right and 2 inches down from the original upperLeft point.
                upperLeft = upperLeft + new XYZ(2.0 / 12.0, -2.0 / 12.0, 0);
            }

            //Create a new schedule sheet instance that makes the sheet to show the data of wall view schedule at upperLeft point.
            ScheduleSheetInstance placedInstance = ScheduleSheetInstance.Create(document, newSheet.Id, schedule.Id, upperLeft);

            t.Commit();
        }

        public string GetParamValueByGuid(Guid guid, Element e)
        {
            var paramValue = string.Empty;

            foreach (Autodesk.Revit.DB.Parameter parameter in e.Parameters)
            {
                if (parameter.IsShared)
                {
                    if (parameter.GUID == guid)
                    {
                        paramValue = parameter.AsString();
                    }
                }
            }

            return paramValue;
        }


        /// &amp;lt;summary&amp;gt;
        /// Create a view schedule of wall category and add schedule field, filter and sorting/grouping field to it.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="uiDocument"&amp;gt;UIdocument of revit file.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;ICollection of created view schedule(s).&amp;lt;/returns&amp;gt;
        private ICollection&amp;lt;ViewSchedule&amp;gt; CreateSchedules(UIDocument uiDocument)
        {

            Document document = uiDocument.Document;

            Transaction t = new Transaction(document, "Create Schedules");
            t.Start();

            List&amp;lt;ViewSchedule&amp;gt; schedules = new List&amp;lt;ViewSchedule&amp;gt;();

            //Create an empty view schedule of Fabrication Pipe category.
            ViewSchedule schedule = ViewSchedule.CreateSchedule(document, new ElementId(BuiltInCategory.OST_FabricationPipework), ElementId.InvalidElementId);
            schedule.Name = "BOM";
            schedules.Add(schedule);


            //Iterate all the schedulable field gotten from the Fabrication Pipe view schedule.
            foreach (SchedulableField schedulableField in schedule.Definition.GetSchedulableFields())
            {

                //Judge if the FieldType is ScheduleFieldType.Instance.
                if (schedulableField.FieldType == ScheduleFieldType.Instance)
                {
                    //Get ParameterId of SchedulableField.
                    ElementId parameterId = schedulableField.ParameterId;

                    //If the ParameterId is id of BuiltInParameter.ALL_MODEL_MARK then ignore next operation.
                    if (ShouldSkip(parameterId))
                        continue;

                    //Add a new schedule field to the view schedule by using the SchedulableField as argument of AddField method of Autodesk.Revit.DB.ScheduleDefinition class.
                    ScheduleField field = schedule.Definition.AddField(schedulableField);

                    //Judge if the parameterId is a BuiltInParameter.
                    if (Enum.IsDefined(typeof(BuiltInParameter), parameterId.IntegerValue))
                    {
                        BuiltInParameter bip = (BuiltInParameter)parameterId.IntegerValue;
                        //Get the StorageType of BuiltInParameter.
                        StorageType st = document.get_TypeOfStorage(bip);
                        //if StorageType is String or ElementId, set GridColumnWidth of schedule field to three times of current GridColumnWidth. 
                        //And set HorizontalAlignment property to left.
                        if (st == StorageType.String || st == StorageType.ElementId)
                        {
                            field.GridColumnWidth = 3 * field.GridColumnWidth;
                            field.HorizontalAlignment = ScheduleHorizontalAlignment.Left;
                        }
                        //For other StorageTypes, set HorizontalAlignment property to center.
                        else
                        {
                            field.HorizontalAlignment = ScheduleHorizontalAlignment.Center;
                        }
                    }


                    //Filter the view schedule by volume
                    if (field.ParameterId == new ElementId(BuiltInParameter.HOST_VOLUME_COMPUTED))
                    {
                        double volumeFilterInCubicFt = 0.8 * Math.Pow(3.2808399, 3.0);
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.GreaterThan, volumeFilterInCubicFt);
                        schedule.Definition.AddFilter(filter);
                    }

                    //Filter the view schedule by Product Long Description Joint
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string JointFilterFabPipe = "Joint" ;
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.NotContains, JointFilterFabPipe);
                        schedule.Definition.AddFilter(filter);
                    }

                    //Filter the view schedule by Product Long Description Joints
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string JointFilterFabPipe = "Joints";
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.NotContains, JointFilterFabPipe);
                        schedule.Definition.AddFilter(filter);
                    }

                    //Filter the view schedule by Vic_Sequence


                    //Group and sort the view schedule by WORKSET
                    if (field.ParameterId == new ElementId(BuiltInParameter.ELEM_PARTITION_PARAM))
                    {
                        ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);
                        sortGroupField.ShowHeader = true;
                        schedule.Definition.AddSortGroupField(sortGroupField);
                    }


                    //Group and sort the view schedule by Product Long Description           
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);
                        sortGroupField.ShowHeader = false;
                        schedule.Definition.AddSortGroupField(sortGroupField);
                    }

                    //Group and sort the view schedule by Product Size Description           
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_SIZE_DESCRIPTION))
                    {
                        ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);
                        sortGroupField.ShowHeader = false;
                        schedule.Definition.AddSortGroupField(sortGroupField);
                    }

                }

            }


            t.Commit();

            uiDocument.ActiveView = schedule;

            return schedules;
        }

        /// &amp;lt;summary&amp;gt;
        /// Judge if the parameterId should be skipped.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="parameterId"&amp;gt;ParameterId to be judged.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Return true if parameterId should be skipped.&amp;lt;/returns&amp;gt;
        private bool ShouldSkip(ElementId parameterId)
        {
            foreach (BuiltInParameter bip in s_skipParameters)
            {
                if (new ElementId(bip) == parameterId)
                    return true;
            }
            return false;
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ScheduleCreationCommand:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

using System;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;

using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ScheduleCreationUT;

namespace ScheduleCreationC
{
    /// &amp;lt;summary&amp;gt;
    /// Implements the Revit add-in interface IExternalCommand
    /// &amp;lt;/summary&amp;gt;
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
    public class ScheduleCreationCommand : IExternalCommand
    {
        /// &amp;lt;summary&amp;gt;
        /// Implement this method as an external command for Revit.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="commandData"&amp;gt;An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="message"&amp;gt;A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="elements"&amp;gt;A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.&amp;lt;/returns&amp;gt;
        public virtual Result Execute(ExternalCommandData commandData
            , ref string message, ElementSet elements)
        {
            try
            {
                UIDocument uiDocument = commandData.Application.ActiveUIDocument;

                ScheduleCreationUtility utility = new ScheduleCreationUtility();
                utility.CreateAndAddSchedules(uiDocument);

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }
    }
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help/guidance would be greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 20:57:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11589088#M15289</guid>
      <dc:creator>Nathan.HilsonN67V6</dc:creator>
      <dc:date>2022-11-30T20:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filter View Schedule by shared parameter &amp; shared parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11589184#M15290</link>
      <description>&lt;P&gt;There is far too much code to understand specifically what you are interested in I can only guess from your description that you want the SharedParameter version of this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could filter for ParameterElements/SharedParameterElements in the usual way and match against:&lt;/P&gt;&lt;P&gt;SharedParameterElement.GuidValue (for shared parameters)&lt;BR /&gt;ParameterElement.Name (for non-shared project parameters)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those matching items then have an Id property because they are derived from elements.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 21:41:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11589184#M15290</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2022-11-30T21:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Filter View Schedule by shared parameter &amp; shared parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11594336#M15291</link>
      <description>&lt;P&gt;I'm having a tough time with these schedules. I'm Closer to what I'm looking for though. This is what I have.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                    //Filter the view schedule by Vic_Sequence
                    //Filter the view schedule by Vic_FieldMaterial
                    //Filter the view schedule by Joint
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string Joint = "Joint";
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.Contains, Joint);
                        schedule.Definition.AddFilter(filter);
                        schedule.Definition.AddFilter(new ScheduleFilter(field.FieldId, ScheduleFilterType.Equal,
                            ("Vic_Sequence")));
                        schedule.Definition.AddFilter(new ScheduleFilter(field.FieldId, ScheduleFilterType.Equal,
                            ("Vic_FieldMaterial")));
                    }

                    //Filter the view schedule by Joint
                    if (field.ParameterId == new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION))
                    {
                        string Joints = "Joints";
                        ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.Contains, Joints);
                        schedule.Definition.AddFilter(filter);
                    }

                    //Group and sort the view schedule by type
                    if (field.ParameterId == new ElementId(BuiltInParameter.ELEM_TYPE_PARAM))
                    {
                        ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);
                        sortGroupField.ShowHeader = true;
                        schedule.Definition.AddSortGroupField(sortGroupField);
                    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanHilsonN67V6_0-1670015989270.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1147652i4DFBEAB12543234B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanHilsonN67V6_0-1670015989270.png" alt="NathanHilsonN67V6_0-1670015989270.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanHilsonN67V6_1-1670016205716.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1147653i13B763BC1FB6049A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanHilsonN67V6_1-1670016205716.png" alt="NathanHilsonN67V6_1-1670016205716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 21:18:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11594336#M15291</guid>
      <dc:creator>Nathan.HilsonN67V6</dc:creator>
      <dc:date>2022-12-02T21:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Filter View Schedule by shared parameter &amp; shared parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11594692#M15292</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For existing schedule, you can compare ScheduleField.ParameterId via&lt;/P&gt;&lt;P&gt;ScheduleDefinition.GetFieldOrder &amp;amp;&amp;nbsp;ScheduleDefinition.GetField(ScheduleFieldId) to get the fields to add filters i.e. no need to iterate other than via Linq.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; public Result Obj_221203a(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, 
                                                                    Autodesk.Revit.DB.ElementSet elements)
        {
            UIApplication UIApp = commandData.Application;
            UIDocument UIDoc = commandData.Application.ActiveUIDocument;
            if (UIDoc == null)
                return Result.Cancelled;
            Document IntDoc = UIDoc.Document;

            ElementId LongDescParamId = new ElementId(BuiltInParameter.FABRICATION_PRODUCT_DATA_LONG_DESCRIPTION);

            FilteredElementCollector FEC = new FilteredElementCollector(IntDoc);
            ParameterElement PE0 = FEC.OfClass(typeof(ParameterElement))
                        .OfType&amp;lt;ParameterElement&amp;gt;().Where(k =&amp;gt; k.Name == "Supplier").FirstOrDefault();

            ParameterElement PE1 = FEC.OfClass(typeof(ParameterElement))
                        .OfType&amp;lt;ParameterElement&amp;gt;().Where(k =&amp;gt; k.Name == "Vic_Sequence").FirstOrDefault();

            //if Supplier etc.is SP then filter for SharedParameterElement with GuidValue

            ElementId SupplierParamId = PE0.Id;
            ElementId VicSequenceParamId = PE1.Id;

            using (Transaction tx = new Transaction(IntDoc, "Create schedule"))
            {

                if (tx.Start() == TransactionStatus.Started)
                {
                    ViewSchedule VS = ViewSchedule.CreateSchedule(IntDoc, 
                                    new ElementId(BuiltInCategory.OST_FabricationPipework),
                                    ElementId.InvalidElementId);
                    VS.Name = "BOM";

                    IList&amp;lt;SchedulableField&amp;gt; SFields = VS.Definition.GetSchedulableFields();
                    SchedulableField ScLongDesc = SFields.FirstOrDefault(k =&amp;gt; k.ParameterId == LongDescParamId);
                    SchedulableField ScSupplier = SFields.FirstOrDefault(k =&amp;gt; k.ParameterId == SupplierParamId);
                    SchedulableField ScVicSequence = SFields.FirstOrDefault(k =&amp;gt; k.ParameterId == VicSequenceParamId);

                    ScheduleField SF0 = VS.Definition.AddField(ScSupplier);
                    ScheduleField SF1 = VS.Definition.AddField(ScVicSequence);
                    ScheduleField SF2 = VS.Definition.AddField(ScLongDesc);

                    VS.Definition.AddFilter(new ScheduleFilter(SF0.FieldId, ScheduleFilterType.HasValue));
                    VS.Definition.AddFilter(new ScheduleFilter(SF1.FieldId, ScheduleFilterType.Contains, ""));
                    VS.Definition.AddFilter(new ScheduleFilter(SF2.FieldId, ScheduleFilterType.NotContains, "Joint"));
                    VS.Definition.AddFilter(new ScheduleFilter(SF2.FieldId, ScheduleFilterType.NotContains, "Joints"));

                    tx.Commit();
                }
            }
            return Result.Succeeded;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 02:33:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-view-schedule-by-shared-parameter-amp-shared-parameter/m-p/11594692#M15292</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2022-12-03T02:33:38Z</dc:date>
    </item>
  </channel>
</rss>

