Author Topic: Add New Viewport by creating boundary on model space  (Read 2222 times)

0 Members and 1 Guest are viewing this topic.

Hrishikesh

  • Guest
Add New Viewport by creating boundary on model space
« 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.  
« Last Edit: July 08, 2017, 03:30:51 PM by Hrishikesh »

HasanCAD

  • Swamp Rat
  • Posts: 1422

Hrishikesh

  • Guest
Re: Add New Viewport by creating boundary on model space
« Reply #2 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.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Add New Viewport by creating boundary on model space
« Reply #3 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