Change Phase Filter and Phase from Phasing in Properties

Anonymous

Change Phase Filter and Phase from Phasing in Properties

Anonymous
Not applicable

Hi I've trying to change the properties "Phase filter" and "Phase" by code, when I'm on Active View with no results

 

I read these posts and others ones:

 

http://thebuildingcoder.typepad.com/blog/2009/03/create-room-on-level-in-phase.html
https://forums.autodesk.com/t5/revit-api-forum/change-phase-of-a-view/m-p/5223335

http://thebuildingcoder.typepad.com/blog/2014/08/setting-the-phase-of-a-view.html

 

I attached an image with the properties what I want to changeforos.PNG programmatically.

 

I have this code:

 

using (ViewCreatorForm viewCreator = new ViewCreatorForm(commandData)) {

                        if (viewCreator.ShowDialog() == System.Windows.Forms.DialogResult.OK) { 

                            List<PhaseFilter> _phFilters = new FilteredElementCollector(doc).OfClass(typeof(PhaseFilter)).Cast<PhaseFilter>().ToList();
                            PhaseFilter filter = _phFilters.Find(p => p.Name.ToUpper() == "Show current phase only".ToUpper());

                            using (Transaction transaction = new Transaction(doc, "Duplicate Views"))
                            {
                                transaction.Start();
                                List<View> views = tools.GetAllViews(doc);
                                List<string> newViewName = new List<string>();
                                string temp = string.Empty;
                                views = views.FindAll(p => p.ViewType == ViewType.ThreeD || p.ViewType == ViewType.FloorPlan);
                                foreach (View view in views)
                                {
                                    temp = string.Empty;
                                    try
                                    {
                                        switch (view.ViewType)
                                        {
                                            case ViewType.ThreeD:
                                            case ViewType.FloorPlan:
                                                
                                                foreach (string phaseName in viewCreator.CheckedPhases)
                                                {
                                                    temp = view.ViewName;
                                                    
                                                    if (temp.Contains(phaseName))
                                                    {
                                                        newViewName.Add(temp);
                                                    }
                                                    else
                                                    {
                                                        newViewName.Add(string.Format("{0} {1}", temp, phaseName));
                                                    }
                                                    view.ViewName = newViewName.Last();
                                                    view.Duplicate(ViewDuplicateOption.WithDetailing);
                                                    view.ViewName = temp;

/////////// I'd like to add your help in here ///////////

                                                }
                                                break;
                                        }
                                    }
                                    catch (Exception)
                                    { }
                                }

                                transaction.Commit();
                            }                            
                        }
                    }

Can you help?

 

Regards!

0 Likes
Reply
388 Views
0 Replies
Replies (0)