Method "GetFileName" for "ImageExportOptions" does not work in CPython3

I just noticed an issue with using the “GetFileName” mehod for “ImageExportOptions” in a python node in Dynamo.
When I run it with IronPython2 it works well. But when changed to CPython3, this function gives an error of variable type inconsistency:
Warning: TypeError : No method matches given arguments for GetFileName: (<class ‘Autodesk.Revit.DB.ImageExportOptions’>, <class ‘Autodesk.Revit.DB.Document’>, <class ‘Autodesk.Revit.DB.ElementId’>) [’ File “”, line 71, in \n’]

Would need you to post the .dyn and/or Python code to help with this. Without that it’s like going to the mechanic and saying “My car makes a funny noise which sounds like brbrbrbrbrbrbrbrbr but it used to sound like brrbrrbrrbrrbrr please help.”

2 Likes

good analogy! :slight_smile:

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

ImageExportList  = [  ]
#sectionView = doc.GetElement(ElementId(436808))
sectionViewId = ElementId(436808)
ImageExportList.append(sectionViewId)
planViewId = ElementId(147390)
ImageExportList.append(planViewId)
tempPath = r'D:\06dynamo\myCalculations\tempReports'

myExportImageOption = ImageExportOptions()
myExportImageOption.FilePath = os.path.join(tempPath , 'export')
myExportImageOption.HLRandWFViewsFileType = ImageFileType.PNG
myExportImageOption.ShadowViewsFileType  = ImageFileType.PNG
myExportImageOption.ExportRange = ExportRange.SetOfViews
myExportImageOption.SetViewsAndSheets(ImageExportList)
myExportImageOption.ZoomType = ZoomFitType.FitToPage
myExportImageOption.FitDirection = FitDirectionType.Horizontal
myExportImageOption.PixelSize = 4096
myExportImageOption.ImageResolution = ImageResolution.DPI_600
doc.ExportImage(myExportImageOption)
hapal = myExportImageOption.GetFileName(doc, sectionViewId)

the error comes from last line

1 Like

I was able to resolve the issue by changing the last line to:
hapal = ImageExportOptions.GetFileName(doc, sectionViewId)

It is because this method is static. But it is weird it was working with IronPython2.
It might be because CPython3 is more disciplined.

yes - C Python runs “natively” (or rather more natively), and as such some of the ‘pythonic’ shortcuts won’t work. I’m hopeful we’ll see IronPython 3.0 because a formal release soon, as this would make transition from a Python 2 to Python 3 ecosystems a LOT easier for many.

1 Like