Jump to content

viewports


rookie37

Recommended Posts

I'm going to start making a layer for my viewports

 

Can somebody please help me with a lisp program to;

 

getvar oldlayer

make layer "vport" color 49 no print

make viewport / /

setvar oldlayer

Link to comment
Share on other sites

Possibly this:

 

(defun c:vp (/ oldlay)
   (setq oldlay (getvar "clayer"))
   (setvar "cmdecho" 0)
   (if (/= (getvar "ctab") "Model")
       (progn
           (if (not (tblsearch "LAYER" "vport"))
           (command "-layer" "M" "vport" "C" "49" "vport" "P" "N" "vport" "")
           (setvar "clayer" "vport")
           ) ; end if
           (command "-vports"
               pause
               pause
           ) ; end command
           (setvar "clayer" oldlay)
       ) ; end progn
       (alert "Viewport Cannot be Drawn in Model Space.")
   ) ; end if
   (setvar "cmdecho" 1)
   (princ)
) ; end defun

Link to comment
Share on other sites

I expect I'm being dim here, but how are you loading the lisp then? Will you be loading it on each client's machine? Will it live on a USB stick?

 

Would a template still not be the easiest solution if you're having to have it portable?

 

Would it not be possible to store a template online so you can easily access it wherever you have an internet connection?

 

(sorry to ask so many questions, but setting up effective systems is a pet interest of mine :wink: )

Link to comment
Share on other sites

If I try to keep all my customizations as one type, (lisp) it is easier to remember.

 

Otherwise, I have multiple directories to find and files to update.

 

It's true that a template could already have a vport layer made and can have a viewport drawn. However, If I want another one, I make the vport layer current, draw the vport, and make the layer current that I was previously drawing in.

 

Also many of the places I work for already have a template and some don't want it touched.

Link to comment
Share on other sites

Good point about the template rookie,

 

With a template, (and the vport layer already created) you would still have to remember to switch to the vport layer before drawing your port and then switch back before drawing other objects. This obviously requires more time, and a the LISP posted is quicker as it won't duplicate the vport layer if one is already created.

 

Another way to approach the problem is to use a reactor - which I have recently learnt a bit about (with the help of ASMI and others).

 

Below is a reactor that could work with a template.

 

; Layer Director

(vl-load-com)

(vlr-command-reactor
   nil '((:vlr-commandWillstart . startCommand))
) ; end command reactor
(vlr-command-reactor
   nil '((:vlr-commandEnded . endcommand))
) ; end command reactor
(vlr-command-reactor
   nil '((:vlr-commandCancelled . cancelCommand))
) ; end command reactor

(defun startCommand (calling-reactor startcommandInfo / thecommandstart)
   (setq oldlay (getvar "clayer"))
   (setq thecommandstart (nth 0 startcommandInfo))
   (cond
       ((= thecommandstart "+VPORTS")
        (setvar "clayer" "VPORT")
       ) ; end condition
   ) ; end cond
   (princ)
) ; end startcommand

(defun endCommand (calling-reactor endcommandInfo / thecommandend)
   (setq thecommandend (nth 0 endcommandInfo))
   (cond
       ((= thecommandend "+VPORTS")
        (setvar "clayer" oldlay)
       ) ; end condition
   ) ; end cond
   (princ)
) ; end endCommand

(defun cancelCommand (calling-reactor cancelcommandInfo / thecommandcancel)
   (setq thecommandcancel (nth 0 cancelcommandInfo))
   (cond
       ((= thecommandcancel "+VPORTS")
        (setvar "clayer" oldlay)
       ) ; end condition
   ) ; end cond
   (princ)
) ; end cancelCommand

Link to comment
Share on other sites

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