Jump to content

Auto Rotate Block View Frame to match Viewport


rcb007

Recommended Posts

The below is a part of a routine which allows to copy the current layout tab a multiple of times, then it would go through each layout and activate the viewport, turn on a layer number,  to zoom extents and set the scale, then go to the next layout tab and do the same.

 

I am trying to figure how to auto rotate the viewport to match the block view frame, then go onto the next.

 

  (foreach name	(layoutlist)
    (setvar 'ctab name)
    (setq n (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout"))))
    (command "-layer"
	     "Freeze"
	     "*Match*"
	     "Thaw"
	     (strcat "*Area" (itoa (cdr (assoc 71 (dictsearch n name)))))
	     ""
    )
    (command "_mspace")
    (command "zoom" "extents")
    (command "ZOOM" "Scale" "1/10xp")
    (command "_.cannoscale" "1\" = 10'")
    (command "_pspace")
  )

 

I stumbled upon this post, But was not sure how to get the rotation piece to work.

 

(defun c:foo (/ ad ll n p pv s tab)
;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-create-automatic-layouts/m-p/8155017#M371763
  (cond
    ((setq s (ssget '((0 . "text") (8 . "CHR_FIELD_MAP_TEXT") (410 . "Model"))))
     (setq s (vl-sort (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
		      '(lambda (a b) (< (cdr (assoc 1 (entget a))) (cdr (assoc 1 (entget b)))))
	     )
     )
     (setq ad (vla-get-activedocument (vlax-get-acad-object)))
     (foreach e	s
       (cond
	 ((vl-position (setq n (strcase (cdr (assoc 1 (entget e))))) (mapcar 'strcase (layoutlist)))
	  (print (strcat "Layout " n " already exists..."))
	 )
	 ((setq tab (vla-add (vla-get-layouts ad) n))
	  (setvar 'ctab n)
	  ;; Viewport hard coded based on example drawing
	  (setq	pv (vlax-invoke
		     (vla-get-paperspace ad)
		     'addpviewport
		     '(8.0694 5.03978 0.0)
		     14.875
		     10.25
		   )
	  )
	  (vlax-put pv 'viewporton -1)
	  (command "_.mspace")
	  (vlax-invoke (vlax-get-acad-object) 'zoomcenter (cdr (assoc 11 (entget e))) 50)
	  (vla-put-customscale pv (/ 1. 50))
	  (command "_.pspace")
	 )
       )
     )
    )
  )
  (princ)
)
(vl-load-com) 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-create-automatic-layouts/m-p/8158285#M371817

 

I hope this make some sense.

 

Capture.JPG

image.png

ejemplo paginacion.dwg

Edited by rcb007
Link to comment
Share on other sites

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