New to Python/Revit API - opening local file

I am attempting to write a simple python script to create and open local files of multiple central files. I’m feeding the input a file path, but can’t seem to get the createlocalfile method to work. I’m sure it’s something simple since I’m new to Python, but I haven’t been able to figure it out. Thoughts?

Have you tried giving it a Full File path with File Name rather than just a directory?

API reference here:
http://www.revitapidocs.com/2018.1/205fa377-e6ad-aef0-e783-35b50152c336.htm

Yes, I have tried that (adding a \temp.rvt to the path)- no difference.
Also realized I had the wrong method name (should have been CreateNewLocal), that has been fixed and it still does not work.

I think you are missing an import or two for the “FilePath” to work as you expect.

Here’s what I have now…Still not working.


I get the following error on my python node:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 38, in
TypeError: expected ModelPath, got str

What is this line doing for you:

modelPath = FilePath(file)

Since you are using the os.path.realpath above, you should be able to feed the “file” directly into the CreateNewLocal line.

I would comment out the newdoc line and set you OUT as modelPath and see what you are getting. I don’t think you need this.

It may also help if you uploaded a shot of the rest of your graph so we can make sure there isn’t something up stream causing the issue.

Convert the local path string as a model path using ConvertUserVisiblePathToModel Path member . That should solve it

4 Likes