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: 

Am I to check ExternalCommandData and its properties before to use them?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Andrey_Bushman
331 Views, 3 Replies

Am I to check ExternalCommandData and its properties before to use them?

Revit 2017.1.1 x64

 

Hi,

 

It is common practice to check the input parameters of the methods. But I see that Revit SDK examples don't do it.

 

Does it mean that the Application and Document instances which are transferred into my external command through the ExternalCommandData instance always will not be null and will be initialized completely? Am I to check ExternalCommandData and its properties before to use them in my external command?

 

Thank you.

Tags (1)
3 REPLIES 3
Message 2 of 4

I wouldn't check the commandData parameter itself, but the current active document is another story.

 

You can use a class that implements IExternalCommandAvailability to do those checks, if you want to leave the Execute method cleaner.

 

Message 3 of 4

Thank you.

 

> but the current active document is another story.

Does it mean that active document can be null or initialized when the external command is invoked?

Message 4 of 4

Dear Andrey,

 

Yes, absolutely.

 

You can run an external command in null document state, aka zero document state.

 

In that case, the current document provided by the external command data argument will obviously be null.

 

If you wish to enable your external application user interface in that state as well, you need to fiddle around a bit to make it usable:

 

http://thebuildingcoder.typepad.com/blog/2011/02/enable-ribbon-items-in-zero-document-state.html

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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