How to change phase of space

How to change phase of space

AnatolyCEL
Enthusiast Enthusiast
3,193 Views
3 Replies
Message 1 of 4

How to change phase of space

AnatolyCEL
Enthusiast
Enthusiast

Hello,

 

Is it possible to change phase (Parameter ROOM_PHASE) of existing space? Or I have to create new space with required phase and copy all parameters from old space?

 

Thanks,

Anatoly.

0 Likes
Accepted solutions (1)
3,194 Views
3 Replies
Replies (3)
Message 2 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

Unfortunetly no. Because the Rooms and Spaces are "Phase Specific" so for each Phase you have to place its own Rooms and Spaces.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 4

AnatolyCEL
Enthusiast
Enthusiast

Hello Mustafa,

 

When I change phase of view through Revit interface and locate new space, the space has that new phase. I need do the same through API: take phase and locate new space for that phase, but Document.NewSpace Method (Level, Phase, UV) create space for "New Construction" phase only, whatever a phase I set.

 

Thanks,

Anatoly.

0 Likes
Message 4 of 4

Mustafa.Salaheldin
Collaborator
Collaborator
Accepted solution

No you can't change the Phase of a Space or Room, it is a read only parameter, you have to create new Space or Room for each Phase.

Please try the following code and mark it as an answer if it satisfies your aim. Open the new view with the new phase and run this addin. This will create a new phase with the same phase as the same view.

Note: You have to specify the UV point in the code so that it is located inside a closed boundary (4 walls for example)

 

 

#region Namespaces

using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;

//using Autodesk.Revit.Collections;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS1
{

    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class PlaceSpaceWithPhase : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;
        
        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }
        
        #endregion

        #region IExternalCommand Members         

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {
                //TODO: add your code below.
                //Reference pickedRef = null;


                //Selection sel = CachedUiApp.ActiveUIDocument.Selection;
                //RebarPickFilter selFilter = new RebarPickFilter();
                //pickedRef = sel.PickObject(ObjectType.Element, selFilter, "Seleccione una Armadura");
                ////Obtener referencia
                //Element el = CachedDoc.GetElement(pickedRef);
                //Rebar myRebar = el as Rebar;
                //List<Curve> lc = myRebar.GetCenterlineCurves(true, true, false).ToList();
                Phase phase = CachedDoc.GetElement(CachedDoc.ActiveView.get_Parameter(BuiltInParameter.VIEW_PHASE).AsElementId()) as Phase;
                Transaction t = new Transaction(CachedDoc, "phase");
                t.Start();
                CachedDoc.Create.NewSpace(CachedDoc.ActiveView.GenLevel, phase, new UV(0, 0));
                t.Commit();
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        #endregion
    }
}


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn