Inventor Customization

Reply
Distinguished Contributor
Posts: 565
Registered: ‎02-12-2009
Message 1 of 6 (373 Views)

How to determine if an open file is read-only?

373 Views, 5 Replies
07-07-2010 01:26 PM

I'm developing a routine to change file propertites on open files.  The file property changes won't be saved if the file is read-only and the file is read-only if it exists in the Vault but is not checked out.

Distinguished Contributor
Posts: 305
Registered: ‎05-07-2005
Message 2 of 6 (367 Views)

Re: How to determine if an open file is read-only?

07-07-2010 09:35 PM in reply to: cadfish1
Try this
Dim File_Attr As String

In Vba/VB6 use
File_Attr = GetAttr("C:\temp\test.ipt")

VB.NET use
File_Attr = System.IO.File.GetAttributes("C:\temp\test.ipt")

If File_Attr = 1 Or File_Attr = 33 Then
Msgbox ("the file is Read only")
End If

René J
Distinguished Contributor
Posts: 565
Registered: ‎02-12-2009
Message 3 of 6 (359 Views)

Re: How to determine if an open file is read-only?

07-08-2010 05:12 AM in reply to: Rene-J

Thanks Rene, this is helpful.  I noticed though that the Document object has a IsModifiable property, what is this used for?

Distinguished Contributor
Posts: 565
Registered: ‎02-12-2009
Message 4 of 6 (357 Views)

Re: How to determine if an open file is read-only?

07-08-2010 05:41 AM in reply to: Rene-J

Correction to your code.  File_Attr should be a number (not a String), I think all Enums are Longs.  Also, your IF test expression only works if read-only is the only attribute set or if read-only and archive are the only two attributes set.  My IF test expression below, returns if read-only is set, no matter what the other Attributes are set to.

 

Dim File_Attr As Long 

If File_Attr And 1 Then
    MsgBox("the file is Read only")
Else 
    MsgBox("the file is NOT Read only")
End If

 

Distinguished Contributor
Posts: 305
Registered: ‎05-07-2005
Message 5 of 6 (354 Views)

Re: How to determine if an open file is read-only?

07-08-2010 06:09 AM in reply to: cadfish1

Hi thanks

The no. 33 If I remember right, if  the inventor file is used in shared project  and set  to reservedforwrite and read-only

 

René J

Distinguished Contributor
Posts: 565
Registered: ‎02-12-2009
Message 6 of 6 (352 Views)

Re: How to determine if an open file is read-only?

07-08-2010 06:17 AM in reply to: Rene-J

No, 33 is the combining of 1 (read-only) and 32 (archive) file Attribute Enums (long integer).

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube