• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Active Contributor
    Posts: 46
    Registered: ‎06-21-2007

    iLogic Help needed

    275 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

     

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,575
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Active Contributor
    Posts: 46
    Registered: ‎06-21-2007

    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.

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,575
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Active Contributor
    Posts: 46
    Registered: ‎06-21-2007

    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.

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,575
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Active Contributor
    Posts: 46
    Registered: ‎06-21-2007

    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.

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,575
    Registered: ‎09-13-2011

    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

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,988
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    Valued Contributor
    Posts: 60
    Registered: ‎09-30-2005

    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

    Please use plain text.