rookie37 Posted November 13, 2008 Share Posted November 13, 2008 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 13, 2008 Share Posted November 13, 2008 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 Quote Link to comment Share on other sites More sharing options...
rookie37 Posted November 14, 2008 Author Share Posted November 14, 2008 It works Great! Thank you! Quote Link to comment Share on other sites More sharing options...
Strix Posted November 14, 2008 Share Posted November 14, 2008 is that necessary? wouldn't you just set up a template to start all drawings from? Quote Link to comment Share on other sites More sharing options...
rookie37 Posted November 14, 2008 Author Share Posted November 14, 2008 Unfortunatly yes I'm a contractor I use many machines with many flavors of autocad with different startup templates Quote Link to comment Share on other sites More sharing options...
Strix Posted November 15, 2008 Share Posted November 15, 2008 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: ) Quote Link to comment Share on other sites More sharing options...
rookie37 Posted November 16, 2008 Author Share Posted November 16, 2008 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 16, 2008 Share Posted November 16, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.