Jump to content

Recommended Posts

Posted

Good morning, evening, or night. Depending on what part of the world you live in. I need help finding a lisp that will set all of my VPs to Hidden and Lock them too. I'm not sure if this can be done with just one lisp or if two are required. Please let me know and thanks in advance.

Posted

I am assuming you mean, Hidden linetype? and lock the viewport scale?

 

Sorry if I am missing something, half asleep as usual :P

 

Lee

Posted

This is a reactor that will lock all viewports upon saving - you cannot change the linetype of a viewport entity it seems... :(

 

(defun Make_Reactor ()
 (vl-load-com)
 (if (not vport:reactor)
   (setq vport:reactor
      (vlr-command-reactor nil '((:vlr-commandWillStart . vpPrompt)))))
 (princ))
(Make_Reactor)

(defun vpPrompt (Reac args / ss i vp ent obj)
 (if (and (= (car args) "QSAVE")
          (setq ss (ssget "X" '((0 . "VIEWPORT"))))
          (not (zerop (setq i (sslength ss)))))
   (progn
     (setq vp i)
     (while (not (minusp (setq i (1- i))))
      (setq ent (ssname ss i)
            obj (vlax-ename->vla-object ent))
      (if (not (vl-catch-all-error-p
                  (vl-catch-all-apply
                    'vla-put-DisplayLocked (list obj 1))))
          (princ)))
    (princ (strcat "\n" (rtos vp) " Viewport(s) Locked."))))
 (princ))

 

REMEMBER: a reactor is to be "loaded" but not "run". - it Runs itself.

Posted

Very cool. Thanks. The Hidden part is was reffering to is the command that causes the the object in the VP to plot hidden. If you click the VP and then right click it, you have the options to define what the objects in the VP will plot like. It is under the SHADE PLOT menu.

Posted

Will see what I can do - I think I could fit that into the reactor as well :D

Posted

Ok, I have re-written the whole LISP to make it more efficient - hopfully it still works!

 

(defun make_reactor  ()
 (vl-load-com)
 (if (not vport:reactor)
   (setq vport:reactor
      (vlr-command-reactor nil '((:vlr-commandwillstart . vpprompt)))))
 (princ))
(make_reactor)

(defun vpPrompt (Reac args / ss Lck nLck)
 (if (and (= (car args) "QSAVE")
          (setq ss (ssget "X" '((0 . "VIEWPORT")))))
   (progn
     (setq Lck 0 nLck 0)
     (foreach vp (mapcar 'vlax-ename->vla-object
                     (mapcar 'cadr(ssnamex ss)))
   (if (vl-catch-all-error-p
         (vl-catch-all-apply
           'vla-put-DisplayLocked (list vp :vlax-true)))
     (setq nLck (1+ nLck))
     (setq Lck  (1+ Lck)))
   (vla-put-shadeplot vp acShadePlotHidden))
     (princ (strcat "\n" (itoa nLck) " Vieport(s) locked"
            (if (/= 0 Lck)
              (strcat ", " (itoa Lck) " were on locked layer! ") "."))))
   (princ "\n<!> No Viewports Found <!>"))
 (princ))

 

Also allows for any on Locked Layers.

Posted

You my friend are a an AutoCad GOD!!! Thank you so so much for bailing me out again.

Posted
You my friend are a an AutoCad GOD!!! Thank you so so much for bailing me out again.

 

Thanks Jadeous, glad it works for you :)

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