Author Topic: Auto Layering  (Read 15743 times)

0 Members and 1 Guest are viewing this topic.

Jim Yadon

  • Guest
Re: Auto Layering
« Reply #30 on: August 25, 2006, 05:30:19 PM »
Now that definitely goes on the list of strangest thread mutations ever.

On a return note, I just want to add that if you can program in VB, LISP is not a big deal. There are a good many instances I've found where LISP actually performs better than VB. before I got involved in my Linux stuff, I was amazed at the power of reactors. It had prompted me to rewrite some of the LISPs I had written years ago.

Again, strictly my opinion.

So Greg, would you go put this bucket in the corner of that round room over there? :)

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Auto Layering
« Reply #31 on: August 25, 2006, 05:41:19 PM »
So Greg, would you go put this bucket in the corner of that round room over there? :)

Over there ?

*points aimlessly*

AVCAD

  • Guest
Re: Auto Layering
« Reply #32 on: September 05, 2007, 11:58:36 AM »
create your block on layer 0 and then in the button (if you use one) jsut set  the layer before the insert

something like...

-layer;make;newlayer;color;yellow;newlayer;-insert;block;

making a new layer will always make it current and if the layer is already existing it will just make it current

blocks created on layer 0 will always take the layer and colors associated with whatever layer it is inserted on.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Auto Layering
« Reply #33 on: October 15, 2007, 10:41:59 AM »
For what it's worth: here's what I use.  Now this hooks into ADT using the AECGENERATELAYERKEY function to generate standard AEC Layers.  Just replace (setq lname (AECGENERATELAYERKEY "ANNOBJ")) with (setq lname "MyTextLayer").  Wrote this back in 2000i - been working flawlessly ever since.  If you need help modifying I'll help as time allows . . ..


Code: [Select]
(vl-load-com)
;;; Set a layer current ;
;;; If pclayer is T the previous clayer string ;
;;; is saved in the variable "jb%oldClayer" ;
;;; ;
(defun jb:setclayer  (lname pclayer / layer)
  (if pclayer(setq jb%oldClayer(getvar "clayer")))
  (if (tblsearch "layer" lname)
    (setq layer(vla-item(vla-get-layers (vla-get-activedocument(vlax-get-acad-object)))lname))
    (setq layer(vla-add(vla-get-layers (vla-get-activedocument(vlax-get-acad-object)))lname)))
  (vla-put-LayerOn layer 1)
  (vlax-put-property layer 'lock :vlax-false)
  (vl-catch-all-apply 'vla-put-Freeze (list layer :vlax-false))
  (vla-put-ActiveLayer (vla-get-activedocument(vlax-get-acad-object)) layer))

;;; ReSet jb%oldClayer ;
;;; sets jb%oldClayer to nil ;
(defun jb:resetclayer  ( / layer doc)
  (if (and jb%oldClayer
  (tblsearch "layer" jb%oldClayer))
    (progn (setq layer (vla-item (vla-get-layers (vla-get-activedocument(vlax-get-acad-object))) jb%oldClayer))
           (vla-put-LayerOn layer 1)
           (vlax-put-property layer 'lock :vlax-false)
           (vl-catch-all-apply 'vla-put-Freeze (list layer :vlax-false))
           (vla-put-ActiveLayer (vla-get-activedocument(vlax-get-acad-object)) layer)))
  (setq jb%oldClayer nil)
  )


;;; Command Will Start ;
 (defun jb:AnnoCommandWillStart(calling-reactor commands / lname)
   (cond((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT" "TEXT"
                                      "-TEXT" "LEADER" "QLEADER" "MLEADER"))
(setq lname (AECGENERATELAYERKEY "ANNOBJ")))

        ((member (car commands) (list "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
                                      "DIMCONTINUE" "DIMDIAMETER" "DIMANGULAR"
                                      "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (setq lname (AECGENERATELAYERKEY "DIMLINE")))
         )
   (if lname(jb:setclayer lname T)))

;;; Command Ended ;
 (defun jb:AnnoCommandEnded(calling-reactor commands / dwgdimscale)
   (cond ((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT"
      "TEXT" "-TEXT" "LEADER" "QLEADER" "MLEADER"
      "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
      "DIMCONTINUE" "DIMDIAMETER"
      "DIMANGULAR" "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (jb:resetclayer))
)
   )

;;; Command Cancelled ;
 (defun jb:AnnoCommandCancelled(calling-reactor commands / )
   (cond((member (car commands) (list "MTEXT" "-MTEXT" "DTEXT"
      "TEXT" "-TEXT" "LEADER" "QLEADER" "MLEADER"
      "DIMLINEAR" "DIMALIGNED" "DIMBASELINE"
      "DIMCONTINUE" "DIMDIAMETER"
      "DIMANGULAR" "DIMRADIUS" "DIMORDINATE" "QDIM"))
         (jb:resetclayer))
)
   )


;;; Construct the Command Reactor ;
(defun jb::AnnoConstructCommandReactor  (/)
  (if (= (type *jbAnnoCommandReactor*) 'VLR-Command-Reactor)
    (progn (vlr-remove *jbAnnoCommandReactor*) (setq *jbAnnoCommandReactor* nil)))
  (if (/= (type *jbAnnoCommandReactor*) 'VLR-Command-Reactor)
    (setq *jbAnnoCommandReactor*
           (VLR-Command-Reactor
             "jbTools Annotation Command Reactor" ; Data associated with the editor reactor
             ;; call backs
             '
              ((:VLR-commandWillStart . jb:AnnoCommandWillStart)
               (:VLR-commandEnded . jb:AnnoCommandEnded)
               (:VLR-commandCancelled . jb:AnnoCommandCancelled)
       )) ;_ end of vlr-editor-reactor
          ))

  (if (not (vlr-added-p *jbAnnoCommandReactor*))
    (progn
    (vlr-add *jbAnnoCommandReactor*)
    (vlr-set-notification *jbAnnoCommandReactor* 'active-document-only)))
  (princ))


;;; load reactors ;

   
(if jb::AnnoConstructCommandReactor
  (jb::AnnoConstructCommandReactor))

James Buzbee
Windows 8