Viewport LSP

Viewport LSP

heather_o
Enthusiast Enthusiast
2,413 Views
14 Replies
Message 1 of 15

Viewport LSP

heather_o
Enthusiast
Enthusiast

Hello All - 

 

I'm wanting to create a lsp routine that will toggle between viewport configurations.  Toggle from single viewport to Two: Vertical.

is this possible?

Thanks!!

0 Likes
Accepted solutions (1)
2,414 Views
14 Replies
Replies (14)
Message 2 of 15

hak_vz
Advisor
Advisor
Accepted solution

I rarely work with multiple viewports so maybe I'm wrong but try this:

(defun c:tv nil (command "-vports" "T"))

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 15

heather_o
Enthusiast
Enthusiast

Thanks!  That brings up the viewport dialog box.  How would I have the routine toggle between Single and Two:Vertical?

Thank you so much for your help!

0 Likes
Message 4 of 15

hak_vz
Advisor
Advisor

At my side it works without showing dialog box. Create two vertical viewports and it should work  correctly. Other option is to click [+] on upper left side of viewport and use option "Maximize vievport".

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 15

heather_o
Enthusiast
Enthusiast

I got it to work!  Thanks you so much!

0 Likes
Message 6 of 15

hak_vz
Advisor
Advisor

Glad to be of help!

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 15

rolisonfelipe
Collaborator
Collaborator

IT IS POSSIBLE FOR A POLYLINE TO TURN A VIEWPORT TO LIMIT A REGION OF THE IMAGE THAT I WANT TO SHOW IN THE VIEW PORT, LEAVING THE MODEL IN SCALE TO LAYOUT.

0 Likes
Message 8 of 15

Sea-Haven
Mentor
Mentor

Yes !

 

There is lots of rectang to layout examples do a google.

 

 

0 Likes
Message 9 of 15

hak_vz
Advisor
Advisor

@rolisonfelipe wrote:

IT IS POSSIBLE FOR A POLYLINE TO TURN A VIEWPORT TO LIMIT A REGION OF THE IMAGE THAT I WANT TO SHOW IN THE VIEW PORT, LEAVING THE MODEL IN SCALE TO LAYOUT.


I don't understand completely what you are asking for. Check this link for a code for clipping images, viewports and similar, if this is what you are looking for.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 10 of 15

rolisonfelipe
Collaborator
Collaborator

rolisonfelipe_0-1627473528179.png

I have a DRAWING FULL OF LAYERS AND A BACKGROUND IMAGE IN THE MODEL, BUT I HAVE A LIMIT THAT I WOULD NOT LIKE TO PRESENT IN THE LAYOUT, ALL EXTERNAL THE CYAN LINE, SHOULD NOT GO TO THE LAYOUT. AS IT IS THE MUNICIPAL LIMIT WITH MANY VERTICES, I THINK An LSP TO COPY THAT SAME LIMIT IN THE SAME POSITION MODEL FOR THE LAYOUT IS POSSIBLE WITH 1XP SCALE, THEN IT IS ONLY FORMATTING WORK, THANKS FOR THE HELP!!!!

0 Likes
Message 11 of 15

ВeekeeCZ
Consultant
Consultant

Say you have a closed polyline as a boundary - as it looks it is. Then this routine of mine could help you. 

Note that there are two last lines commented out - routine is originally made for export to the separated file.

 

(vl-load-com)
(defun c:ExtrimExport ( / :VPMatchModel s i x f)    ; Extrim using Export-Layout
  
  (defun :VPMatchModel (ss / cad doc ss i obj cen)  ; Match scale with Model
    (setq cad (vlax-get-Acad-Object)
	  doc (vla-get-ActiveDocument cad))
    
    (vla-put-MSpace doc :vlax-true)
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-ActivePViewport (list doc obj))))
	(progn
	  (vlax-invoke cad 'ZoomCenter (vlax-get obj 'Center) 1.0)
	  (vla-put-CustomScale obj 1.))))
    (vla-put-MSpace doc :vlax-false))
  
  ; ---------------------------------------------------------------------------------------
  
  (if (and (or (= (getvar 'ctab) "Model")
	       (prompt "\nError: Start routine from MODEL space!"))
	   (princ "\nClosed lwpolylines as boundaries required, ")
	   (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
	   (or (vl-position "Extrim" (layoutlist))
	       (vl-cmdf "_.LAYOUT" "_New" "Extrim"))
	   (setvar 'ctab "Extrim")
	   (vl-cmdf "_.PSPACE")
	   )
    (progn
      (if (setq x (ssget "_A" '((410 . "Extrim"))))
	(command "_.ERASE" x ""))
      
      (repeat (setq i (sslength s))
	(entmake (append (entget (ssname s (setq i (1- i)))) '((410 . "Extrim")))))
      
      (command "_.ZOOM" "_E")
      
      (if (setq s (ssget "_A" '((0 . "LWPOLYLINE") (410 . "Extrim"))))
	(repeat (setq i (sslength s))
	  (command "_.-VPORTS" "_Object" (ssname s (setq i (1- i))))))
      
      (if (setq s (ssget "_A" '((0 . "VIEWPORT") (410 . "Extrim"))))
	(:VPMatchModel s))
      
;;;      (initdia)
;;;      (command "_.EXPORTLAYOUT")
      ))
  (princ)
  )

 

Message 12 of 15

hak_vz
Advisor
Advisor

@rolisonfelipe  With my code you can create new layout with one or more viewports. Place border (closed lwpolyline) over the viewport, and clip all outside the boundary using my code.

Other option is to trim all entities outside the boundary, but I would do this only if it's really necessary.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 13 of 15

rolisonfelipe
Collaborator
Collaborator

MY BROTHER, IT WAS ALL I NEEDED, MILLIMETRICLY CUSTOMIZED....

MUITO OBRIGADO @ВeekeeCZ 

0 Likes
Message 14 of 15

rolisonfelipe
Collaborator
Collaborator

I TESTED YOUR VERSION HAS A VERY GREAT POTENTIAL AND A DYNAMIC USE PATIBILITY.

THANK YOU VERY MUCH @hak_vz 

Message 15 of 15

sebastian_aust5W7SB
Community Visitor
Community Visitor

I tried this and it works for me.

 

(if (= 1 (length (vports))) (ai_tiledvp 2 "_V") (ai_tiledvp 1 nil))

 

I use this as text input on a STREAM DECK and it works like a charm.

0 Likes