Inventor General

Reply
Active Contributor
gcooper79
Posts: 47
Registered: ‎06-21-2007
Message 1 of 12 (325 Views)

iLogic Help needed

325 Views, 11 Replies
08-16-2012 03:01 AM

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

 

*Expert Elite*
mrattray
Posts: 2,456
Registered: ‎09-13-2011
Message 2 of 12 (323 Views)

Re: iLogic Help needed

08-16-2012 03:57 AM in reply to: gcooper79

I don't think this is going to work.

Mike (not Matt) Rattray

Active Contributor
gcooper79
Posts: 47
Registered: ‎06-21-2007
Message 3 of 12 (321 Views)

Re: iLogic Help needed

08-16-2012 04:02 AM 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.

*Expert Elite*
mrattray
Posts: 2,456
Registered: ‎09-13-2011
Message 4 of 12 (319 Views)

Re: iLogic Help needed

08-16-2012 04:03 AM in reply to: gcooper79

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

Mike (not Matt) Rattray

Active Contributor
gcooper79
Posts: 47
Registered: ‎06-21-2007
Message 5 of 12 (316 Views)

Re: iLogic Help needed

08-16-2012 04:20 AM in reply to: mrattray

Oh ok :smileysad: 

 

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.

*Expert Elite*
mrattray
Posts: 2,456
Registered: ‎09-13-2011
Message 6 of 12 (314 Views)

Re: iLogic Help needed

08-16-2012 04:26 AM 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

Active Contributor
gcooper79
Posts: 47
Registered: ‎06-21-2007
Message 7 of 12 (308 Views)

Re: iLogic Help needed

08-16-2012 05:48 AM 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.

*Expert Elite*
mrattray
Posts: 2,456
Registered: ‎09-13-2011
Message 8 of 12 (306 Views)

Re: iLogic Help needed

08-16-2012 05:55 AM 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

*Expert Elite*
Curtis_Waguespack
Posts: 2,780
Registered: ‎03-08-2006
Message 9 of 12 (295 Views)

iLogic Read Only Flag / Read Only Files

08-16-2012 08:05 AM in reply to: gcooper79

 

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

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Valued Contributor
theo.bot
Posts: 64
Registered: ‎09-30-2005
Message 10 of 12 (273 Views)

Re: iLogic Help needed

08-17-2012 10:39 PM in reply to: gcooper79

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

 

Theo

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
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

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