Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to Create viewport from selected rectangles from model-space

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
5358 Views, 3 Replies

Lisp to Create viewport from selected rectangles from model-space

i found this lisp, but i dont want to make that rectangle and just click on a reclangle already made (and of course,make a multiple selection of reclangle from model-space).I dont mind if the lisp will generate the "n" numbers of viewport all told

 

;|------------ Viewport Creator ----------------
	    q_|_|| _\|| q_|| _\|		
						
  - Select area					
  - ask for viewport scale			
  - Go to last layout (first at right)		
  - Ask for center point of viewport		
  - Create a viewport				
  - view the selected area with the viewport	
  Create stations for Prestresed tendon		
						
------------------------------------------------
  Author: Hasan M. Asous, 2010			
	ALL RIGHT RESERVED TO ALL		
  Contact: HasanCAD @ TheSwamp.org,		
           asos2000 @ CADTutor.net		
           HasanCAD@gmail.com			
------------------------------------------------
  Version: 1      2012 07 01			
________________________________________________
					      |;

	;     q_|_|| _\|| q_|| _\|     ;
	;       Mainroutine Start      ;

(defun c:NV (/	      doc      p1	p2	 temp	  mp
	     scl      SC       cd:DWG_LayoutsList	  res
	     a	      b	       vpp	vpdoc	 vp
	    )

  (vl-load-com)
  (setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (setq p1 (getpoint "\Select objects to view:"))
  (setq p2 (getcorner p1))
  (if
    (< (car (trans p2 1 0)) (car (trans p1 1 0)))
     (setq tmp p1
	   p1  p2
	   p2  tmp
     )
     T
  )
  (setq	mp (list (/ (+ (car p1) (car p2)) 2)
		 (/ (+ (cadr p1) (cadr p2)) 2)
		 0.0
	   )
  )

  (setq	sc (cond ((getint (strcat "\nWhat is Viewport Scale 1: <"
				  (itoa	(setq sc (cond (sc)
						       (50)
						 )
					)
				  )
				  ">: "
			  )
		  )
		 )
		 (sc)
	   )
  )
  (setq	cd:DWG_LayoutsList
	 (vlax-for % (vla-get-layouts Doc)
	   (setq res (cons (list (vla-get-name %)
				 (vla-get-TabOrder %)
				 %
			   )
			   res
		     )
	   )
	 )
  )
  (setvar "CTab"
	  (caar	(vl-sort cd:DWG_LayoutsList
			 '(lambda (a b) (> (cadr a) (cadr b)))
		)
	  )
  )

  (setq VPDoc (vla-get-PaperSpace doc))
  (setq VPp (vlax-3D-point (getpoint "\nSelect Point for Viewport")))
  (setq	VP (vla-AddPViewport
	     VPDoc
	     VPp
	     (/ (- (car p2) (car p1)) sc)
	     (/ (- (cadr p2) (cadr p1)) sc)
	   )
  )
  (vla-display VP :vlax-true)
  (vla-put-mspace doc :vlax-true)
  (vla-put-activepviewport Doc VP)
  (vla-zoomcenter
    (vlax-get-acad-object)
    (vlax-3d-point mp)
    1.0
  )
  (vl-cmdf "_.zoom" (strcat (RTOS (/ 1.0 SC)) "xp"))
  (vla-regen (vla-get-activedocument (vlax-get-acad-object))
	     acActiveViewport
  )
  (vla-put-mspace doc :vlax-FALSE)
  (VLA-PUT-DisplayLocked VP :vlax-true)
)


	;     q_|_|| _\|| q_|| _\|     ;
	;       Mainroutine End        ;

(princ "\n Type  NV  to Invoke")
(princ)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Dear Sir,

 

I have work on this lisp, but not success.

Can you please help, how to operate this lisp with video.

 

Thanks.

Message 3 of 4
Anonymous
in reply to: Anonymous

Hello,

I know this is an old thread, so I might not reach anyone, but I tried this LISP and it worked a couple times(although a little differently than I thought, with the scaling), but I would love to locate a LISP that works as intended. It seems to "nearly work"!

 

Thanks,

Michael

Message 4 of 4
dlanorh
in reply to: Anonymous

Origin of lisp is HERE

 

Various partial code updates and variations

I am not one of the robots you're looking for

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report