CAD Posted September 24, 2017 Share Posted September 24, 2017 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) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 24, 2017 Share Posted September 24, 2017 AFAIK, you can't lock/unlock main Model space viewport... Quote Link to comment Share on other sites More sharing options...
CAD Posted September 24, 2017 Author Share Posted September 24, 2017 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 24, 2017 Share Posted September 24, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
CAD Posted September 24, 2017 Author Share Posted September 24, 2017 Hello Tharwat, the lisp dont work. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 24, 2017 Share Posted September 24, 2017 Hello Tharwat, the lisp dont work. It did work on my Cad 2015. Any error message at the command bar? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 24, 2017 Share Posted September 24, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
CAD Posted September 24, 2017 Author Share Posted September 24, 2017 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 24, 2017 Share Posted September 24, 2017 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. Quote Link to comment Share on other sites More sharing options...
CAD Posted September 24, 2017 Author Share Posted September 24, 2017 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!!! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 24, 2017 Share Posted September 24, 2017 YESs thankyou when i combine it works fine!!! You're welcome. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 24, 2017 Share Posted September 24, 2017 @Tharwat: In a drawing with multiple PS layouts your code will change each viewport multiple times. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 24, 2017 Share Posted September 24, 2017 @Tharwat:In a drawing with multiple PS layouts your code will change each viewport multiple times. Due to what? Quote Link to comment Share on other sites More sharing options...
CAD Posted September 24, 2017 Author Share Posted September 24, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 25, 2017 Share Posted September 25, 2017 Due to what?Oops my bad, I did not check your code properly. Your code does not modify entities multiple times. My apologies Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 25, 2017 Share Posted September 25, 2017 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. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 25, 2017 Share Posted September 25, 2017 (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 September 25, 2017 by Roy_043 Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 25, 2017 Share Posted September 25, 2017 Related topic: https://www.cadsite.be/smf/index.php?topic=1204.msg33950#msg33950 Quote Link to comment Share on other sites More sharing options...
CAD Posted September 25, 2017 Author Share Posted September 25, 2017 @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!!! 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!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.