Now I know transferring project standards is a topic that has been discussed on the forum a lot before, and it seems the best way to achieve it is to use the ui.app.PostCommand()
method with the LookupCommandId("ID_TRANSFER_PROJECT_STANDARDS")
. Fine.
The issue I have with this is I have 35+ standard house-type models to manage and I would like the capability of pushing lineweights and material changes out across all of these without having to sit and click the categories to transfer:
Followed by the overwrite button:
Thirty. Five. Times…(let alone sitting and watching it process this).
I realise what I am doing at this point is trying to programmatically dismiss Dialogue boxes, which reminded me of an old post of Konrad’s
Now, of course, it would be easy if I knew C# (which I unfortunately don’t), and my measly attempts to even register the TransferProjectStandards dialogue box event and extract its Id has failed (see code below)
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
Run = IN[0]
DialogueProperties = []
def handle_dialog_box(sender, args):
# Append dialog box properties to the list
dialogue_properties = {
"DialogId": args.DialogId
}
DialogueProperties.append(dialogue_properties)
# Subscribe to the DialogBoxShowing event
uiapp.DialogBoxShowing += handle_dialog_box
if Run:
CmndID = RevitCommandId.LookupCommandId("ID_TRANSFER_PROJECT_STANDARDS")
CmId = CmndID.Id
uiapp.PostCommand(CmndID)
# Wait for the dialog box event to be raised
TransactionManager.Instance.EnsureInTransaction(doc)
TransactionManager.Instance.TransactionTaskDone()
Test = len(DialogueProperties) > 0
else:
Test = False
# Unsubscribe from the DialogBoxShowing event
uiapp.DialogBoxShowing -= handle_dialog_box
# Assign True if the DialogBoxShowing event was triggered, False otherwise
OUT = Test
I was hoping some Python legend might be able to wade in and help point me in the right direction? I would even accept a crushing of dreams so long as I know it isn’t possible somehow haha.
At some point it is probably worth me using a dedicated tool such as Nightrunner, but for now I’d at least like to try and chase the free + learn something route.
Thanks in advance.