architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
494 stars 113 forks source link

predict command number of rps button in ribbon #53

Closed fbe-work closed 7 years ago

fbe-work commented 7 years ago

Is there a way to predict the "Command" number a RPS script ribbon button will be assigned to? If I look it up in the journal file I get something like:

' Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%CustomCtrl_%Add-Ins%RevitPythonShell%rvt_model_services%qc_model:Command0"'

So here the script is listed under Command0. In the RevitPythonShell.xml config file for that program version I find the added script in the list of commands:

<?xml version="1.0" encoding="utf-8"?>
<RevitPythonShell>
  <Commands>
    <Command name="qc_model" src="D:\934_rvt_model_services\commands\qc\rps_qc_model.py" group="rvt_model_services" />
  </Commands>

Is it safe to assume the commands are numbered straight from that list in the same order? (background info: I am writing journal files with python to run qc checks on models in a scheduled manner. (works greate on my machine, but I would like to generalize it if possible, before github release) [-> will be on github rvt_model_services - hopefully soon.]) Thank you!

daren-thomas commented 7 years ago

Yes, that is a safe assumption. The relevant code is RevitPythonShellApplication.GetCommands() and it reads the <Command/> nodes in sequence.

fbe-work commented 7 years ago

Thanks a lot!! So I will start writing something to find my qc buttons via the xml.. (-: