See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: AC2014 Secureload and Reactor

  1. #1
    Active Member Tommybluegrass's Avatar
    Join Date
    2015-12
    Location
    Mississippi Gulf Coast, U.S.A.
    Posts
    74
    Login to Give a bone
    0

    Default AC2014 Secureload and Reactor

    Has anyone tried to monitor “SECURELOAD” when it changes using a reactor and set it to something else?
    Using other system variables seems to work. For some reason SECURELOAD is not recognized.
    Below is what I am trying.

    Code:
    (vl-load-com)
       
      (defun c:CKSL ()
        (if *SECURELOADReactor*
          (progn
            (vlr-remove *SECURELOADReactor*)
            (setq *SECURELOADReactor* nil)
            (setq SECURELOAD:Callback nil)
            (prompt "\nReactor stopped. ")
          )
          (progn
            (setq *SECURELOADReactor*
                   (vlr-sysvar-reactor ;I have tried also “vlr-editor-reactor”
                     ""
                     '(
                       (:vlr-sysvarchanged . SECURELOAD:Callback)
                      )
                   )
            )
            (defun SECURELOAD:Callback (rea var / varName)
              (if
                (and
                  (wcmatch (setq varName (strcase (car var))) "SECURELOAD")
                  (cdr var)
                )
                        (setvar "SECURELOAD" 1); Problem is it just writes to the command line “SECURLOAD” 1. Like it doesn’t see setvar
    ;;;             (alert
    ;;;               (strcat "\n[App Event] : System Var Changed\t\t: " varName)
    ;;;             )
              )
            )
            (prompt "\nReactor started. ")
          )
        )
        (princ)
      )
    ACAD Text Window (F2) results follow:

    Code:
    Command: CKSL <-- Manual execute of the reactor
    
    Reactor started.
    Command:
    Command: 'VLIDE
    Command:
    Command: SECURELOAD
    
    Enter new value for SECURELOAD <1>: 0 <-- changed the value manually.
    ; error: AutoCAD variable setting rejected: "SECURELOAD" 1  <-- Results of reactor -->but works if SECURELOAD is replaced with another sysvar like FILEDIA sysvars.
    I wonder, is the a bug or Autodesk has prevented this from working.

    Any advice or solution?
    Last edited by BlackBox; 2014-03-24 at 04:15 PM. Reason: [code] tags added

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: AC2014 Secureload and Reactor

    Quote Originally Posted by Tommybluegrass View Post
    Has anyone tried to monitor “SECURELOAD” when it changes using a reactor and set it to something else?
    Using other system variables seems to work. For some reason SECURELOAD is not recognized.
    Below is what I am trying.

    Code:
    (vl-load-com)
       
      (defun c:CKSL ()
        (if *SECURELOADReactor*
          (progn
            (vlr-remove *SECURELOADReactor*)
            (setq *SECURELOADReactor* nil)
            (setq SECURELOAD:Callback nil)
            (prompt "\nReactor stopped. ")
          )
          (progn
            (setq *SECURELOADReactor*
                   (vlr-sysvar-reactor ;I have tried also “vlr-editor-reactor”
                     ""
                     '(
                       (:vlr-sysvarchanged . SECURELOAD:Callback)
                      )
                   )
            )
            (defun SECURELOAD:Callback (rea var / varName)
              (if
                (and
                  (wcmatch (setq varName (strcase (car var))) "SECURELOAD")
                  (cdr var)
                )
                        (setvar "SECURELOAD" 1); Problem is it just writes to the command line “SECURLOAD” 1. Like it doesn’t see setvar
    ;;;             (alert
    ;;;               (strcat "\n[App Event] : System Var Changed\t\t: " varName)
    ;;;             )
              )
            )
            (prompt "\nReactor started. ")
          )
        )
        (princ)
      )
    ACAD Text Window (F2) results follow:

    Code:
    Command: CKSL <-- Manual execute of the reactor
    
    Reactor started.
    Command:
    Command: 'VLIDE
    Command:
    Command: SECURELOAD
    
    Enter new value for SECURELOAD <1>: 0 <-- changed the value manually.
    ; error: AutoCAD variable setting rejected: "SECURELOAD" 1  <-- Results of reactor -->but works if SECURELOAD is replaced with another sysvar like FILEDIA sysvars.
    I wonder, is the a bug or Autodesk has prevented this from working.

    Any advice or solution?
    Firstly, if you're going to copy someone's publicly posted code, as you seem to have done with mine from here, that's perfectly fine, but you'd do well to kindly accredit the source.

    Second, one is not permitted to change the SECURELOAD system variable within a SystemVariableChanged event handler... That may be due to this particular system variable being an integral part of the new AutoCAD security mechanism; it would stand to reason that it should not be permitted, but I do not know that for certain.

    In order to accomplish this....

    In a SystemVariableChanged event handler I'd first check for the target system variable(s), in this case SECURELOAD, check if it has in fact changed, then check if has been disabled (set to 0)... At which point I would unregister my SystemVariableChanged event handler, and register an Idle event handler (do not recall if this has been exposed to LISP), then within the Idle event handler I would unregister said event, and re-register the SystemVariableChanged event, making the applicable change(s)... All of this done to avoid an potential infinite loop.

    Here's a quick example from .NET API, as I just happened to be in Visual Studio at the moment:

    Code:
    // BlackBoxCAD.com, 2014
    //
    using Autodesk.AutoCAD.Runtime;
    using System;
    
    using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
    
    [assembly: ExtensionApplication(typeof(BlackBox.AutoCAD.SecureloadAuto.Events))]
    
    namespace BlackBox.AutoCAD.SecureloadAuto
    {
        public class Events : IExtensionApplication
        {
            void IExtensionApplication.Initialize()
            {
                acApp.SystemVariableChanged += onSystemVariableChanged;
            }
            void IExtensionApplication.Terminate()
            {
            }
            void onSystemVariableChanged(object sender, 
                Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
            {
                if (e.Name.ToUpper() == "SECURELOAD" && e.Changed &&
                    Convert.ToInt32(acApp.GetSystemVariable("SECURELOAD")) == 0)
                {
                    acApp.SystemVariableChanged -= onSystemVariableChanged;
                    acApp.Idle += onIdle;
                }
            }
            void onIdle(object sender, EventArgs e)
            {
                acApp.Idle -= onIdle;
                acApp.SetSystemVariable("SECURELOAD", 1);
                acApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n[BlackBox] : SECURELOAD enabled. \n");
                acApp.SystemVariableChanged += onSystemVariableChanged;
            }
        }
    }


    ... Sample command line output:

    Code:
    Command:
    
    Command: NETLOAD
    
    Command: SECURELOAD
    
    Enter new value for SECURELOAD <1>:
    0
    
    Command:
    [BlackBox] : SECURELOAD enabled.
    
    SECURELOAD
    
    Enter new value for SECURELOAD <1>: 0
    
    Command:
    [BlackBox] : SECURELOAD enabled.
    
    (getvar 'secureload)
    1
    
    (setvar 'secureload 0)
    0
    
    Command:
    [BlackBox] : SECURELOAD enabled.
    Cheers
    Last edited by BlackBox; 2014-03-24 at 06:03 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Active Member Tommybluegrass's Avatar
    Join Date
    2015-12
    Location
    Mississippi Gulf Coast, U.S.A.
    Posts
    74
    Login to Give a bone
    0

    Default Re: AC2014 Secureload and Reactor

    Dear Blackbox,

    First thanks for your ideas and suggestions. I will check into these.
    Second, I am not sure where or from whom I got this code but in the heat of my action item I grab snippets and take a look see. The insult was not neccessary. Since it is yours more power to you. I will make it offical now that I know whos code it is. Kudos goes to Blackbox. It worked as written to return an alert box on variable change. If I use this snippet I will give you the credit for it is required and shows respect to the author.

    v/r
    Tommy

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: AC2014 Secureload and Reactor

    Quote Originally Posted by Tommybluegrass View Post
    First thanks for your ideas and suggestions. I will check into these.
    You're welcome; I'm happy to help.

    FWIW - My intention was to educate, and not insult, as I believe you made a sincere mistake... Sorry if you took it differently (I wouldn't have attempted to help, if I was trying to offend).

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    1

    Default Re: AC2014 Secureload and Reactor

    Quote Originally Posted by Tommybluegrass View Post
    Dear Blackbox,

    First thanks for your ideas and suggestions. I will check into these.
    Second, I am not sure where or from whom I got this code but in the heat of my action item I grab snippets and take a look see. The insult was not neccessary. Since it is yours more power to you. I will make it offical now that I know whos code it is. Kudos goes to Blackbox. It worked as written to return an alert box on variable change. If I use this snippet I will give you the credit for it is required and shows respect to the author.

    v/r
    Tommy
    For reference purposes I include the link to where I copied the code as well as the author. If the code doesn't work as expected after an upgrade returning to that link I often find updated code for the newer version. If not that's usually the best place to get help from the author and other folk using that same piece of code.

    It's also nice to show appreciation for those who work so hard creating and posting code for all of us they'll probably never even meet.

Similar Threads

  1. vlr-dwg-reactor issue MY FIRST REACTOR
    By treaves04413213 in forum AutoLISP
    Replies: 21
    Last Post: 2013-10-18, 12:36 PM
  2. Replies: 4
    Last Post: 2013-08-02, 09:13 PM
  3. Replies: 1
    Last Post: 2009-08-14, 01:05 PM
  4. Looking for reactor help
    By d_m_hopper in forum AutoLISP
    Replies: 1
    Last Post: 2008-12-17, 07:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •