How to use Autodesk.Revit.Creation namespace? (Space creation problem)

How to use Autodesk.Revit.Creation namespace? (Space creation problem)

Anonymous
Not applicable
1,516 Views
2 Replies
Message 1 of 3

How to use Autodesk.Revit.Creation namespace? (Space creation problem)

Anonymous
Not applicable

Hi

I am creating a space using the Document.NewSpace(Level,UV) method in the Autodesk.Revit.Creation namespace.

 

I am strugging with this because it is not the usual format of implementation i am used to since every program i have written uses the  standard

            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

implementation in my External Command.

 

How do I implement the Document class so that I can use. doc.NewSpace(...,...)?

 

Cheers

 

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

arnostlobel
Alumni
Alumni
Accepted solution
Mendo123,

Your puzzlement is totally justified. The creation API is certainly not the best we have in Revit. It is the pattern we used originally when we rolled out the first API. We have been trying to get away from it since then, thus many of the new creation method live on their respective classes (e.g. TextNote.Create).

To answer your question, however, you can get to the Creation object via ether the Revit Application instance, or a Revit Document instance. Chose the one that has the creation methods for the type of objects you need.

Concretely for your example, the code will be either one of the following:

a) uiapp.Application.Create ==> returns an Application-wide creation object
b) uiapp.ActiveUIDocument.Document.Create ==> returns a Document-wide creation object

To make the matter of confusion even worse, the Properties above return instances of classes named Application or Document, respectively; Both are totally different classes than the global Revit Application and Document classes. (I know, it's utterly confusing, and I am very sorry for that!)
Arnošt Löbel
Message 3 of 3

Anonymous
Not applicable

Thanks so much, yes i wouldn't have gotten that without your help.

0 Likes