PostableCommand issues

PostableCommand issues

flann.mclaughlin
Enthusiast Enthusiast
440 Views
1 Reply
Message 1 of 2

PostableCommand issues

flann.mclaughlin
Enthusiast
Enthusiast

 

The following code creates exceptions in 2018, 2019, and 2020

foreach (var command in (PostableCommand[])Enum.GetValues(typeof(PostableCommand)))
            {
                var commandId = RevitCommandId.LookupPostableCommandId(command);
            }

These are the PostableCommands that fail

 

2018:
PostableCommand.ViewRange

2019:
PostableCommand.PublishDGNToAutodeskBuzzsaw
PostableCommand.PublishDWFToAutodeskBuzzsaw
PostableCommand.PublishDWGToAutodeskBuzzsaw
PostableCommand.PublishDXFToAutodeskBuzzsaw
PostableCommand.PublishSATToAutodeskBuzzsaw
PostableCommand.ViewRange

2020:
PostableCommand.DrawOnFace
PostableCommand.DrawOnWorkPlane
PostableCommand.PublishDGNToAutodeskBuzzsaw
PostableCommand.PublishDWFToAutodeskBuzzsaw
PostableCommand.PublishDWGToAutodeskBuzzsaw
PostableCommand.PublishDXFToAutodeskBuzzsaw
PostableCommand.PublishSATToAutodeskBuzzsaw
PostableCommand.ViewRange

 

Also, the static method RevitCommandId.LookupCommandId returns null for every command

foreach (var command in Enum.GetNames(typeof(PostableCommand)))
            {
                var commandId = RevitCommandId.LookupCommandId(command);
                if (commandId != null)
                    Debugger.Break();  //This line is never reached
            }
0 Likes
441 Views
1 Reply
Reply (1)
Message 2 of 2

bhprest
Advocate
Advocate

I can replicate the exceptions you are getting from the first portion of code that you posted. 

 

  • The exceptions from Revit 2019 and Revit 2020 regarding Buzzsaw makes sense to me, as the  Buzzsaw service is no longer active. It has been replaced by BIM360 docs, and the "Publish" feature has been removed from these versions of Revit. Perhaps @jeremytammik could ask the development team if there are plans to remove these values from the PostableCommand enumeration in the future.
  • I can replicate the exceptions regarding DrawOnFace, DrawOnWorkPlane, and ViewRange, but do not have an explanation to offer you.

 

Regarding the second portion of your post, I believe the null values you are getting are the expected and correct outcome of the code you posted. The RevitCommandId.LookupCommandId() method does not take in the names of PostableCommands, but rather the string values of the names of the internal commands that Revit uses, i.e. the output of the LookupPostableCommandId method, the names of which look like this:

 

ID_CREATE_GUIDE_GRID
ID_CREATE_ASSEMBLY
ID_STAIRS_TRISER_NUMBER
ID_MANAGE_CONNECTION_TO_A_REVIT_SERVER_ACCELERATOR
ID_PHOTO_RENDER_IN_CLOUD
ID_PHOTO_RENDER_GALLERY
ID_ENABLE_ENERGY_ANALYSIS
ID_DISPLACEMENT_CREATE
ID_SETTINGS_ASSEMBLY_CODE
ID_TOGGLE_FABPART_BROWSER
ID_PLAYLIST_DYNAMO

Per the RevitAPI documentation, you can get these string values from Revit Journal files, or, if they pertain to a PostableCommand, you can output them with an augmentation to your own code:

 

foreach (var command in (PostableCommand[])Enum.GetValues(typeof(PostableCommand)))
     {
          var commandId = RevitCommandId.LookupPostableCommandId(command);

          Debug.Log(commandId.Name)
          //or whichever way you prefer to collect and display these names
     }

Hope this helps!