Enforce Revit to perform potable command before doing the rest of my code!

Enforce Revit to perform potable command before doing the rest of my code!

IbrahimNaeem
Advocate Advocate
756 Views
5 Replies
Message 1 of 6

Enforce Revit to perform potable command before doing the rest of my code!

IbrahimNaeem
Advocate
Advocate

Hi,

I have a problem with implementing two postable commands in the same external command, Actually I have two problems:

1- I have implemented two external events to perform the two postable commands, only one of them is working and postponed till the end of the code lines"I know why" but is there a way to enforce Revit not to postpone the postable command ?

 

2- The two commands are "CutToClipboard", which working fine and the other one is "PasteFromClipboard" which isn't working. Are there Postable Commands which not doable yet? 

 

Thanks, Ibrahim Naeem 

0 Likes
757 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Ibrahim Naeem,

 

Afaik, you can only post one command.

 

If you want more than that, things will probably start to get tricky.

 

Maybe there is an easier and more robust way to achieve what you are after?

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 6

IbrahimNaeem
Advocate
Advocate

Hi Jeremy, 

Thank you for replying on these questions, Actually I need to cut some elements to clipboard and then paste it back and in between I'd like to do some commands. Yes, I got another solution that has been posted on your blog "the building coder" to do a transaction group and roll back afterwords so thank you also for keeping post these solutions, your blog is really a great source.

 

My question now, even if I need to do a postable command, can I force Revit not to postpone it till the end?

 

Thanks, Ibrahim Naeem  

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Dear Ibrahim,

 

Thank you for your appreciation. Glad it helped.

 

Nope, sorry, no way.

 

Cheers,

 

Jeremy



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

Message 5 of 6

BobbyC.Jones
Advocate
Advocate

Hello Ibrahim,

I do not know of a way to postpone a posted command, but have some other thoughts.  

 

  1. Have you seen the ElementTransformUtils.CopyElements() method?  If that will not suffice then,
  2. Chaining multiple PostCommands together scares me but, a while back I created a PostableCommandBase helper class to help me run code after a posted command completed.  Perhaps you could use it to get the results you need,  http://forums.autodesk.com/t5/revit-api-forum/a-question-about-suppressing-warning-messages-in-revit...
--
Bobby C. Jones
0 Likes
Message 6 of 6

Anonymous
Not applicable
There is an event in the AdWindows.dll that you can use that fires directly after a command has posted.
So you can basically post one command, and then listen to the event and then fire the other after the first is completed.
This is the event:
Autodesk.Windows.ComponentManager.ItemExecuted
There is a blogpost about on Jeremys blog:
http://thebuildingcoder.typepad.com/blog/2015/02/automation-ribbon-panel-itemexecuted-and-vacation.h...
0 Likes