iLogic to Change Read Only state of file(s)

iLogic to Change Read Only state of file(s)

phlyx
Collaborator Collaborator
2,689 Views
5 Replies
Message 1 of 6

iLogic to Change Read Only state of file(s)

phlyx
Collaborator
Collaborator

Exhausted my searched and didn't find anything so just posting a quick question.  Can you change the read only state of a file (or files) with iLogic (or something else) from inside Inventor?  Looking for a quick and dirty (non-Vault) way to change the state of files.

0 Likes
Accepted solutions (2)
2,690 Views
5 Replies
Replies (5)
Message 2 of 6

mcgyvr
Consultant
Consultant

Maybe explaining why you want this functionality would be helpful/wise,etc...

 

VB/system.io has the functionality you want though..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @phlyx 

 

This question would have been better placed on the  Inventor Customization forum so I've asked the moderators to move it to there, please keep that in mind for the future
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

as for your question though, here is an example I had on hand.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

strPath =  System.IO.Directory.GetParent(ThisDoc.Document.FullFileName).FullName


'set read only off for each file in the folder
Dim dir As New System.IO.DirectoryInfo(strPath)
 For Each File As System.IO.FileInfo In dir.GetFiles("*", System.IO.SearchOption.AllDirectories)
     ' Set flag.
     File.IsReadOnly = False
 Next
	 
MessageBox.Show("Read Only turned off for all files in: "  &vbLf &vbLf & _
strPath, "iLogic", MessageBoxButtons.OK, MessageBoxIcon.Information)

 

EESignature

Message 4 of 6

phlyx
Collaborator
Collaborator

That's close but that handles all files in a folder.  We're really just looking to have something we can click on to toggle read only on and off for the active document we're in.  

 

Why we're looking to do this is that we are nowhere close to being at a position to even consider Vault so we're trying to do some minor file editing control using the file properties to protect completed designs.

 

0 Likes
Message 5 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @phlyx 

 

see this example

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

sFileName = ThisApplication.ActiveEditDocument.fullfilename

Dim oFile As System.IO.FileInfo 
oFile = New System.IO.FileInfo(sFileName)
oFile.IsReadOnly = False

 

EESignature

0 Likes
Message 6 of 6

phlyx
Collaborator
Collaborator

All I can say is PERFECT!   Created a quick form that you can access while in a part or assembly and change the read-only state on or off.  That is exactly what we needed!   Thanks!!!

0 Likes