Win32 alternative Python


So I would like to automatically export the warnings html from revit, then read it as part of a dynamo graph.

To do this, I need to use a postable command, define a path, then hit Export…

In this c# example, they use Win32 to hit Export…

But that doesn’t ship with our default IronPython2.7, so I’m wondering if there is another way we can do it?

Any thoughts welcome!



P.S I know there are other ways of accessing warnings, but this is what I want to do :smiley:

Have you tried doing something like this?

import clr    

It looks like they’re just accessing the user32.dll, so you should be able to add a reference to the DLL, import the proper namespaces, and go from there.


Will have a look! Thanks :slight_smile:

if installing additional python libraries is an option (I never did that with Dynamo) then there is this thingy called ‘autoit’ and has python bindings:

1 Like

I have used it with selenium for some web automation, if you want to kick start here is some sample code.

It actually does what you need - focuses on window (standard file dialog), fills the file path and then hits a button. You just have to figure out how to find a window handle (can be by window title fortunatelly) and button / edit field names (if they would be different for some reason).
Althoug you might get away even without looking for a handle, as usually if you hit a button window that pops out is active.

handle = “[CLASS:#32770]”
autoit.control_click(handle, “Button1”)


an other way to export/write warnings to html file with GetWarnings() method

import clr
import datetime
import Autodesk
from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

import System
from System.IO import Directory, SearchOption
datenow ='%Y-%m-%d %H:%M:%S')
exportfolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)
reporthtmlfile = exportfolder + "\\report_"+ datenow.replace(':','_') + ".html"

warnings = doc.GetWarnings()
htmllst = []
htmllst.append("<html><p><center><h1>  Error Report {} {}  </h1></center></p>".format(doc.Title, datenow ))
htmllst.append("<p><table border=on>  <th style='width:'50%'; vertical-align:top;'> <center>  Errors  </center> </th>")
htmllst.append("<th style='width:'50%'; vertical-align:top;'><center>  Elements  </center> </th>")

for warn in warnings:
	descript = warn.GetDescriptionText()
	htmllst.append("<tr>  <td style='vertical-align:top;'>  {}  </td>".format(descript))
	for elemId in warn.GetFailingElements():
		elem = doc.GetElement(elemId)
		elemType = doc.GetElement(elem.GetTypeId())
			if doc.IsWorkshared:
				wks = doc.GetElement(ElementId(elem.WorksetId.IntegerValue))
				wksName = wks.Name
				wksName = ""
			if elemType is not None:
				htmllst.append("{} : {} : {} : {} : ID {}".format(wksName, elem.Category.Name, elemType.FamilyName, elem.Name, str(elemId)))	
				htmllst.append("{} : {} : {} : ID {}".format(wksName, elem.Category.Name, elem.Name, str(elemId)))	
			htmllst.append("{} : ID {}".format(elem.Category.Name, str(elemId)))		
	htmllst.append("</td>  </tr>")	
htmllst.append(	"</table>  </html>")

with open(reporthtmlfile, 'wb') as f:
OUT = exportfolder, warnings, reporthtmlfile

Hey guys,

I didn’t think I’d get 1 response so really grateful for your replies :slight_smile:

Hmm… so i get the error ‘The module was expected to contain an assembly manifest.’ which a quick google suggests is not easily fixed…

if installing additional python libraries is an option

thank you for those really interesting posts, unfortunately I am trying to avoid it…

an other way to *export* /write warnings to html file with [GetWarnings()]( method

thanks for posting, that is a really interesting bit of Python, unfortunately the GetWarnings wasn’t returning every element for me, so I wanted to use the brute force hacky method… when I run your code a get a message AttributeError: ‘NoneType’ object has no attribute ‘FamilyName’ would you be able to suggest an error catching method for that? thanks



Hi @Mark.Ackerley
i update the code try this

is it possible to see the native html report?

new correction



Really good of you to stick with this :slight_smile: Just to give a bit more background, I got the same error as these guys…

Some elements were not returned with the getwarnings method… hence me looking at the brute force method. I was interested to see that you are able to export info to HTML, but I don’t want you to spend time on this when we won’t reach a satisfactory outcome. If you are really keen, I got a different error this time…

File “”, line 34, in
AttributeError: Name

Thanks again for your efforts.


Edit, here’s an updated html renamed to a txt to allow me to upload it… SBC-TAH-HTA-A-ZZ-M3-EXT_Mark.txt (164.3 KB)

1 Like

Ok I understand better with the report.
Unless I’m mistaken, this is a temporary report following the automatic creation of elements.
Indeed, all warnings are not signaled in the revision warning messages once the window is closed because Revit apply “some corrections”

1 Like