Author Topic: During Loading and Closing a DWG  (Read 5435 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Re: During Loading and Closing a DWG
« Reply #15 on: October 07, 2013, 11:01:41 AM »
lol you will like this; i usually appload it.

I have loaded it in my AppLoad (added the lisp to the StartUp Suite).

I opened a drawing with the Plot Styles Display On.

I closed the drawing and saved it;

Reopened the drawing and Plot Styles Display On is still on.

Or If i trun it off manually it and reopen it; the drawing still has it turned off.

Again, i wonder if i am doing something wrong. Which I could be. (I am good at that).

Code: [Select]
(defun c:dpson () (rm:displayplotstyles t nil))
(defun c:dpsonall () (rm:displayplotstyles t t))
(defun c:dpsoff () (rm:displayplotstyles nil nil))
(defun c:dpsoffall () (rm:displayplotstyles nil t))


(defun rm:displayplotstyles (bshow ball / acdoc bvshow disp layout layouts)
  (princ "\n...Display plotstyles ")
  (vl-load-com)
  (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
  (setq layouts (vla-get-layouts acdoc))
  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (setq   bvshow (if bshow
       :vlax-true
       :vlax-false
          )
  )
  (princ (if bshow
      (progn (or *editor-reactor-close*
            (setq *editor-reactor-close*
              (vlr-editor-reactor nil '((:vlr-beginclose . resetplotstyles)))
            )
        )
        (defun resetplotstyles (a b) (alert "foo") (rm:displayplotstyles nil t) (princ))
        (vla-put-graphicswinlayoutbackgrndcolor disp 16777215)
        "ON"
      )
      (progn (vla-put-graphicswinlayoutbackgrndcolor disp 0) "OFF")
    )
  )
  (if ball
    (progn (vlax-for layout layouts
        (if (/= (vla-get-name layout) "Model")
          (vla-put-showplotstyles layout bvshow)
        )
      )
      (princ " in all layouts.\n")
    )
    (progn (vla-put-showplotstyles (vla-get-activelayout acdoc) bvshow)
      (princ " in current layout.\n")
    )
  )
  (vla-regen acdoc acallviewports)
  (prin1)
)
(princ (strcat "\n...DisplayPlotStyles is loaded || DPSON, DPSONALL, DPSOFF, DPSOFFALL...\n"))
(prin1)

Please see the workflow I am using and with the above code and still can not get it. Am I missing something?
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: During Loading and Closing a DWG
« Reply #16 on: October 07, 2013, 11:20:20 AM »
Since the reactor is not working for you .. give this one a try. I don't use the startup suite to load lisp routines so you'll have to test that it loads each time a drawing is opened or if it's per session.



Code: [Select]
(defun c:dpson () (rm:displayplotstyles t nil))
(defun c:dpsonall () (rm:displayplotstyles t t))
(defun c:dpsoff () (rm:displayplotstyles nil nil))
(defun c:dpsoffall () (rm:displayplotstyles nil t))
(defun rm:displayplotstyles (bshow ball / acdoc bvshow disp layout layouts)
  (princ "\n...Display plotstyles ")
  (vl-load-com)
  (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
  (setq layouts (vla-get-layouts acdoc))
  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (setq bvshow (if bshow
:vlax-true
:vlax-false
       )
  )
  (princ (if bshow
   (progn
;;;      (or *editor-reactor-close*
;;;       (setq *editor-reactor-close*
;;;      (vlr-editor-reactor nil '((:vlr-beginclose . resetplotstyles)))
;;;       )
;;;   )
;;;   (defun resetplotstyles (a b) (alert "foo") (rm:displayplotstyles nil t) (princ))
  (vla-put-graphicswinlayoutbackgrndcolor disp 16777215)
  "ON"
   )
   (progn (vla-put-graphicswinlayoutbackgrndcolor disp 0) "OFF")
)
  )
  (if ball
    (progn (vlax-for layout layouts
     (if (/= (vla-get-name layout) "Model")
       (vla-put-showplotstyles layout bvshow)
     )
   )
   (princ " in all layouts.\n")
    )
    (progn (vla-put-showplotstyles (vla-get-activelayout acdoc) bvshow)
   (princ " in current layout.\n")
    )
  )
  (vla-regen acdoc acallviewports)
  (prin1)
)
;; This should run the reset when the lisp loads at startup
(rm:displayplotstyles nil t)
(princ (strcat "\n...DisplayPlotStyles is loaded || DPSON, DPSONALL, DPSOFF, DPSOFFALL...\n"))
(prin1)


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Re: During Loading and Closing a DWG
« Reply #17 on: October 07, 2013, 12:37:38 PM »
Where do you typicall load your lisp routines from and how? (I only know the appload method).
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: During Loading and Closing a DWG
« Reply #18 on: October 07, 2013, 12:42:51 PM »
Where do you typicall load your lisp routines from and how? (I only know the appload method).


I have a custom menu that is loaded that has a *.MNL file associated with it. Within this MNL file is a lisp that looks at a directory and loads all lisp routines found within.


There are multiple examples here on the TheSwamp that show how to do this.


Good luck!  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Re: During Loading and Closing a DWG
« Reply #19 on: October 07, 2013, 12:43:47 PM »
Great! Thank you again for your time! Means alot!
Civil3D 2020