Jump to content

Offset to layer reactor


broncos15

Recommended Posts

I don't think this should work , but you need to convert the layer object to vla-object then put the plotstyle to Block if your Plot Style Mode is not Color-Dependent and it is Named Plot Style mode.
Thanks Tharwat! I got it all working, except I have one last question in regards to using setenv. So I have been able to get the reactor on to work using
(if (not *Offset2LayerReactor*)
   (progn
     (setenv *Offset2LayerReactor* t)
            (vlr-command-reactor
              "offset:to:layer"
              '((:vlr-commandWillStart . PaveTheGround)
                (:vlr-commandended . GetTheJobDone)
               )
            )
   )
 )

However, my turning off portion doesn't work, which is

(if *Offset2LayerReactor*
   (progn
     (vlr-remove (vlr-command-reactor
              "offset:to:layer"
              '((:vlr-commandWillStart . PaveTheGround)
                (:vlr-commandended . GetTheJobDone)
               )
            ))
     (setenv *Offset2LayerReactor* nil)
   )
 )

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • broncos15

    13

  • Tharwat

    9

  • Grrr

    3

  • BIGAL

    1

Top Posters In This Topic

Sorry, you have lots of mistakes.

 

Why you are assigning the global variable *Offset2LayerReactor* into setenv ?

Setenv accepts strings only as I know and not Boolean or nil.

You are removing the reactor by creating it !

Link to comment
Share on other sites

Sorry, you have lots of mistakes.

 

Why you are assigning the global variable *Offset2LayerReactor* into setenv ?

Setenv accepts strings only as I know and not Boolean or nil.

You are removing the reactor by creating it !

The reason that I was trying to use setenv is that I want the user to only have to turn on the reactor once. That way, every time they open AutoCAD, the reactor is running if they turn it on. So if I understand correctly, I should just use setenv to turn the reactor on or off, then I will need another function that will actually run the reactor based on if setenv is set to on or off.
Link to comment
Share on other sites

You don't need at all , I already include that with two commands to activate and disable. Did not you notice that ?

If you want to activate the reactor in every new or opened drawing , just add the complete name of the command like this example (c:test) and the program must be loaded via ACADDOC.lsp or added to Contents of the command call APPLOAD to get sure that the program is running with any new session.

Link to comment
Share on other sites

You don't need at all , I already include that with two commands to activate and disable. Did not you notice that ?

If you want to activate the reactor in every new or opened drawing , just add the complete name of the command like this example (c:test) and the program must be loaded via ACADDOC.lsp or added to Contents of the command call APPLOAD to get sure that the program is running with any new session.

The variable is only global though that control whether it is turned on though, so when I load it, I still have to turn it on in every new drawing vs. if I used setenv, then I could just turn it on once, and it would remember it.
Link to comment
Share on other sites

So I have tried to correct this by adding

(if (= (getenv "*Offset2LayerReactor*") "On")
 (setq *Offset2LayerReactorOnOff*
            (vlr-command-reactor
              offset:to:layer
              '((:vlr-commandWillStart . PaveTheGround)
                (:vlr-commandended . GetTheJobDone)
               )
            )
     )
 )

I added this to the top so the reactor is loaded during start up. I then edited the on and off functions to:

 (defun c:Offset2LayerOn nil   (if (not (= (getenv "*Offset2LayerReactor*") "On"))
   (progn
     (setenv "*Offset2LayerReactor*" "On")
     (setq *Offset2LayerReactorOnOff*
            (vlr-command-reactor
              offset:to:layer
              '((:vlr-commandWillStart . PaveTheGround)
                (:vlr-commandended . GetTheJobDone)
               )
            )
     )
   )
 )
 (princ "\nOffset to Layer enabled.")
 (princ)
)
;;--------------------------------------------;;
(defun c:Offset2LayerOff nil
 (if (= (getenv "*Offset2LayerReactor*") "On")
   (progn
     (vlr-remove *Offset2LayerReactorOnOff*)
     (setenv "*Offset2LayerReactor*" "Off")
   )
 )
 (princ "\nOffset to Layer disabled.")
 (princ)
)

Do you see any problem w/ my solution? I am just asking because I know that reactors are extremely finicky.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...