Dismiss Transfer Project Standards Dialogue box

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:
image

Followed by the overwrite button:
image

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.

Have you considered coding a zero touch node in C#? The developer primer makes it fairly straightforward and once you have that done copy/pasting code and assembling it isn’t any harder for C# than Python… plus things like interface classes work consistently.

2 Likes

zero touch node or python the PostCommand will be launched once the script has been completed, so you need a parallel process that listens to events.

1 Like

I hadn’t actually thought to do that… I’ll put it on the long list and consider it next time I fancy a real challenge haha.

Hmm I see, so it’s somewhat a chicken and egg situation as I need the PostCommand to finish in order for the DialogBoxShowing to register?

Assume this is linked to the API limitation with Transferring Project Standards and that the only current way is to force the UIAPP to generate the window?

So the workflow would need to be:
1 - Trigger UIAPP.PostCommand
2 - Check for DialogueBoxShowing
3 - Dismiss DialogueBox after selecting relevant types to copy