Jump to content

Recommended Posts

Posted (edited)

Sir,

I need help that I want a lsp which allow me to zoom in particular area in all layouts tabs at once.

Edited by pmadhwal7
Posted

An example.

;; Where the variables p1 & p2 are a list of coordinates

(foreach l (layoutlist)
  (setvar 'CTAB l)
  (vlax-invoke (vlax-get-acad-object) 'ZoomWindow p1 p2)
  ) (vl-load-com)

 

Posted

Sir example and error both are in attachment just like this I want to zoom in all layouts tabs in particular area..

20191008_142115.jpg

Posted

I just copy your code and paste it to lsp file extension and just ran this than the error occurred...

Posted
1 minute ago, pmadhwal7 said:

I just copy your code and paste it to lsp file extension and just ran this than the error occurred...

You need to feed the coordinates as I have mentioned in the first port. p1 & p2 

eg: 

(setq p1 '(0. 0. 0.))
(setq p2 '(10.0 10.0 0.0))

(foreach l (layoutlist)
  (setvar 'CTAB l)
  (vlax-invoke (vlax-get-acad-object) 'ZoomWindow p1 p2)
)
(vl-load-com)

 

Posted

But sir their are lots of layouts tabs in my drawing and as per your method if I feed manually all the coordinates than better to go one by one in all layouts

Posted

Sorry sir don't be angry I have and lsp which allow me to zoom extended in all layouts similarly I just want to zoom it in particular area I also retry your lsp but again error massage occurred..

2019-10-08_16_01_53.jpg

Posted

My replies have nothing to do anger, so here are a few questions for you to drag and push the idea to your world.

- How do you make a zoom window in AutoCAD ?

- Can you zoom window without picking two points?

Posted

Perhaps this will help.

1.  Give the command appload and load zlayout.lsp

2. Give the command zlayout.

 

Note, you will be view the same area of a layout for any one you choose.  If you want to zoom to a different window than the one defined 0,0,0 to 1,1,0, then change the values for p1 and p2 to the lower left and upper right corners of the desired window.

(defun c:zlayout (/)
(setq p1 '(0. 0. 0.))
(setq p2 '(1.0 1.0 0.0))
(foreach l (layoutlist)
  (setvar 'CTAB l)
  (vlax-invoke (vlax-get-acad-object) 'ZoomWindow p1 p2)
)
(vl-load-com)
)  

BTW, you can use the PrtScn keyboard button on your keyboard to copy the screen image to the clipboard.  Alt-PrtScn will copy the image of the currently active application.  Better yet, use the Windows 10 Snipping Tool.

zlayout.lsp

  • Like 1
Posted

May I offer an alternate solution for the user, using the code that Tharwat and lrm already started?

 

(defun c:zlayout (/ sSize vSize vCtr LLC URC)
  (vl-load-com)
  (setvar "tilemode" 0)
  (vl-cmdf "pspace")
  (graphscr)
  (princ
    "\nZoom to the area you would like viewed on all tabs. Press <ENTER> when ready... "
  )
  (getstring)
  (setq	sSize (getvar "screensize")
	vSize (getvar "viewsize")
	vCtr  (getvar "viewctr")
  )
  (setq	LLC
	 (mapcar '-
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (setq	URC
	 (mapcar '+
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (foreach l (layoutlist)
    (setvar 'CTAB l)
    (vlax-invoke (vlax-get-acad-object) 'ZoomWindow LLC URC)
  )
)  

 

Run this code, get your zoom area on one sheet, then it will use the same zoom for all sheets.

  • Like 1
Posted

I suppose I have it setup where any key will work, not just enter.

 

This version will pause on each tab so you can check whatever is in the view prior to jumping to the next.

 

(defun c:zlayout (/ sSize vSize vCtr LLC URC)
  (vl-load-com)
  (setvar "tilemode" 0)
  (vl-cmdf "pspace")
  (graphscr)
  (princ
    "\nZoom to the area you would like viewed on all tabs. Press any key when ready... "
  )
  (getstring)
  (setq	sSize (getvar "screensize")
	vSize (getvar "viewsize")
	vCtr  (getvar "viewctr")
  )
  (setq	LLC
	 (mapcar '-
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (setq	URC
	 (mapcar '+
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (setvar "nomutt" 1)
  (foreach l (layoutlist)
    (setvar 'CTAB l)
    (vlax-invoke (vlax-get-acad-object) 'ZoomWindow LLC URC)
    (princ
      "\nPress any key to continue... "
    )
    (getstring)
  )
  (setvar "nomutt" 0)
  (princ)
)

 

  • Like 1
Posted
11 hours ago, lrm said:

Perhaps this will help.

1.  Give the command appload and load zlayout.lsp

2. Give the command zlayout.

 

Note, you will be view the same area of a layout for any one you choose.  If you want to zoom to a different window than the one defined 0,0,0 to 1,1,0, then change the values for p1 and p2 to the lower left and upper right corners of the desired window.


(defun c:zlayout (/)
(setq p1 '(0. 0. 0.))
(setq p2 '(1.0 1.0 0.0))
(foreach l (layoutlist)
  (setvar 'CTAB l)
  (vlax-invoke (vlax-get-acad-object) 'ZoomWindow p1 p2)
)
(vl-load-com)
)  

BTW, you can use the PrtScn keyboard button on your keyboard to copy the screen image to the clipboard.  Alt-PrtScn will copy the image of the currently active application.  Better yet, use the Windows 10 Snipping Tool.

zlayout.lsp 197 B · 0 downloads

working fine...

Posted
10 hours ago, CHLUCFENG said:

I suppose I have it setup where any key will work, not just enter.

 

This version will pause on each tab so you can check whatever is in the view prior to jumping to the next.

 


(defun c:zlayout (/ sSize vSize vCtr LLC URC)
  (vl-load-com)
  (setvar "tilemode" 0)
  (vl-cmdf "pspace")
  (graphscr)
  (princ
    "\nZoom to the area you would like viewed on all tabs. Press any key when ready... "
  )
  (getstring)
  (setq	sSize (getvar "screensize")
	vSize (getvar "viewsize")
	vCtr  (getvar "viewctr")
  )
  (setq	LLC
	 (mapcar '-
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (setq	URC
	 (mapcar '+
		 vCtr
		 (list (* (* 0.5 vSize) (/ (car sSize) (cadr sSize)))
		       (* 0.5 vSize)
		       0.0
		 )
	 )
  )
  (setvar "nomutt" 1)
  (foreach l (layoutlist)
    (setvar 'CTAB l)
    (vlax-invoke (vlax-get-acad-object) 'ZoomWindow LLC URC)
    (princ
      "\nPress any key to continue... "
    )
    (getstring)
  )
  (setvar "nomutt" 0)
  (princ)
)

 

this is also working fine...thanks a lot to all sir

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