- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I’m attempting to use the PostCommand to run the FilledRegion command. It gets called from a custom ribbon button. I’m having to get external data from a database prior to posting the command which infleunces the regions parameter values etc. hence the desire to have its own button. The bear bones code for posting the command is shown below:
[Transaction(TransactionMode.Manual)] public class PlaceFilledRegion : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.FilledRegion); bool b = uiapp.CanPostCommand(commandId); // returns true uiapp.PostCommand(commandId); return Result.Succeeded; } }
Nothing actually happens when I click the button. If i debug through the CanPostCommand method returns true and the PostCommand method seems to run with no error. I get the same result on any command that attempts to draw something. If I replace the FilledRegion with the say the Align command however then the Align command gets executed successfully. So the problem seems to be limited to just those commands that create something (i've tried placing Floors, Walls, etc).
The journal does return information that would suggest that there is already some kind of internal transaction running which is preventing the command in question from executing:
Jrn.Command "KeyboardShortcut" , "Create a filled region , ID_OBJECTS_FILLED_REGION"
' 0:< Unnecessary nesting;ArrowUI_4;-1;ID_OBJECTS_FILLED_REGION ;N++EB(NB);
' 4:< FaultyAtomsCheckLog - Comparasion difference found :
' 0:< DBG_INFO: TransactionGroup 17 is being started within existing Transaction 16: line 1347 of d:\ship\2015_px64\source\revit\revitdb\undo\UndoMgr.cpp.
' 0:< <<Begin build CT>>
Is this expected behaviour or have i missed something? Has anyone one else managed to get these "Create" commands to work through the PostCommand method? I'm using 2015 with update 7.
Thanks.
Graham Cook
Solved! Go to Solution.