Dissmiss a Revit Dialog

Hello Rhino Inside community,

i am trying to dissmiss a Revit Dialog and I found this link in the website of Dynamobim


The problem is, I have some troubles importing the same libraries, cause there are not being called exactly the same from Rhino.Inside, as far as I know.

Thanks in advance!

Is this Revit 2019?

yes, it is revit 2019, thanks

Yeah, there is something about Revit 2019’s old Python engine cannot load libraries if Dynamo is loaded. I believe @Rickson and @eirannejad have more details on it.

I think it depends on the order of install and would cause the script to totally fail, which i don’t think its doing for you.

the relevant posts
dll conflict

my solution to that particular problem was to delete the dynamo addins.

Hi,

I translated the sample from the forum to be Rhino.Inside like.

# Original code from:
# https://forum.dynamobim.com/t/dismiss-a-revit-dialog-when-exporting-nwc/24990/4

__author__ = "kike.garbo"
__version__ = "2020.09.09"

import clr
import System
from System import EventHandler

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Events import *

# Import RiR
clr.AddReference('RhinoInside.Revit')
from RhinoInside.Revit import Revit

doc = Revit.ActiveDBDocument
uidoc = Revit.ActiveUIDocument
uiapp = uidoc.Application

def dismiss (sender, eventArgs):
	if isinstance(eventArgs, TaskDialogShowingEventArgs):
		eventArgs.OverrideResult(TaskDialogResult.No)
	return

def RemoveFirstChar(text):
	return text[1:]

outViews = []
if path:
	for i in views:
		outViews.append(i)
		Options = Autodesk.Revit.DB.NavisworksExportOptions()
		Options.ConvertElementProperties=True
		Options.ExportScope = NavisworksExportScope.View
		Options.DivideFileIntoLevels =False
		Options.Coordinates=NavisworksCoordinates.Internal
		Options.ViewId = i.Id
		Options.ExportLinks = True
		Options.ExportRoomAsAttribute=False
		Options.ExportRoomGeometry=False
		Options.ExportUrls=False
		dialogEventHandler = EventHandler[DialogBoxShowingEventArgs](dismiss)
		
		uiapp.DialogBoxShowing += dialogEventHandler
		
		doc.Export(path, RemoveFirstChar(i.Name), Options)
		
		uiapp.DialogBoxShowing -= dialogEventHandler
		
	with Transaction(doc, "Export Navisworks") as trans:
	    trans.Start()
	    doc.Regenerate()
	    trans.Commit();

Export-NavisWorks.gh (13.8 KB)

I was unable to really test it on my computer since I don’t have Navisworks installed. Tell me if you have any trouble running the linked script above.

thanks a lot! I test it today and I give a feed back! :slight_smile:

1 Like