Jump to content

Recommended Posts

Posted
i know i'm behind, since we switched to a reactor, but i thought i'd indulge.

 

Nice solution Alan :D

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    8

  • Commandobill

    5

  • mdbdesign

    4

  • TimSpangler

    4

Top Posters In This Topic

Posted
Notice: the above does not take into account for the existence of the layers..

 

TIM - I forgot my call-back arguments...! :shock:

 

(defun c:MacON ()
 (vl-load-com)
 (if (not lay:react)
   (progn
     (setq lay:react
       (vlr-command-reactor nil
         (list
           (cons :vlr-commandWillStart 'ChkLay))))
     (princ "\n<< LAYER REACTOR INITIATED >>")))    
 (princ))

(defun ChkLay ([b][color=Red]reac args[/color][/b] / lay1 lay2)
 (and (setq lay1 (tblobjname "LAYER" "APPROVED")
            lay2 (tblobjname "LAYER" "PRELIMINARY"))
      (setq lay1 (vlax-ename->vla-object lay1)
            lay2 (vlax-ename->vla-object lay2))
      (cond ((vl-every
               (function
                 (lambda (x) (eq :vlax-true (vla-get-layeron x)))) (list lay1 lay2))
             (vla-put-layeron lay2 :vlax-false))
            ((vl-every
               (function
                 (lambda (x) (eq :vlax-false (vla-get-layeron x)))) (list lay1 lay2))
             (vla-put-layeron lay1 :vlax-true))))
 (princ))

(defun c:MacOFF ()
 (if lay:react
   (progn
     (vlr-remove lay:react)
     (setq lay:react nil)
     (princ "\n<< LAYER REACTOR DEACTIVATED >>")))
 (princ))

^^ this works now!

 

 

Your code reminded me! :D

Posted
Nice solution Alan :D

thought i'd show a less coding option.

Posted

Another option from another Alan. :)

(defun c:laysw (/ lay)
 (and (setq lay (tblobjname "LAYER" "APPROVED"))
      (setq lay (entget lay))
      (entmod (subst (cons 62 (- (cdr(assoc 62 lay)))) (assoc 62 lay) lay)))
 (and (setq lay (tblobjname "LAYER" "PRELIMINARY"))
      (setq lay (entget lay))
      (entmod (subst (cons 62 (- (cdr(assoc 62 lay)))) (assoc 62 lay) lay)))
 (princ)
)

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...