Wednesday, February 2, 2011

[Revit API]–Document.PathName will be empty when unsaved or detached from central

This may seem a bit obvious but I thought I’d post it up anyway. If you are planning on relying on Document.PathName to show you where the current Revit file is located (for instance, if you are making an export tool that puts the file in the same location as the .rvt file), keep in mind that if the user has just created a new file, this value will be empty. The same also goes for Document.Title.
Perhaps a bit more trickier is that these values will also be empty if the user opens a central file and selects ‘detach from central’
image
If the user runs your tool before manually saving it somewhere, they will not have a PathName or Title. If your application relies on this value make sure you check it for null and have a contingency plan, such as asking the user to save the file first, or prompting them for a location.
image

No comments: