ActiveUIDocument Warning

ActiveUIDocument Warning

!Dalton_Goodwin!
Advocate Advocate
2,610 Views
4 Replies
Message 1 of 5

ActiveUIDocument Warning

!Dalton_Goodwin!
Advocate
Advocate

Hello all,

 

I have a question on a warning. I am really new at this and I found out that for me to learn was typing out macros from a site I found and if I got any errors then trouble shooting them. I found this issue and went in the API and looked up the code but I didn't have any luck with that. I have attached three pics. I am creating this Macro in SharpDevelop with the C# language.

 

Thank you,

 

DaltonG

0 Likes
2,611 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

The code you're copying appears to be an Application macro, and you're writing a Document macro (based on this ThisDocument name). 

 

You can either change the macro to be an Application macro, or change the code to be for a document macro. Something like this:

UIDocument uidoc = this;
ICollection<ElementId> ids = uidoc.Selection.GetElementIds();
			foreach (ElementId id in ids)
{
//whatever you're doing }

 

0 Likes
Message 3 of 5

!Dalton_Goodwin!
Advocate
Advocate
Thank you mwilson1,

That was the reason. Thank you for the help!

Sent from my iPhone
0 Likes
Message 4 of 5

brudWK2W5
Contributor
Contributor

Hello, guys

 

i would like to use this macro:

Autodesk.Revit.DB.Fabrication.FabricationUtils.ExportToPCF(
                 this.ActiveUIDocument.Document, 
                 this.ActiveUIDocument.Selection.GetElementIds().ToList(), 
                 "C:\\temp\\somefile.pcf");

but i have the same problem with activeUIDocuments. May you also help me? Thank you guys 

0 Likes
Message 5 of 5

dmaral
Enthusiast
Enthusiast
You can use directly var doc = Document;
It will assign current document to your variable.
0 Likes