TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hrishikesh on July 08, 2017, 03:19:49 PM

Title: Add New Viewport by creating boundary on model space
Post by: Hrishikesh on July 08, 2017, 03:19:49 PM
Hi All,
I tried to make lisp which create viewport boundary on model space & create viewport on layout for the same.
I am not a professional lisp programer, I am working on Autocad for 15 years, your comments & suggestions help me a lot to learn more about lisp programming.

Thanks
Hrishikesh

Code - Auto/Visual Lisp: [Select]
  1. (defun C:NEWVP  (/ PT1 PT2 PTV SC)
  2.  (prompt "Select layout on which you want to create viewport")
  3.  (setvar "cmdecho" 0)
  4.  (vl-cmdf "undo" "_BE" "")
  5.  (setq OL (getvar "clayer"))
  6.  (if (/= (tblsearch "LAYER" "VIEWPORTS"))
  7.  (vl-cmdf "-LAYER" "M" "Viewports" "C" "8" "" "")
  8.  )
  9.  (vl-cmdf "-SCALELISTEDIT" "_R" "_Y" "_E")
  10.  (setvar "tilemode" 1)
  11.  (prompt "Draw boundary around modelspace object for making viewport")
  12.  (setq PT1 (getpoint "\nSelect First Corner for viewport boundary"))
  13.  (setq PT2 (getcorner PT1 "\nSelect opposite Corner"))
  14.  (vl-cmdf "._Rectang" PT1 PT2)
  15.  (setq sc (/ (getreal "\nEnter scale for new viewport without inch sign (Example: 1/8, 1/2, 3/4 or 1 etc.): ") 12))
  16.  (vl-cmdf "._copybase" PT1 "_L" "")
  17.  (setvar "tilemode" 0)
  18.  (setq PTV (getpoint "\nSelect insertion point for new viewport"))
  19.  (vl-cmdf "._pasteclip" PTV "")
  20.  (vl-cmdf "._scale" "_L" "" PTV sc)
  21.  (vl-cmdf "MVIEW" "_O" "_L")
  22.  (vl-cmdf "_.MSPACE")
  23.  (vl-cmdf "_Zoom" "_W" PT1 PT2)
  24.  (vl-cmdf "_.PSPACE")
  25.  (vl-cmdf "MVIEW" "_L" "ON" "_L" "")
  26.  (vl-cmdf "undo" "_E" "")
  27.  (setvar "clayer" OL)
  28.  (terpri)
  29. ) ;_ end of defun
  30.  (prin1)
  31.  
Title: Re: Add New Viewport by creating boundary on model space
Post by: HasanCAD on July 18, 2017, 04:05:07 AM
This post
https://www.theswamp.org/index.php?topic=42149.msg473152#msg473152
Title: Re: Add New Viewport by creating boundary on model space
Post by: Hrishikesh on July 20, 2017, 12:50:56 AM
Thank you Hasan sahab,
Your program is very good & easy to use.
I wll definitely use this one.
Title: Re: Add New Viewport by creating boundary on model space
Post by: HasanCAD on July 24, 2017, 08:19:35 AM
Thank you Hasan sahab,
Your program is very good & easy to use.
I wll definitely use this one.
It is my pleasure