creating viewport lisp

creating viewport lisp

rsocampo1827
Participant Participant
3,395 Views
7 Replies
Message 1 of 8

creating viewport lisp

rsocampo1827
Participant
Participant

Hi, I am new to autolisp and trying to create my own.

below works when I execute the command although it took more time than other commands.

Any suggestion to speed it up?

thanks.

 

(defun c:vp()
(command ".layer" "M" "viewport" "C" "8" "viewport" "P" "N" "viewport" ""
"-VPORTS" pause pause ".layerp")
(princ)
)

0 Likes
Accepted solutions (1)
3,396 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

@rsocampo1827  hi,

 

first maybe you can not see what going on in command line so add this line at first

(setvar "cmdecho" 1)

 

after the code works, change 1 to 0 but as last line turn it back on (1)

run -vports command manually to see what input is needed than fix your code

(-vports at first expect to know how many viewport to create and than specify the 2 points of rectangle)

 

moshe

 

 

0 Likes
Message 3 of 8

rsocampo1827
Participant
Participant

thanks for that, but adding (setvar "cmdecho" 1) doesn't change anything. I works faster now but layer color back to white and "no plot" goes back to plot.

 

Any other suggestion?

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

What are you setting for -vports?

Are you experiencing some significant lags or you want to speed up the whole workflow... or it's just a feeling.

 

BTW I would definitely get rid of PLAYER.

 

(defun c:vp ( / lay)

  (setq lay (getvar 'clayer))
  
  (or (tblsearch "LAYER" "viewport")
      (command ".layer" "N" "viewport" "C" "8" "viewport" "P" "N" "viewport" ""))

  (command "_.layer" "_T" "viewport" "_U" "viewport" "_S" "viewport" "")
  
  (command-s "-VPORTS")

  (setvar 'clayer lay)
(princ)
)
Message 5 of 8

rsocampo1827
Participant
Participant

Thanks @ВeekeeCZ your modified lisp works perfect as I wanted.

The lag I'm experiencing before might be because of big file that was open when I tried my lisp. But its okay now.

Also after executing your revised lisp my layer came back to previous which is great.

Thanks.

0 Likes
Message 6 of 8

ndikesh
Contributor
Contributor

i'm just trying to learn.

 

i'm trying to create a lisp but it does not return back to previous layer. can you please let me know what's wrong?

 

 

(defun c:vp ( / lay )

(setq lay (getvar "clayer"))

(if (= (tblsearch "layer" "VP")nil))

(command "-layer" "M" "VP" "C" "6" "L" "Continuous" "P" "N" "S" "VP" "" ""))

(command "mview" )

(setvar "clayer" lay)

)

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant

Ok...

 

(defun c:vp ( / lay )
  
  (setq lay (getvar "clayer"))
  
  (command "-layer"
	   "T" "VP"  	; in case it exists and frozen. does no harm if neither is needed
	   "M" "VP"	; it creates if needed, makes it current and turn off. does no harm if neither is needed
	   "C" 6 ""	; last could be "VP", but VP became, so "" is enought
	   "L" "Continuous" ""
	   "P" "N" ""
	   "")
  
  (command-s "mview")     ; command is for a single user input only. command-s keeps the user inside until mview finishes.
  
  ;  (command "mview")		; or traditional alternative to command-s
  ;  (while (> (getvar 'cmdactive) 0) (command pause))
  
  (setvar "clayer" lay)
  (princ)
  
  )

 

Message 8 of 8

tjoy
Explorer
Explorer

thanks for the explanation, cheers!!

0 Likes