How to create a ViewSchedule and change Headiling and Center Fields!

How to create a ViewSchedule and change Headiling and Center Fields!

ricaun
Advisor Advisor
625 Views
0 Replies
Message 1 of 1

How to create a ViewSchedule and change Headiling and Center Fields!

ricaun
Advisor
Advisor

Hello,

 

I'm trying to create a Schedule and add some Fields automatically using API.

 

And I'm having a hard time finding how to change the Field Heading, and when I was writing this post to search for some help I found the parameter... (ScheduleField.ColumnHeading)

 

Long story short I decided to share a code example.

 

public void CreateViewScheduleWindows(Document doc)
        {
            Transaction tran = new Transaction(doc);
            tran.Start("Create schedule");

            ViewSchedule sampleSchedule
              = ViewSchedule.CreateSchedule(doc, new
                ElementId(BuiltInCategory.OST_Windows));

            foreach (ElementId id in
              ViewSchedule.GetAvailableParameters(doc, new
                ElementId(BuiltInCategory.OST_Windows)))
            {
                try
                {
                    ScheduleField sf = sampleSchedule.Definition.AddField(
                        new SchedulableField(ScheduleFieldType.Instance, id));
                    // Change Heading Field
                    sf.ColumnHeading = "Field " + sf.FieldIndex;
                    // Change Alignment Field
                    sf.HorizontalAlignment = ScheduleHorizontalAlignment.Center;
                }
                catch (Exception)
                {
                }
            }
            tran.Commit();
        }

 

ricaun_2-1588791950506.png

 

See yaa!

 

 

 

 

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

626 Views
0 Replies
Replies (0)