The local file is not owned by the current user, who therefore is not allowed to modify it

The local file is not owned by the current user, who therefore is not allowed to modify it
image

This sounds like a Revit problem. I’m guessing the file you’re trying to access is someone else’s local copy and therefore you can’t modify it. Assuming it’s not just an issue with the Revit user name, your only option is to recreate the file as a new central or remove worksharing altogether.

I am opening in background a local file, but in that python script does not detach from central and keep worksets, just opens as it is. I would change the local file but I cannot edit it, so I want to extend the script to be able to detach from central and keep worksets.

the script used is that:

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import clr
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
app = DocumentManager.Instance.CurrentUIApplication.Application
filePath = IN[0]
opened = []
#Output
for i in filePath:
	opened.append(app.OpenDocumentFile(i))
OUT = opened

I saw a similar code in C# from Rhythm but I did not try to make it in Python

If you purposefully want to open another local file then you’ll have to use the OpenDocumentFile method with OpenOptions.

That will allow you to either open the file read-only or open detached.

I tried that but it does not work with a list of file paths, only single input item:

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

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

filePath = IN[0]
modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath)

options = OpenOptions()
options.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets

docOnDisk = app.OpenDocumentFile(modelPath, options)

OUT = docOnDisk

Correct. You would have to loop through the list of files like your original code did.

1 Like

Thanks, I know, so I was expecting some suggestions in code before resolving it by myself

import clr
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
app = doc.Application
filePath = IN[0]
opened = []
options = OpenOptions()
options.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets
for i in filePath:
	opened.append(app.OpenDocumentFile(ModelPathUtils.ConvertUserVisiblePathToModelPath(i), options))
OUT = opened