Does not contain a definition for 'Application'

Hi all, I am working with C# in the SharpDevelop Revit Macro Manager.
I am creating some sub routine class outside of ThisDocument for me to call. I am running into an error:
does not contain a definition for ‘Application’ and no extension method…

How can I create a subfunction that calls Revit UIDocument.

Also I just realized I maybe in the wrong forum “I come here by default” so if someone can help me, thanks or point me to the correct forum, also thanks

I have re-posted this question to a more appropriate forum for macro manager and not dynamo.

this refers to your class not the Revit API Document class, and you haven’t declared a property called Application which is why you are seeing that exception. Even if you did have the active document object, the Autodesk.Revit.ApplicationServices.Application which is returned does not contain a property called ActiveUIDocument (its found in Autodesk.Revit.UI.UIApplication) so it will still throw an exception.

Instead, get the active document object (I think the macro template which Revit generates for you contains a variable storing it which you can use) and construct a new UIDocument object if that’s what you need:

var uiDoc = new UIDocument(document);

Thank you

Also thanks for your explanation! Really helpful!

UIDocument uidoc = new ThisDocument();
Document doc = new ThisDocument().Document;