Problem with references in revit api C# visual studio

Problem with references in revit api C# visual studio

marcintromski
Contributor Contributor
723 Views
5 Replies
Message 1 of 6

Problem with references in revit api C# visual studio

marcintromski
Contributor
Contributor

Hi, Im new to Revit API. I have done some tutorials. but yesterday I got many errors. I googled it but I havent found any solutions. Please help me to resolve this problem. I attach printscreen.

Bez nazwy.jpg

0 Likes
Accepted solutions (1)
724 Views
5 Replies
Replies (5)
Message 2 of 6

marcintromski
Contributor
Contributor

when i change UIApplication, UIDocument, Application and Document to: Autodesk.Revit.UI.UIApplication uiapp = commandData.Application;

Autodesk.Revit.UI.UIDocument uidoc = uiapp.ActiveUIDocument;

Application app = uiapp.Application;

Document doc = uidoc.Document;

there is no error, whats wrong with my code? Later Selection and Element are not found also

0 Likes
Message 3 of 6

nice3point
Advocate
Advocate

can you show your .csproj file?

0 Likes
Message 4 of 6

marcintromski
Contributor
Contributor

.csproj file

0 Likes
Message 5 of 6

nice3point
Advocate
Advocate
Accepted solution

your problem with wrong using directives and wrong namespace matching. In this case you use UIApplication struct instead of Autodesk.Revit.UI.UIApplication.
nice3point_0-1714558909659.png

 

Just use var instead of explicit type specification. This is more handy than writing Autodesk.Revit.UI.UIApplication a = commandData.Application;

nice3point_1-1714559245562.png

 

 

Message 6 of 6

marcintromski
Contributor
Contributor
thank you 🙂
0 Likes