my second day with pyRevit and my first post here.
I hope you can help me!
I wanna create a tab that opens dynamo player. [My goal is to select an element which has stored a specific parameter value and with clicking on “my button” the right dynamo player script will open.] But first i need to find the right way to open dynamo player
I don’t think this is possible simply through python itself. Waybe with the help of a journal file.
I went through the journal file right after running a dyn file from the player and could not find something significatly helpful.
Hi Jean-Marc, do you know why this won’t work in a hook? It works perfectly in pushbuttons, but then the same code won’t work in a doc-changed.py hook saying the uiapp loading is the issue. I’d post the code, but it’s essentially this…
first I would not use the doc-changed hook as you would launch your script every time a tiny thing changes in your model.
the hook I use to show warnings when doc-opened looks like this:
import sys
from pyrevit import HOST_APP, framework
from pyrevit import DB, revit
from pyrevit import forms
# from pyrevit import script
# from os import path
doc = __eventargs__.Document
if not doc.IsFamilyDocument:
I think the trouble is the “eventargs” missing in your hook
I am not 100% hook literate ;p
Great thanks for the quick response! I’ve been bashing around using eventargs but haven’t quite figured out the subtleties between them and hooks yet… Seems I’ve been going about getting doc wrong for a start!
PS it’d be a disaster if the script ran constantly so I’ve an external txt file to check at intervals so the script ignores the intended action unless required.
I tried the code below with doc-changed and could not get it to work, did the same with doc-saving and it worked. I am guessing it has to do with the hook context. one is capable of postablecommand, the other is not in the UIApplication context
from pyrevit import forms
from pyrevit import EXEC_PARAMS
from pyrevit import HOST_APP
import Autodesk
from Autodesk.Revit.UI import RevitCommandId
uiApp=HOST_APP.uiapp
CmndID = RevitCommandId.LookupCommandId('ID_PLAYLIST_DYNAMO')
print(CmndID)
CmId = CmndID.Id
print(CmId)
uiApp.PostCommand(CmId)
Thanks for your help Jean-Marc, I’ve done the same and it works fine with view-activated also. I’ll create a new thread if I continue to have issues! Cheers