Jump to content

Recommended Posts

Posted

hello, i got a lisp that only work in layout who can modified it so i also can run in the model. thxxxxx

in the model it says:; error: bad argument type: lselsetp nil

 

 

(Defun c:vplk ()
(setq d (ssget "_x" '((0 . "VIEWPORT"))))
 	(vplock d T)(princ))

(Defun c:vpun ()
(setq d (ssget "_x" '((0 . "VIEWPORT"))))
 	(vplock d nil)
 	(princ)
 )

(Defun vplock (sel flg)
	(setq mode (if flg  :vlax-true :vlax-false))
(repeat (setq i (sslength sel))
	  (vlax-put-property (vlax-ename->vla-object (ssname sel (Setq i (1- i))))
	    'DisplayLocked mode)
  )
 	(princ (strcat "\nViewports " (if flg "" "Un" )  "locked"))(princ)
)				  
(vl-load-com)

Posted

AFAIK, you can't lock/unlock main Model space viewport...

Posted

No mean, when iam in the model TAB, i want the layouts TAB with viewport lock/ and unlock them. The lisp works only when iam in the layout TAB.

Posted

Hi,

An example.

(defun c:vplk (/ spc)
 (setq spc (getvar 'ctab))
 (foreach lay (layoutlist)
   (setvar 'ctab lay)
   (vplock (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 lay))) t)
 )
 (setvar 'ctab spc)
 (princ)
)

Posted
Hello Tharwat,

 

the lisp dont work.

 

It did work on my Cad 2015.

 

Any error message at the command bar?

Posted

Looking at the code in the OP the problem should only occurs in drawings without viewports.

 

To fix it try:

(defun c:vplk ( / d)
 (if (setq d (ssget "_X" '((0 . "VIEWPORT"))))
   (vplock d T)
 )
 (princ)
)

Posted

both code not working error code

 

Command: VPLK

Restoring cached viewports - Regenerating layout.

; error: no function definition: VPLOCK

 

i use acad2016 can u also add function vpunlock

Posted
yes

 

Command: VPLK

Restoring cached viewports - Regenerating layout.

; error: no function definition: VPLOCK

 

i use acad2016 can u also add function vpunlock

 

You need to load that function 'VPLOCK' along with the codes that I posted earlier since I re-wrote the function in another way that you can use it for the two options in the same manner you have posted in the first post.

Posted
You need to load that function 'VPLOCK' along with the codes that I posted earlier since I re-wrote the function in another way that you can use it for the two options in the same manner you have posted in the first post.

 

YESs thankyou when i combine it works fine!!!

Posted

@Tharwat:

In a drawing with multiple PS layouts your code will change each viewport multiple times.

Posted
@Tharwat:

In a drawing with multiple PS layouts your code will change each viewport multiple times.

 

Due to what?

Posted
Looking at the code in the OP the problem should only occurs in drawings without viewports.

 

To fix it try:

(defun c:vplk ( / d)
 (if (setq d (ssget "_X" '((0 . "VIEWPORT"))))
   (vplock d T)
 )
 (princ)
)

 

Roy your code not working when i combine it?

 

 

 

(Defun c:vplk ()
(setq d (ssget "_x" '((0 . "VIEWPORT"))))
 	(vplock d T)(princ))

(Defun c:vpun ()
(setq d (ssget "_x" '((0 . "VIEWPORT"))))
 	(vplock d nil)
 	(princ)
 )

(Defun vplock (sel flg)
	(setq mode (if flg  :vlax-true :vlax-false))
(repeat (setq i (sslength sel))
	  (vlax-put-property (vlax-ename->vla-object (ssname sel (Setq i (1- i))))
	    'DisplayLocked mode)
  )
 	(princ (strcat "\nViewports " (if flg "" "Un" )  "locked"))(princ)
)				  
(vl-load-com)

(defun c:vplk ( / d)
 (if (setq d (ssget "_X" '((0 . "VIEWPORT"))))
   (vplock d T)
 )
 (princ)
)

Posted
Due to what?
Oops my bad, I did not check your code properly. Your code does not modify entities multiple times. My apologies Tharwat
Posted
Oops my bad, I did not check your code properly. Your code does not modify entities multiple times. My apologies Tharwat

 

No worries Roy, it's okay.

Posted (edited)

@CAD:

The code works fine.

 

I suspect you do not realise that when a layout has never been activated it does not contain any viewports. The viewport you see when you first activate a layout has been newly created (which is why it can be an exact fit for the entities that are currently visible in model space).

So if you start a drawing from scratch, for example, and you are still on the "Model" tab, there will be no viewports in the drawing for the code to change.

 

Please retest the code in a drawing where all layouts have been activated.

 

Note 1:

When combining the code you should remove old versions of functions instead of just appending new code.

 

Note 2:

When a layout is first activated not one but two viewports are automatically generated. The first is the main paper space viewport.

Edited by Roy_043
Posted
@CAD:

The code works fine.

 

I suspect you do not realise that when a layout has never been activated it does not contain any viewports. The viewport you see when you first activate a layout has been newly created (which is why it can be an exact fit for the entities that are currently visible in model space).

So if you start a drawing from scratch, for example, and you are still on the "Model" tab, there will be no viewports in the drawing for the code to change.

 

Please retest the code in a drawing where all layouts have been activated.

 

Note 1:

When combining the code you should remove old versions of functions instead of just appending new code.

 

Note 2:

When a layout is first activated not one but two viewports are automatically generated. The first is the main paper space viewport.

 

hELLO Roy_043 u right!!!:):notworthy: i think i made a mistake the lisp also WORKS!!great. thinks some old code was in mine acad.

 

u both areee good!!!!thankksss Bedankt!!!

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