View Full Version : Run the -VPort command normally then move newly created Viewports onto a Layer
Mr Cory
2007-03-11, 09:42 PM
What im trying to do is create a simple lisp to invoke the _.-vport command and then turn the newly created vport ot the vport layer. The trouble is when i add the command to change the new vport to the vp layer i can no longer specify the placing of the vp.
(defun c:vp1()
(command "_.-vports" "vp" "l")
(princ)
)
(vp = change layer command) would like to know how to let the vports command pick the points and specify the alinement of the vps (Im also creating lisp for 1,2,3,4 vps)
Any help will be greatly appreciated!
What im trying to do is create a simple lisp to invoke the _.-vport command and then turn the newly created vport ot the vport layer. The trouble is when i add the command to change the new vport to the vp layer i can no longer specify the placing of the vp.
(defun c:vp1()
(command "_.-vports" "vp" "l")
(princ)
)
(vp = change layer command) would like to know how to let the vports command pick the points and specify the alinement of the vps (Im also creating lisp for 1,2,3,4 vps)
Any help will be greatly appreciated!
For the layer portion, maybe do something like:
(defun c:vp1()
(setq oldlayer (getvar "clayer"))
(if (tblsearch "layer" "mylayer");check if the layer exists
(setvar "clayer" "mylayer");if its there; set it current
(command "-layer" "m" "mylayer" "c" 1 "mylayer" "");if not there, make it with red color
)
(command "_.-vports" ...);create your viewports or ?
(setvar "clayer" oldlayer); Set the layer back the way it was.
(princ)
)
For the other part: Are you wanting to supply the points, instead of the user? And what do you mean by alignment? I need a little more info on what you are trying to do there... Maybe make a list of the steps you are trying to accomplish (pseudo code).
Mr Cory
2007-03-12, 01:30 AM
Sorry, i already have the layer changing lisp
(defun c:vp()
(setq ss1 (ssget) ; Get selection set.
) ;_ End setq.
(command "_.chprop" ss1 "" "la" "_Vports" "")
(princ)
) ;_ End C:vp.
Thats the term "user input" I would like user input. I dont know how to write that into lisps.
Alignment - If you try the _.-vports command you get prompted for how you want the vports to be placed. (only for 2 or 3 vports) for 2 vports its vert or horiz. Probably easier if you try the command.
Basically it would be
type vp1 or vp2 or vp3 or vp4
For vp2 and vp3 specify how they are to be placed (user input)
pick 1st point of rectangle (user input)
pick 2nd point (user input)
then lisp would change the new vport to the vp layer.
ccowgill
2007-03-12, 12:39 PM
What im trying to do is create a simple lisp to invoke the _.-vport command and then turn the newly created vport ot the vport layer. The trouble is when i add the command to change the new vport to the vp layer i can no longer specify the placing of the vp.
(defun c:vp1()
(command "_.-vports" "vp" "l")
(princ)
)
(vp = change layer command) would like to know how to let the vports command pick the points and specify the alinement of the vps (Im also creating lisp for 1,2,3,4 vps)
Any help will be greatly appreciated!that is one of the programs I just wrote, however I used a reactor to accomplish this. I was sick of drawing a viewport and forgetting to place it on the viewport layer, then printing out the drawing and having the viewport show up. You might want to remove the first part of the program, I placed the new program in the same file as a program that uses reactors to switch to the dim layer when creating dimensions and leaders. You just activate the command like normal, and it will take care of the layer switch. You also need to change the layer, I have it set to Viewport, as that is our company standard.
*edit I must apologize, my code had some lines that wouldn't allow it to run on systems not tied into my network, I have modified it for others benefit
Mr Cory
2007-03-12, 09:19 PM
Hay i got a lil lost lol. I couldnt see where to type in what layer the vp is to go on and which program i should be using lol Sorry to be a pain!
ccowgill
2007-03-13, 12:36 PM
Hay i got a lil lost lol. I couldnt see where to type in what layer the vp is to go on and which program i should be using lol Sorry to be a pain!try the below in red, it isnt a pain
;; Check if Dim_Reactor is loaded in the task otherwise load it ( Do NOT load a reactor more than once )
(if (not Dimwillstart_Reactor )
(setq Dimwillstart_Reactor (vlr-command-reactor nil '((:vlr-commandwillstart . My_Dimstart_Command ))) )
( ) ;; The reactor is already loaded
)
(if (not Dimended_Reactor )
(setq Dimended_Reactor (vlr-command-reactor nil '((:vlr-commandended . My_Dimend_Command ))) )
( ) ;; The reactor is already loaded
)
(if (not Dimcancelled_Reactor )
(setq Dimcancelled_Reactor (vlr-command-reactor nil '((:vlr-commandcancelled . My_Dimcancel_Command ))) )
( ) ;; The reactor is already loaded
)
(if (not VPwillstart_Reactor )
(setq VPwillstart_Reactor (vlr-command-reactor nil '((:vlr-commandwillstart . My_VPstart_Command ))) )
( ) ;; The reactor is already loaded
)
(if (not VPended_Reactor )
(setq VPended_Reactor (vlr-command-reactor nil '((:vlr-commandended . My_VPend_Command ))) )
( ) ;; The reactor is already loaded
)
(if (not VPcancelled_Reactor )
(setq VPcancelled_Reactor (vlr-command-reactor nil '((:vlr-commandcancelled . My_VPcancel_Command ))) )
( ) ;; The reactor is already loaded
)
;;; Function used as Callbacks when the event fires / reactor triggers
(defun My_Dimstart_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if
(or
(= (car In_Command ) "QLEADER" )
(= (car In_Command ) "DIMALIGNED" )
(= (car In_Command ) "DIMLINEAR" )
(= (car In_Command ) "DIMCONTINUE" )
(= (car In_Command ) "DIMANGULAR" )
)
(if (tblsearch "LAYER" "As-Recorded Dim")
(progn
(setq currentlayer (getvar "clayer"))
(setvar "clayer" "As-Recorded Dim");dim layers are here
);end progn
(progn
(setq currentlayer (getvar "clayer"))
(setvar "clayer" "Dim");and here, depending on whether our drawings are as-recorded or not
);END PROGN
);end if
( ) ;; The last command was not qleader
);end if
(princ)
);end defun
(defun My_Dimend_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if
(or
(= (car In_Command ) "QLEADER" )
(= (car In_Command ) "DIMALIGNED" )
(= (car In_Command ) "DIMLINEAR" )
(= (car In_Command ) "DIMCONTINUE" )
(= (car In_Command ) "DIMANGULAR" )
)
(PROGN
(setvar "clayer" currentlayer)
);END PROGN
( ) ;; The last command was not a dimension command
);end if
(princ)
);end defun
(defun My_Dimcancel_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if
(or
(= (car In_Command ) "QLEADER" )
(= (car In_Command ) "DIMALIGNED" )
(= (car In_Command ) "DIMLINEAR" )
(= (car In_Command ) "DIMCONTINUE" )
(= (car In_Command ) "DIMANGULAR" )
)
(PROGN
(setvar "clayer" currentlayer)
);END PROGN
( ) ;; The last command was not a dimension command
);end if
(princ)
);end defun
(defun My_VPstart_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if (or (= (car In_Command ) "MVIEW" )
(= (car In_Command ) "-VPORTS" )
(= (car In_Command ) "VPORTS" )
)
(progn
(setq currentlayer (getvar "clayer"))
(setvar "clayer" "Viewport"); viewport layer is listed here
);end progn
( ) ;; The last command was not qleader
);end if
(princ)
);end defun
(defun My_VPend_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if (or (= (car In_Command ) "MVIEW" )
(= (car In_Command ) "-VPORTS" )
(= (car In_Command ) "VPORTS" )
)
(setvar "clayer" currentlayer);this line switches back to the original layer
( ) ;; The last command was not a dimension command
);end if
(princ)
);end defun
(defun My_VPcancel_Command (In_ReactorName In_Command / )
;(alert (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is qleader
(if (or (= (car In_Command ) "MVIEW" )
(= (car In_Command ) "-VPORTS" )
(= (car In_Command ) "VPORTS" )
)
(setvar "clayer" currentlayer);this one switches back if the command is canceled
( ) ;; The last command was not a dimension command as you can see, I use one form over and over and just switch out the commands and layers, dimension should be viewport in this line, although it is a comment, it doesnt really matter.
);end if
(princ)
);end defun
;|;; How to remove the Reactor :
(vlr-remove Dimwillstart_Reactor )
(vlr-remove Dimended_Reactor )
;;; How to clear the place holder :
(setq My_Insert_Command_Reactor nil )
|;
Mr Cory
2007-03-13, 08:42 PM
Command: (LOAD "Z:/10 - ADT System Files/User/Support/View Ports.lsp")
MY_VPCANCEL_COMMAND
Command:
Command:
Command:
Command:
Command: _-vports ; error: An error has occurred inside the *error*
functioninvalid AutoCAD command: nil
Specify corner of viewport or
[ON/OFF/Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4] <Fit>:
Specify opposite corner: Regenerating model.
Command: Specify opposite corner:
That is what i get when i try to create a viewport, i must be doing something wrong?
ccowgill
2007-03-13, 09:28 PM
could you post a copy of a test drawing, I would like to run the modified program in the drawing you are attempting to run it in. my assumption is, maybe the layer doesnt exist?
Mr Cory
2007-03-14, 01:49 AM
The layer exists a.
aaronic_abacus
2007-03-14, 03:00 AM
;This autolisp program creates view ports on a specific layer.
;Just replace layer 0 with the desired layer.
(DEFUN C:CVL (/ CL CMDE LP)
(PROMPT "\n*CREATE VIEWPORTS ON LAYER* ")
(SETQ CL (GETVAR "CLAYER"))
(SETQ CMDE (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 1)
(COMMAND "LAYER" "M" "0" "S" "0" "")
(COMMAND "VPORTS")
(SETQ LP 1)
(WHILE LP
(IF (= (GETVAR "CMDACTIVE") 1) (COMMAND PAUSE) (SETQ LP NIL))
);END LP
(SETVAR "CLAYER" CL)
(SETVAR "CMDECHO" CMDE)
(PRINC)
);END CVL
Mr Cory
2007-03-14, 03:08 AM
Nice and simple i like cheers for that!
ccowgill, you say your code works for dimensions?
Mr Cory
2007-03-14, 03:11 AM
ccowgill, It wouldnt be a ADT thing would it?
ccowgill
2007-03-14, 03:43 PM
The layer exists a.I have tested it and it appears to work, I dont know if it is an ADT thing or not. it does not appear to be case sensitive either. If it was a layer name it would display this error
DIMLINEAR ; error: AutoCAD variable setting rejected: "clayer" "Dim"
; reset after error
yes it applies to dimensions to, the first three defuns apply to the dimension commands, you can change the layer name there as well.
Mr Cory
2007-03-14, 08:35 PM
Sweet ill have to have a play cheers for that!
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.