Hello Everyone,
I have created a Dynamo Script for exporting the Revit Models into IFC format as needed. attached scripts will try to find all Revit files in specified location and it will open one Revit file and export it in the IFC format with the options specified in the script and then it will close the Revit file without saving it. This process will be repeated for all the Revit files in that location. Until this point everything is fine.
while opening files I am getting the pop ups where I have to manually click on those to proceed further. I just want to avoid these pop ups. Is there a way to modify the script accordingly?
All suggestions are welcome.
IFc export-all Files in a folder.dyn (25.6 KB)
Python Code:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
items = IN[0]
folder=UnwrapElement(IN[1])
name=tolist(UnwrapElement(IN[2]))
fileversion = IN[3]
wallandcolumnsplitting = IN[4]
exportbasequantities = IN[5]
Projectorigin = IN[6]
#if isinstance(IN[7], list) : inputdocs = IN[7]
#else : inputdocs = [IN[7]]
oOptions = OpenOptions()
oOptions.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets
oOptions.Audit = True
oOptions.AllowOpeningLocalByWrongUser = True
typelist = list()
for index, i in enumerate(items):
modelpath = FilePath(i)
newdoc = app.OpenDocumentFile(modelpath, oOptions)
# typelist.append(newdoc)
t = Transaction(newdoc,'export')
t.Start()
result = []
# v = view[index]
options=IFCExportOptions()
#if fileversion != None:
# options.FileVersion = fileversion
if fileversion == "IFC4":
options.FileVersion = IFCVersion.IFC4
if fileversion == "IFC4RV":
options.FileVersion = IFCVersion.IFC4RV
if fileversion == "IFC4DTV":
options.FileVersion = IFCVersion.IFC4DTV
if fileversion == "IFC2x2":
options.FileVersion = IFCVersion.IFC2x2
if fileversion == "IFC2x3":
options.FileVersion = IFCVersion.IFC2x3
if fileversion == "IFC2x3CV2":
options.FileVersion = IFCVersion.IFC2x3CV2
if fileversion == "IFC2x3BFM":
options.FileVersion = IFCVersion.IFC2x3BFM
if fileversion == "IFC2x3FM":
options.FileVersion = IFCVersion.IFC2x3FM
if fileversion == "IFCBCA":
options.FileVersion = IFCVersion.IFCBCA
if fileversion == "IFCCOBIE":
options.FileVersion = IFCVersion.IFCCOBIE
if fileversion == "":
options.FileVersion = IFCVersion.Default
options.WallAndColumnSplitting = wallandcolumnsplitting
options.ExportBaseQuantities = exportbasequantities
# options.FilterViewId = v.Id
options.AddOption("ExportInternalRevitPropertySets","false");
options.AddOption("ExportIFCCommonPropertySets","false");
options.AddOption("ExportAnnotations ","false");
options.AddOption("SpaceBoundaries ", "0");
options.AddOption("ExportRoomsInView", "false");
options.AddOption("Use2DRoomBoundaryForVolume ", "false");
options.AddOption("UseFamilyAndTypeNameForReference ", "true");
options.AddOption("Export2DElements", "false");
options.AddOption("ExportPartsAsBuildingElements", "false");
options.AddOption("ExportBoundingBox", "false");
options.AddOption("ExportSolidModelRep", "false");
options.AddOption("ExportSchedulesAsPsets", "false");
options.AddOption("ExportSpecificSchedules", "false");
#oesn't work. It would be necessary to use OpenInBackground.
options.AddOption("ExportLinkedFiles", "false");
options.AddOption("IncludeSiteElevation","true");
options.AddOption("StoreIFCGUID", "false");
options.AddOption("VisibleElementsOfCurrentView ", "false");
options.AddOption("UseActiveViewGeometry", "false");
options.AddOption("TessellationLevelOfDetail", "1");
options.AddOption("ExportUserDefinedPsets","false");
options.AddOption("SitePlacement", IN[6]);
# options.AddOption("ExportUserDefinedPsetsFileName","the filepath")
#IFCVersion Version = (IFCVersion) Enum.Parse( typeof(IFCVersion), UnwrapElement(IN[3]), true );
#x.FileVersion = IFCVersion.IFC2x3CV2
c=newdoc.Export(folder, name[index], options)
result.append(c)
t.Commit()
typelist.append(newdoc.Close(False))
if fileversion == "":
OUT="Default settings used"
else:
OUT=typelist