Author Topic: Create a reactor to recall a layerstate Updated 5-15-05  (Read 3712 times)

0 Members and 1 Guest are viewing this topic.

sourdough

  • Bull Frog
  • Posts: 367
Create a reactor to recall a layerstate Updated 5-15-05
« on: May 12, 2005, 05:32:34 PM »
Would like to find someone who can create a reactor that will recall a layerstate that is the same name as a tablayout name. I saw a example of a reactor here but can't seem to put it together to do this task. Any help would be appreciated.

Mike in Alaska
and new here...

Thanks in Advan :)

Okay... Update time... this works much better... although doesn't have a good error trap for no layerstates... but the logic works if you use them for all tab layouts... including model tab. So here is the update:


Code: [Select]


;;; This is the updated Reactor Restore Layerstates per Tablayout Name
;;; with Viewport regen
;;; A collective effort with Jürg Menz who wrote the bulk of the code
;;; Afralisp.com Alan Bates and Jeff_M (bullfrog) advice and help
;;; Doggarn (C) 2005 by Michael J. Perry
;;; email : doggarn@nc.rr.com



(defun c:vr ()

(vl-load-com)

(setq thisdrawing
       (vla-get-activedocument
               (vlax-get-acad-object)))

(vla-Regen thisdrawing acAllViewports )

(princ)

);defun









; = Tablayout-Reator.lsp ===============================================================
;
; - Initialize ActiveX support
(vl-load-com)


(setq *acad* (vlax-get-acad-object);get the application
      doc (vla-get-activedocument *acad*);get the current drawing
      LayMan (vla-getinterfaceobject *acad* "AutoCAD.AcadLayerStateManager.16");get the LStateManager acad 2005
)




; Return the list of names


;
; - Reactors ------------------------------------------------------------------
;
; - If not set, initialize DocManager-Reactor
(or Me:ReaDma
 (setq Me:ReaDma (VLR-DocManager-Reactor
                  nil
                 '(
                   (:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
                  )
                 )
 )
)
; - If not set, initialize Command-Reactor
(or Me:ReaCom

 (setq Me:ReaCom (VLR-Command-Reactor
                  nil
                 '(
                   (:VLR-commandEnded . MeCommandEndedCallbacks)
                  )
                 )
 )
)
;
; - Notifications -------------------------------------------------------------
;
; - CommandEnded notifications






(defun MeCommandEndedCallbacks (Rea Arg)
 (MeDoCmdEndedStuff Arg)
 (princ)
)
; - DocToBeDestroyed notifications
(defun MeDocToBeDestroyedCallbacks (Rea Arg)
 (MeDoCloseStuff)
 (princ)
)
;
; - Subs ----------------------------------------------------------------------
;
; - Command ended function
(defun MeDoCmdEndedStuff (Arg / CurCmd)
 (setq CurCmd (strcase (car Arg)))
 (cond
  ((wcmatch CurCmd "LAYOUT_CONTROL,TILEMODE")
 
  (setq state (getvar "ctab"))
 
   
  (vla-setdatabase layman (vla-get-database doc))
(vla-restore layman state)

   (princ (strcat "\nLayState Current = " state " \n"))
(c:vr)
(princ)
  )
  ;;; other command ended dependent functions
 )
 (princ)
)
; - Reactor cleanup function
(defun MeDoCloseStuff ( / VarLst)
 (setq VarLst (MeGetReaVars))
 (mapcar 'VLR-remove (mapcar 'eval VarLst))
 (mapcar '(lambda (l) (set l nil)) VarLst)
 (princ)
)
; - Collect global reactor variables
(defun MeGetReaVars ( / RetVal)
 (foreach memb (atoms-family 1)
  (if (wcmatch (strcase memb) "ME:REA*")
   (setq RetVal (cons memb RetVal))
  )
 )
 (mapcar 'read RetVal)
)

(princ)
 
;end defun


LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #1 on: May 12, 2005, 05:40:05 PM »
Mike ... Weaver ... Alaska ... as in one of the tin foil helmet crew from the old take5?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

sourdough

  • Bull Frog
  • Posts: 367
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #2 on: May 12, 2005, 06:43:00 PM »
see update above
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #3 on: May 12, 2005, 07:05:26 PM »
This should point you to the errors of your ways :)
Code: [Select]

(setq *acad* (vlax-get-acad-object);get the application
      doc (vla-get-activedocument *acad*);get the current drawing
      LayMan (vla-getinterfaceobject *acad* "AutoCAD.AcadLayerStateManager");get the LStateManager
      )
(vla-setdatabase layman (vla-get-database doc));tell it to use this drawing
(vla-restore layman "test");restore the "TEST" saved layer state

sourdough

  • Bull Frog
  • Posts: 367
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #4 on: May 12, 2005, 07:39:39 PM »
see update above
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #5 on: May 12, 2005, 08:03:24 PM »
Change the line:
(vla-restore layman (getvar "ctab"))

to this:
(vl-catch-all-apply 'vla-restore (list layman (getvar "ctab")))

That should do it

sourdough

  • Bull Frog
  • Posts: 367
many thanks.... for my first visit.... I have gained so much
« Reply #6 on: May 13, 2005, 01:47:38 PM »
It worked perfect.... and I'm off to the submarine races....

Thanks again... this is the site... and the talent here is the best by far.

Mike in Alaska
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #7 on: May 16, 2005, 10:10:57 AM »
Nice to see my samples goes around the world...

Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

sourdough

  • Bull Frog
  • Posts: 367
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #8 on: May 16, 2005, 10:30:30 AM »
And I would like to add that it was your original code and a idea that
has been in the works for over a year on my part that allowed me to
finish this aspect of a tool I use in everyday cad work... but I have more,
and a suite of utility tab layouts and layerstates that is easy and faster to use is about done and will be shown here soon.

Thanks all, and especially Jürg Menzi

Mike in Alaska
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Create a reactor to recall a layerstate Updated 5-15-05
« Reply #9 on: May 16, 2005, 10:43:06 AM »
Thx for the flowers Mike...

One point you should change in the code:
Code: [Select]
((wcmatch CurCmd "LAYOUT_CONTROL,tilemode")
;must be:
((wcmatch CurCmd "LAYOUT_CONTROL,TILEMODE")

otherwise it's not watched because of 'strcase (car Arg)'

Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18