- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I just stumbled across a case where the normal procedure I use to see if a file is saved or unsaved does not work. In many code examples I've seen it checks the document.fullfilename and if that is something the file has been saved. I've seen an Autodesk employee recomend using that check and it works most of the time.
The case I just found is when working inside of an assembly and either demoting a part to a new assembly or creating a new part using the create component command. Both of these commands have you choose a filepath for the new assembly/part and if you check the document.fullfilename for that newly created assembly/part it exists. The issue is until you do a save that assembly/part is not saved to the disk.
So for instance if you check the document.fullfilename it will exist (normally this means the assembly/part has been saved) and then a script tries the following. The following check will error because while dpath is the full file name for that component, the component has not been saved to disk yet.
dpath = oDoc.fullfilename
if (ThisApplication.Documents.Open(dpath, False).DocumentType <> kAssemblyDocumentObject) then
I'd like to know if there is another simple way to check if a file is actually saved or would that require making a function to check if the file exists on disk.
Secondly I got around the error in the code above by chaning it to use oDoc.DocumentType instead of trying to open the file (not sure why I did it that way originally), but I have one other problem. I use the code below to open a choosen part by itself and it doesn't work for the reason stated above. Is there a way to use ThisApplication.ActiveEditDocument to open an assembly/part in a new window? Thanks
Set oPartDoc = ThisApplication.Documents.Open(dpath, True)
oPartDoc.Activate
Solved! Go to Solution.