I tried to use pyRevit to export model 3d view to obj and associated mtl file, I use: obj_options = OBJExportOptions() where I found available in Revit API since 2022
however, there is constantly this error:
Failed to export: The provided options are not valid.
Parameter name: options
Does anyone know whether pyRevit support OBJExportOptions()?
The Export method is part of the Document Class Export Method
It takes 3 arguments: folder path where you want to save you export, name of you export, export options
our mistake was here: The export options takes at a minimum, one argument, the view id of the view the geometry is exported from.
from pyrevit import forms, revit, DB, script
output = script.get_output()
output.close_others()
view = revit.active_view
doc = revit.doc
# set export options
eo = DB.OBJExportOptions()
# set the view to export
eo.ViewId = view.Id
# set the output folder path
output_folder_path = __file__.rsplit("\\", 1)[0]
# export the geometry
doc.Export(output_folder_path, "output.obj", eo)
It does not require a transaction as you are not doing anything to the revit DB, you are just collecting and saving stuffs outside revit
you will need to learn how to read the error message / traceback that pyRevit gives you. They are usually pretty self-explanatory if you take the time to read them.
When I try the code above without setting the view Id, I got:
IronPython Traceback:
Traceback (most recent call last):
File "C:\pyRevit\B1_ToolBar.extension\Outils BIM One.tab\Z_PROTOTYPING.panel\Tests.pulldown\z.pushbutton\script.py", line 18, in <module>
Exception: The provided options do not specify a printable 3D view.
Parameter name: options