Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Help needed

11 REPLIES 11
Reply
Message 1 of 12
gcooper79
952 Views, 11 Replies

iLogic Help needed

Hi All,

 

I am trying to write a rule for restricting save rights to a .ipt or .iam file.  I am just starting out with ilogic and have very basic coding experience.

 

What I would like is for the rule to read the windows login username and depending on the result (User A) displays a radio message box asking if if the file should be restricted.

 

If the file is to be restricted, then the rule should allow only User A to save the file.  Hopefully that makes sense.

 

I have posted the code I have so far.  I don't know how to get the windows username so have substituted this with username for the moment.

 

If Username = "User A" Then

RestrictAccess = InputRadioBox("Should this file be restricted?", "Yes", "No", RestrictAccess, Title := "Restrict Access")

End If

If  RestrictAccess = True  And Username = "User A" Then

ThisDoc.Save

Else

ThisDoc.Document.SaveAs


End If

 

Regards,
Graeme
11 REPLIES 11
Message 2 of 12
mrattray
in reply to: gcooper79

I don't think this is going to work.

Mike (not Matt) Rattray

Message 3 of 12
gcooper79
in reply to: mrattray

I know my current code doesn't work.  I just posted it to give an idea of what I'm looking to achieve.

Regards,
Graeme
Message 4 of 12
mrattray
in reply to: gcooper79

That's obvious, I mean I don't think iLogic will work for this at all.

Mike (not Matt) Rattray

Message 5 of 12
gcooper79
in reply to: mrattray

Oh ok Smiley Sad 

 

Do you mean that It wouldn't be posible to get the windows username from ilogic or something else?

 

If it's not possibile to get the windows username, would it be possible to get the username from the applications options?

 

thanks for any help.

Regards,
Graeme
Message 6 of 12
mrattray
in reply to: gcooper79

You can get the WIndows username (I don't have it at my finger tips, but I'm sue you could find a snippet if you searched the Inventor customization forum).

I just don't think iLogic will work very well for controlling file editing permissions. I don't know how much anti-tamper you need but all it would take is a right click suppress or delete on your rule to "unlock" the file. More importantly, I'm not sure how you could capture the save command to keep it from executing. Have you done any experimenting to see if it's possible?

Mike (not Matt) Rattray

Message 7 of 12
gcooper79
in reply to: mrattray

Suppressing the rule won't be an issue as the user we're trying to restrict, doesn't have a lot of experience using inventor, and has never even heard of ilogic.

 

I haven't experimented with the save command yet.  My thoughts on it would be to trigger the rule before save then write a rule to abort the save command and trigger the saveas command instead.

 

I don't know how possible this would be though.

Regards,
Graeme
Message 8 of 12
mrattray
in reply to: gcooper79

Have you considered using read only files instead?

You could write an API routine (I don't know if it would work in iLogic) that would mark the file read only or not based on the user name...

 

Never underestimate the power of ignorance.

Mike (not Matt) Rattray

Message 9 of 12

 

Hi  gcooper79,

 

I think mrattray is probably right in thinking that iLogic might not be the best tool for this, but it doesn't hurt to try I suppose. Here are some snippets I had on hand for setting and clearing the read only flags. These snippets do it for the entire folder the file resides in, but you can change it to target only the file as needed.

 

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

 

 

 

'clear the read only flag on all of the files found
'in the same folder as this file

'get the file path
Dim strPath As String = ThisDoc.Path & “\”

 ‘clear read only flag
SetAttr(strPath, vbNormal + vbArchive)

Dim strFile As String = Dir(strPath)
Do Until strFile = ""
 ‘clear read only flag
SetAttr(strPath & "\" & strFile, vbNormal + vbArchive)
strFile = Dir()
Loop

 

'set the read only flag on all of the files found 
'in the same folder as this file

'get the file path
Dim strPath As String = ThisDoc.Path & “\” ‘clear read only flag SetAttr(strPath, vbNormal + vbArchive) Dim strFile As String = Dir(strPath) Do Until strFile = "" ‘set read only flag SetAttr(strPath & "\" & strFile, vbReadOnly + vbArchive) strFile = Dir() Loop

 

Message 10 of 12
theo.bot
in reply to: gcooper79

Maybe it's easier to use a datamangement tool for this like Vault.

 

Theo

Message 11 of 12
MegaJerk
in reply to: theo.bot


@theo.bot wrote:

Maybe it's easier to use a datamangement tool for this like Vault.

 

Theo



Agreed. If you're trying to prevent users from working on files that other users may be actively working on, then your best bet would be to go on and grab Vault so that you can incorporate a nice check in / check out into your work flow. 

If that isn't your goal, perhaps you can explain in a bit (or a lot) more detail, about what you're trying to do, and why. 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 12 of 12
gcooper79
in reply to: MegaJerk

I agree that vault would solve the issue.  However, the company has not yet installed Vault and the department that has the user issue are not too keen on using Vault anyway.  I think they have solved the problem by  sacking the user anyway 😉

 

thanks for all your help.

Regards,
Graeme

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report