Open revit command in my own toolbar

Hello everybody.

I would like to integrate the plan output/changes command into my own toolbar.
With a script in a pushbutton it would work. But it takes a very, very long time.

Here is the Script:

from pyrevit import revit, UI
doc = revit.doc
Command_ID = UI.RevitCommandId.LookupCommandId(‘ID_SETTINGS_REVISIONS’)
UI.UIApplication(doc.Application).PostCommand(Command_ID)

Is there another way here?

Greets

I have been following your issues as I have been having the same. I have read up about invoke buttons and even tried your method to call on an external dll with no success. I am getting the command ID is null which is filled in. If you get any luck let me know. Thank you

When putting this script in a pushbutton it works fast on my side. No real delay between click and rev table compared to the builtin button

My revit version is 2021.1.8. In which version did you test it?

The same one.
But also in 2024

This is how my files are named and structured.
I dont know whats the problem.
I stopped the time, it takes 28 seconds for the window to open.
Each time the button is pressed. Revit 2021.1.8
In Revit Version 2022.1 its the same problem. In a clear project it takes 26 seconds to open.

image
image


23-06-16_Revit_Pushbutton
image

you could add a timer between each line to see where it takes the most time
Basically doing performance profiling.

Also ou could try with a different command that requires a window to open.

Do you have any particular hook or addins attach to revit? That could slow it down.

What you could also do, is importing Autodesk modules directly. It might be slightly faster.
and doing it with the LookupPostableCommandId


from Autodesk.Revit.UI import UIApplication, RevitCommandId, PostableCommand

doc = __revit__.ActiveUIDocument.Document
uiapp = UIApplication(doc.Application)

Command_ID=RevitCommandId.LookupPostableCommandId(PostableCommand.SheetIssuesOrRevisions)
uiapp.PostCommand(Command_ID)


This is how it works.
I would say it takes about 1-2 seconds longer than using the original revit button.

What is the easiest way to get the name of the revit command, i.e. the PostableCommand?
This?

I use a lot of addins:
ArchilizerTinyTools-1.0.11
AECTechDependentView-2.2
BIM42Align-1.8.0
BIMcollab Installer 1.0 build 16
DiRoots.AppManager_1110
DiRoots.DiStem_0960
DiRoots.One_1310
DiRoots.ProSheets_12180
ModPlusInstaller_v.24.0
pyRevit_4.8.12.22247_signed
TwentyTwoElementSelectorPro-1.0.6
TwentyTwoTransferLegend-1.1.5
TwentyTwoTransferTemplate-1.0.5
XrevFreebiesSetup_2.9.0_x64
BIMinteropTools
ReluxCADforRevit-2022.2.12.0
EF_Tools

Journal file entries are the only way that I know for non-system postable commands

What could the postable command be for this tool:

0:< API_SUCCESS { Added pushbutton Id: 7055, name: Xrev.Freebies.Revit.UpRev.UpRevCommand, text: Up Rev, class: Xrev.Freebies.Revit.UpRev.UpRevCommand, assembly: C:\Program Files\Xrev Freebies\Xrev.Freebies.2021.dll, parentId: CustomCtrl_%Add-Ins%Xrev.Freebies }

Jrn.RibbonEvent “Execute external command:CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand:Xrev.Freebies.Revit.UpRev.UpRevCommand”

Probably this

CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand:Xrev.Freebies.Revit.UpRev.UpRevCommand

from Autodesk.Revit.UI import UIApplication, RevitCommandId, PostableCommand

doc = revit.ActiveUIDocument.Document
uiapp = UIApplication(doc.Application)

Command_ID=RevitCommandId.LookupPostableCommandId(PostableCommand.CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand:Xrev.Freebies.Revit.UpRev.UpRevCommand)
uiapp.PostCommand(Command_ID)

After pushing the button i get this message:
image

This works fine:

from pyrevit import revit, UI
doc = revit.doc
Command_ID = UI.RevitCommandId.LookupCommandId(‘CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand’)
UI.UIApplication(doc.Application).PostCommand(Command_ID)

But it takes a long time to open.

See example

This works:

from pyrevit import HOST_APP, UI
uiapp = HOST_APP.uiapp
uiapp.PostCommand(UI.RevitCommandId.LookupCommandId(“CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand”))

But the addin takes 37 seconds to open…

That works as well:

from pyrevit import revit, UI
doc = revit.doc
Command_ID = UI.RevitCommandId.LookupCommandId(‘CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand’)
UI.UIApplication(doc.Application).PostCommand(Command_ID)

But the addin takes 32 seconds to open…

it’s frustrating that there isn’t an easier way to create your own tollbar.
revit needs a function like the quick access toolbox, in its own toolbar.

Update:
I tested this code:

from pyrevit import revit, UI
doc = revit.doc
Command_ID = UI.RevitCommandId.LookupCommandId('CustomCtrl_%CustomCtrl_%Add-Ins%Xrev.Freebies%Xrev.Freebies.Revit.UpRev.UpRevCommand')
UI.UIApplication(doc.Application).PostCommand(Command_ID)

in a script.py in a pushbutton and in Revit 2020 and it opened the tool right away.
Then I saw that ReluxCADforRevit-2023.1.5.0 is not installed in this version. So I uninstalled it everywhere.
Now my button also opens in Revit 2021 and 2022 in a few seconds.
I will write to the manufacturer and see if he can fix the problem.

1 Like

Excellent @Manuel486!

Answer from Relux:
It seems that there is a conflict between pyRevit and ReluxCAD for Revit with one of the additional components used by both. ReluxCAD for Revit uses a newer version of the component than pyRevit, which leads to the problem mentioned.
Since we were planning to get rid of this component anyway, please be patient until we can publish a new version.

1 Like