vports

vports

Anonymous
Not applicable
1,144 Views
8 Replies
Message 1 of 9

vports

Anonymous
Not applicable

I have a layout with several vports, I would like to  set each vport in that layout to 2DWIREFRAME model , using autolisp, can somebody help me to accomplish this?

 

 

0 Likes
Accepted solutions (3)
1,145 Views
8 Replies
Replies (8)
Message 2 of 9

john.uhden
Mentor
Mentor

Do you mean to help or to provide you freeware requiring no development on your own?

First, I am presuming that the name you provided is that of a saved Modelspace view.

Without even opening AutoCAD, my preliminary (and aged) thought would be to (ssget) each viewport, make it active, and View;Restore the named view.  There are probably better ActiveX methods, but I don't know them without research.  But that is something you can do.

John F. Uhden

0 Likes
Message 3 of 9

Sea-Haven
Mentor
Mentor

Like John use ssget then change assoc 281 

(entget (car (entsel))) pick viewport change style do again.

0 Likes
Message 4 of 9

Anonymous
Not applicable

just help to get me started and develop my own.  I am new programming Autolisp,  and first time using this forum.   

I have tried several ways to do it but do not get results, that is why I am using this forum.   

0 Likes
Message 5 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hi, welcome to the forums. You're in the right place.

Here is one example...

 

(defun c:VPVisualStyle (/ ss i)
  (if (and (or (= 1 (getvar 'cvport))
	       (prompt "\nError: Needs to be run from paparspace."))
	   (setq ss (ssget "_A" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))))
	   )
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "VisualStyle" 1))) ; 1 = 2DWIREFRAME
  (princ)
  )

 

Message 6 of 9

Anonymous
Not applicable
Accepted solution

Thank you very much BeekeeCZ,   this is exactly what I need. 

I am incorporating your routine in another one I have so it will change the VisualStyle of all viewports in each layout of the drawing: 

 

(defun C:VPVS ()

(set numerolayouts (length (layoutlist)))

(setq test 0)

(while (< test numerolayouts)

(setvar 'ctab (if (= (getvar 'catb) (last (layoutlist))) (car (layoutlist)) (cadr (member (getvar 'ctab) (layoutlist)))))

(command "PSPACE")

;;     ------Start BeeKee Routine-----

(if (and (or (= 1 (getvar 'cvport)) (prompt "\nError: Needs to be run from paperspace.")) (setq ss (ssget "_A" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab))))) ) (repeat (setq i (sslength ss)) (setpropertyvalue (ssname ss (setq i (1-i))) "VisualStyle" 1)))

;;      ---------End---------

(setq test (1+ test))

)

(princ)

)

 

 

 

by the way,   is there a way to incorporate Shortcut Keys in a Autolisp routine?

 

Thanks again BeeKeeCZ

 

 

 

 

 

 

0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

You have to create a shortcut in CUI. Add new command with macro ^c^cvpvs. That cannot be created by routine itself.

 

btw, you have 3 typos in your code. That won't work.

 


@Anonymous wrote:

Thank you very much BeekeeCZ,   this is exactly what I need. 

I am incorporating your routine in another one I have so it will change the VisualStyle of all viewports in each layout of the drawing: 

 

(defun C:VPVS ()

(set numerolayouts (length (layoutlist)))

(setq test 0)

(while (< test numerolayouts)

(setvar 'ctab (if (= (getvar 'catb) (last (layoutlist))) (car (layoutlist)) (cadr (member (getvar 'ctab) (layoutlist)))))

(command "PSPACE")

;;     ------Start BeeKee Routine-----

(if (and (or (= 1 (getvar 'cvport)) (prompt "\nError: Needs to be run from paperspace.")) (setq ss (ssget "_A" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab))))) ) (repeat (setq i (sslength ss)) (setpropertyvalue (ssname ss (setq i (1-i))) "VisualStyle" 1)))

;;      ---------End---------

(setq test (1+ test))

)

(princ)

)

 

 

 

by the way,   is there a way to incorporate Shortcut Keys in a Autolisp routine?

 

Thanks again BeeKeeCZ

 

 

 

 

 

 


 

Message 8 of 9

Sea-Haven
Mentor
Mentor

Rather than add to the cui use a custom lisp with all your favourite short cuts  and command calls, note you can also have transparent commands that can be used in the middle of commands.

 

(defun c:VPS () (if (not VPVS)(progn(load "VPVS")(command "VPVS"))))
0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor
Maybe I'm off here, but I think you had to have used (vlax-add-cmd ...) in
order to call lisp with the command function.

John F. Uhden

0 Likes