bvn-architecture / RevitBatchProcessor

Fully automated batch processing of Revit files with your own Python or Dynamo task scripts!
GNU General Public License v3.0
296 stars 80 forks source link

System.IO.IOExecution: Could not add reference to assembly RevitAPI #68

Closed archengell closed 4 years ago

archengell commented 4 years ago

Hello,

I'm trying to create a post-script that'll save the files after the task is run. I've done this a few times with scripts/plug-ins with RPS. I've followed and made a derivative from the example save file script, and created a new script using the template code to work with your plug-in; both attempts have been unsuccessful with this error:

RBP_System IO IOException

Any insight would be helpful. I've been intermittently working on this error for a few days. Thanks.

archengell commented 4 years ago

Post-scripts i've used to debug this issue: ################################################################ Attempt #1: Custom Save Post Script: ################################################################ import clr import System

clr.AddReference("RevitAPI") clr.AddReference("RevitAPIUI") import Autodesk.Revit.DB as DB import Autodesk.Revit.DB.Options as Options import Autodesk.Revit.DB.Transaction as Transaction import Autodesk.Revit.DB.ModelPathUtils as ModelPathUtils import Autodesk.Revit.DB.OpenOptions as OpenOptions import Autodesk.Revit.UI.UIDocument as uiDoc import Autodesk.Revit.UI as ui

import revit_script_util from revit_script_util import Output

sessionId = revit_script_util.GetSessionId() uiapp = revit_script_util.GetUIApplication()

doc = revit_script_util.GetScriptDocument() revitFilePath = revit_script_util.GetRevitFilePath()

clr.AddReference("System.Core") clr.ImportExtensions(System.Linq)

output messages either to batch processor (debug = False) or console (debug = True)

def Output(message = ''): if not debug_: revit_script_util.Output(str(message)) else: print (message)

Output() Output('Saving Revit File....')

modelPath = revit_file_util.ToModelPath(revitFilePath) opendRvtFile_uiDoc = revit.OpenAndActivateDocument(modelPath, openOpt, False)
opendRvtFile_doc = opendRvtFile_uiDoc.Document saveOptions = revDb.SaveAsOptions() saveOptions.OverwriteExistingFile = True
opendRvtFile_doc.Save(saveOptions)
opendRvtFile_doc.Close(False)

make further changes as required....

Output('Modifying Revit File.... status: ' + str(result_.status))

sync changes back to central

if (doc.IsWorkshared and debug == False): Output('Syncing to Central: start') syncing = com.SyncFile (doc) Output('Syncing to Central: finished ' + str(syncing_.status))

Output('Modifying Revit File.... finished ') ################################################################ Attempt #2: hybrid of saveAs example and template/boilerplate code: ################################################################

import clr import System clr.AddReference("System.Core") clr.ImportExtensions(System.Linq)

clr.AddReferenceToFileAndPath('RevitAPI') clr.AddReferenceToFileAndPath('RevitAPIUI')

import script_util from script_util import Output

sessionId = script_util.GetSessionId()

revitFileListFilePath = script_util.GetRevitFileListFilePath()

sessionDataFolderPath = script_util.GetSessionDataFolderPath() dataExportFolderPath = script_util.GetExportFolderPath()

Output() Output("This post-processing script is running!")

import revit_script_util import revit_file_util doc = revit_scriptutil.GetScriptDocument() revitFilePath = revit_script_util.GetRevitFilePath()

from Autodesk.Revit.DB import *

import Common as com from Common import *

Output('Modifying Revit File.... start') result_ = com.Save(doc)

Output('Modifying Revit File.... status: ' + str(result_.status))