Lisp for placing vports on a specific layer

Lisp for placing vports on a specific layer

twallacemagee
Enthusiast Enthusiast
1,027 Views
7 Replies
Message 1 of 8

Lisp for placing vports on a specific layer

twallacemagee
Enthusiast
Enthusiast

I am trying to get a lisp command that collects and stores the current layer name, creates a new, prompts for a new viewport with two point selection on the new layer then returns the layer to the original layer.

 

(defun c:Nvp ()
(setq cl (getvar "cLAYER"))
(COMMAND "-LAYER" "M" "NO PLOT" "c" "14" "no plot" "p" "n" "no plot" "")
(command "-VPORTS" PAUSE)
(SETVAR "clayer" cl)
)

 

It all works except for two things.  it does not display the 'specify corner' and the 'specify opposite corner' prompts.  Second issue is it places the viewport on the stored layer instead of the new layer.

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

pbejse
Mentor
Mentor
Accepted solution

Try with

(command "-VPORTS" pause pause) 

 

0 Likes
Message 3 of 8

twallacemagee
Enthusiast
Enthusiast

I had it that way originally and it did not seem to like it.  Went back to it and it is working now.  I had been in adding and remarking out lines to figure the problem out so maybe before the clean up it was just glitching.

 

Any idea on why it doesn't show the prompts?

0 Likes
Message 4 of 8

pbejse
Mentor
Mentor

@twallacemagee wrote:

Any idea on why it doesn't show the prompts?


 

Cmdecho is off me thinks,  Make sure its on @twallacemagee 

Cmdecho to 1

 

 

 

0 Likes
Message 5 of 8

twallacemagee
Enthusiast
Enthusiast
Accepted solution

Cmdecho is set to 1.  So I set it to 0 and back to 1 and it is working correctly for now.  I will remember this for in the future...possibly.

0 Likes
Message 6 of 8

twallacemagee
Enthusiast
Enthusiast

It appears that CMDEcho keeps getting set to 0 every time I open a drawing or a new drawing.  I have set it as 1 in my template file but it still keeps resetting to 0.  Any idea why or what setting to modify to get it to keep the 1 setting?

0 Likes
Message 7 of 8

pbejse
Mentor
Mentor

@twallacemagee wrote:

It appears that CMDEcho keeps getting set to 0 every time I open a drawing or a new drawing.  I have set it as 1 in my template file but it still keeps resetting to 0.  Any idea why or what setting to modify to get it to keep the 1 setting?


 

You mean the template file resets the value back to 0? Now that is odd, perhaps you're starting from a different template? Are you sure the template file you save is the one set on Options/Files/Template settings? 

 

Or even, a code loading on startup that includes cmdecho setting to 0?

 

Could be anything really, I doubt its Sysvarmonitor as it only notifies you of any changes.

 

0 Likes
Message 8 of 8

twallacemagee
Enthusiast
Enthusiast

It is a template that I set up as a base drawing with the layers, dimstyles, text styles, etc. that are typical for our office. The template file was set up many versions ago and is occasionally updated with some new feature I find out about. The template worked fine with keeping cmdecho as 0 until 2021 but now when I have set it as 1 in the template file and still it changes to 0.

 

I did not try it with other template files, but it appears to be keeping the setting now as 1 so there must have been something I did at some point that initiated this glitch.

 

Thank you and all others for your help and time.

0 Likes