Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't get phases

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
sabatierae
487 Views, 9 Replies

Can't get phases

Hi

I want to get the list of all my phases but I don't know how to..

I've tried to do what they explain here : http://revitapisearch.com/

But it doesn't work..

That's my code :

code.png

 

And that's the error message in Revit when I run my app:

 

error.png

 

Any ideas plz?

 

Thank!!

Tags (2)
9 REPLIES 9
Message 2 of 10
peterjegan
in reply to: sabatierae

Your app is running the "NotImplementedException" and ignoring your "void Getinfo_Phase"

 

Try:

 

public class Class1 : IExternalCommand
{
		public Autodesk.Revit.UI.Result Execute(
			ExternalCommandData commandData,
			ref string message,
			ElementSet elements)
		{
Document doc = commandData.Application.ActiveUIDocument.Document;

PhaseArray.......

...your code....

.Show("Revit", prompt);

 And get rid of the "NotImplementedException" block.

Message 3 of 10
sabatierae
in reply to: peterjegan

It doesn't work..

using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;


namespace CreerVuesPourLePhasage
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class Class1 : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;
            PhaseArray phase = doc.Phases;
            {
                String list = null;
                if (0 != phase.Size)
                {
                    list = "Phases are";
                    foreach (Phase ii in phase)
                    {
                        list += "\n\t" + ii.Name;
                    }
                }
                else
                {
                    list = "No phases available";
                }
                TaskDialog.Show("Revit", list);
            }
        }
    }
}       

 It doesn't work because of the Execute()

and the error returns by visual studio is something like that (sorry for the translation I have visual studio in french..) :

 


'CreerVuesPourLePhasage.Class1.Execute(Autodesk.Revit.UI.ExternalCommandData, ref string, Autodesk.Revit.DB.ElementSet)' : all code paths don't return a value necessarily



Message 4 of 10
peterjegan
in reply to: sabatierae

Try: TaskDialog.Show("Revit", list); } return Result.Succeeded; } } }
Message 5 of 10
peterjegan
in reply to: peterjegan

That was ugly. I hope this is better: TaskDialog.Show("Revit", list); } return Result.Succeeded; } } }
Message 6 of 10
peterjegan
in reply to: peterjegan

} TaskDialog.Show("Revit", list); } return Resut.Succeeded; } } }
Message 7 of 10
peterjegan
in reply to: peterjegan

Sorry, I can't get line feeds to work from here. See attached file
Message 8 of 10
peterjegan
in reply to: peterjegan

 
Message 9 of 10
sabatierae
in reply to: peterjegan

The attachment wasn't send to the server..
Message 10 of 10
sabatierae
in reply to: sabatierae

Yeah It works!! thx!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community