Hello, I'm not sure this is the right area to post this or not, but hopefully it is.
I have spent a good deal searching the web for information on how to change the Phasing property labeled "Phase Created" without success, and have come here in hopes to find an answer.

The property is available on all elements to my knowledge, and I need to be able to change that property from "New Construction" to "Existing" via C# code. My goal is to feed the program an item from user selection and be able to see what phase that item is currently set to and then change it if needed. Now I already can feed the program an item and view what phase that item is in with the following code:
Reference RefDemo = uidoc.Selection.PickObject(ObjectType.Element);
Element eDemo = doc.GetElement(RefDemo.ElementId);
Autodesk.Revit.DB.Phase phaseCreated = doc.GetElement(eDemo.CreatedPhaseId) as Phase;
if (phaseCreated.Name != "Existing")
{
// Change phase code here...
}
I have tested this code and it does work for testing the phase of the item, however I cannot find any support API to change the phase. The only API I can find that makes changes to it is the CreatePhaseId property or its mirror version that destroys the PhaseId. With these I have no way to make changes to what the property is set to other then true or false. The closest I got to get it working was with the following code:
phaseCreated.Name = "Existing";
which provided with an error stating that It would not allow user entered variables to change it, which led me to think that there must be a way to access the dropdown options and change the property to an option in that dropdown.

And this is where I am now stuck.
If anyone would be able to provide some guidance on how I can programmatically change the Phase Property please comment, If I am posting this in the wrong area or if you know a better place for me to post this question please also let me know.
In my attempts to get this working I also managed to use this same method to change the Workset property to any given Workset by the text name of that Workset. EX: I want to change a Workset from M_HVAC to M_DEMO, I can do that by entering M_DEMO into the program then select an element to change.
I have spent a good deal searching the web for information on how to change the Phasing property labeled "Phase Created" without success, and have come here in hopes to find an answer.
The property is available on all elements to my knowledge, and I need to be able to change that property from "New Construction" to "Existing" via C# code. My goal is to feed the program an item from user selection and be able to see what phase that item is currently set to and then change it if needed. Now I already can feed the program an item and view what phase that item is in with the following code:
Reference RefDemo = uidoc.Selection.PickObject(ObjectType.Element);
Element eDemo = doc.GetElement(RefDemo.ElementId);
Autodesk.Revit.DB.Phase phaseCreated = doc.GetElement(eDemo.CreatedPhaseId) as Phase;
if (phaseCreated.Name != "Existing")
{
// Change phase code here...
}
I have tested this code and it does work for testing the phase of the item, however I cannot find any support API to change the phase. The only API I can find that makes changes to it is the CreatePhaseId property or its mirror version that destroys the PhaseId. With these I have no way to make changes to what the property is set to other then true or false. The closest I got to get it working was with the following code:
phaseCreated.Name = "Existing";
which provided with an error stating that It would not allow user entered variables to change it, which led me to think that there must be a way to access the dropdown options and change the property to an option in that dropdown.
And this is where I am now stuck.
If anyone would be able to provide some guidance on how I can programmatically change the Phase Property please comment, If I am posting this in the wrong area or if you know a better place for me to post this question please also let me know.
In my attempts to get this working I also managed to use this same method to change the Workset property to any given Workset by the text name of that Workset. EX: I want to change a Workset from M_HVAC to M_DEMO, I can do that by entering M_DEMO into the program then select an element to change.
Comment