LISP help

LISP help

Anonymous
Not applicable
1,830 Views
14 Replies
Message 1 of 15

LISP help

Anonymous
Not applicable

I through together a lisp using a few others that is intended to use CleanScreen and get rid of the command line and a few others to go to a full screen of sorts. I also wanted it to zoom all layouts to all (except model to extents). The zoom doesn't seem to work quite the way I want and forces me to use the zoom all on all layouts again afterward. It's as if it is zooming before the interface is cleared all the way.

 

Here is the LISP so far:

   (defun c:fw nil (c:FullScreenMode))
(defun c:FullScreenMode ()
  (command "_CleanScreenOn")
  (command "commandlinehide")
  (setvar 'layouttab 0)
  (setvar 'menubar 0)

  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom" "_all")
  ); end foreach
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

  (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))
  
  (princ)
  )

   (defun c:fwq nil (c:FullScreenModeOff))
(defun c:FullScreenModeOff ()
  (command "_CleanScreenOff")
  (command "commandline")
  (setvar 'layouttab 1)
  (setvar 'menubar 1)

  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom" "_all")
  ); end foreach
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

  (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))

  (princ)
  )

Any ideas would be much appreciated!

 

Thanks,

Michael

 

0 Likes
Accepted solutions (2)
1,831 Views
14 Replies
Replies (14)
Message 2 of 15

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

the code is good and works if you disable the last code line (in each function) i turn it into red.

(:layoutRealOrder) it looks like you have a missing function here.

anyhow this line is suppose to restore the current layout (that was before calling the command), with out it you will be left in model space, also good Smiley LOL

 

enjoy

moshe

 

 


   (defun c:fw nil (c:FullScreenMode))
(defun c:FullScreenMode ()
  (command "_CleanScreenOn")
  (command "commandlinehide")
  (setvar 'layouttab 0)
  (setvar 'menubar 0)

  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom" "_all")
  ); end foreach
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

  ; (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))
  
  (princ)
  )

   (defun c:fwq nil (c:FullScreenModeOff))
(defun c:FullScreenModeOff ()
  (command "_CleanScreenOff")
  (command "commandline")
  (setvar 'layouttab 1)
  (setvar 'menubar 1)

  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom" "_all")
  ); end foreach
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

  ; (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))

  (princ)
  )

Any ideas would be much appreciated!

 

Thanks,

Michael

 


 

0 Likes
Message 3 of 15

Anonymous
Not applicable

Ah yes, so that part was missing this:

   (vl-load-com)

; pbejse https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/layout-order/td-p/3749964
(defun :LayoutsRealOrder (/ order)
  (vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq order (cons (list (vla-get-name lay)
                            (vla-get-taborder lay))
                      order)))
  (mapcar 'car (cdr (vl-sort order '(lambda (j k) (< (cadr j) (cadr k)))))))

And for me that part was working fine. Everything but the proper zoom was working. It looks as though it zooms each layout to all BEFORE doing the CleanScreen and turning off bars and such. and then when the command is complete the layout is not quite zoomed completely. I apologize that I am not able to get a screencast(I worked with my IT for days trying to get permission, to no avail).

The best I could do in stead of a screencast is a screenshot of how the layouts look when lisp is finished, and how they should look after a "Zoom" All".

Anyway, thanks for your reply! It's obviously not a dire situation, but it would be a handy tool for me.

 

Thanks,

Michael

0 Likes
Message 4 of 15

Moshe-A
Mentor
Mentor

@Anonymous ,

 

i do not understand what is wrong with zoom and i do not see the difference between the 2 images.

 

moshe

 

 

 

 

0 Likes
Message 5 of 15

Anonymous
Not applicable

Ah, fair enough. Again, sorry I can't show a screencast. I can't even open the images I attached, except for from my computer. It is certainly different on my screen. It really just seems like the order of operations is a little off in the LISP and I wonder if there is a way to specify which actions happen first in a program.

Anyway, thanks for taking a look!

 

-Michael

0 Likes
Message 6 of 15

Moshe-A
Mentor
Mentor

@Anonymous ,

 


It really just seems like the order of operations is a little off in the LISP and I wonder if there is a way to specify which actions happen first in a program.

 

detail the order you seek

 

moshe

 

0 Likes
Message 7 of 15

Anonymous
Not applicable

Oh well, I want the interface disabling ones first:

(command "_CleanScreenOn")
  (command "commandlinehide")
  (setvar 'layouttab 0)
  (setvar 'menubar 0)
  (setvar 'statusbar 0)

And then the zoom program:

(foreach lay (layoutlist)
  (setvar 'ctab lay)
  (command "_.pspace" "_.zoom" "_all")
  ); end foreach
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

And then making first layout current:

(command ".layout" "set" "model")

  (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))
  
  (princ)
  )

(vl-load-com)

; pbejse https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/layout-order/td-p/3749964
(defun :LayoutsRealOrder (/ order)
  (vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq order (cons (list (vla-get-name lay)
                            (vla-get-taborder lay))
                      order)))
  (mapcar 'car (cdr (vl-sort order '(lambda (j k) (< (cadr j) (cadr k)))))))

Thanks,

-Michael

0 Likes
Message 8 of 15

Moshe-A
Mentor
Mentor

so what is the different between your new code and the previous?

still do not understand what is wrong here?

0 Likes
Message 9 of 15

Anonymous
Not applicable

I changed nothing because I didn't know what to change. I just know that the final outcome does not give me the zoom that I want and it appears that it is zooming before.

 

My current solution is to isolate the "CleanScreen" etc. part of the lisp and then just use two lisp commands to get what I need; one that cleans up and one that zooms all and sets the current layout. I separated them and used the "zoom lisp"  and then used the "cleanscreen lisp" separately and it gave me the same, non-ideally zoomed outcome. I want it to "clean" and then "zoom".

 

Anyway, going to keep looking around. It's not a huge issue, just trying to combine two lisps into one.

 

Thanks!

Michael

0 Likes
Message 10 of 15

Moshe-A
Mentor
Mentor

@Anonymous ,

 

the only way i will start understand what is the issue is by seeing your drawing, can you post it?

 

0 Likes
Message 11 of 15

Anonymous
Not applicable

Sure, here it is!

 

-Michael

0 Likes
Message 12 of 15

Anonymous
Not applicable

Running the LISP and then doing a "Zoom" "All" should show you what I want it to show. But, at least for me, that is not what happens. It is zoomed all crooked-like.

 

Thanks,

Michael

0 Likes
Message 13 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution

This the code I was able to achieve the best results.

 

  (command "commandlinehide")
  (command "filetabclose")
  (command "ribbonclose")
  (setvar 'statusbar 0)
  (setvar 'layouttab 0)
  (setvar 'menubar 0)

  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace")
    )
  
  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.zoom" "_extents")
    )
  
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")

 

Personally, don't like the CleanScreen command very much... 

Also try a setting of LAYOUTREGENCTL if that makes any effect.

 

 

0 Likes
Message 14 of 15

Anonymous
Not applicable

Well, this works great with the zooming, although it doesn't hide my toolbars(I don't really use the ribbon) without cleanscreen. I wonder if there is a way to hide them without messing up their position when showing them again?

 

Anyway, the prompt for pressing "ENTER" to continue works great too. Out of curiosity, what don't you like about the CleanScreen command?

 

Thanks,

Michael

0 Likes
Message 15 of 15

Anonymous
Not applicable
Accepted solution

Wow, so it looks like "CleanScreen" was screwing with things all along. I removed it to try it out, inspired by your distaste for it, and here is what I came up with (I also added the hiding/showing of toolbars and filetabs, since cleanscreen was taking care of those:

;;;Custom Fullscreen ON
     (defun c:fw nil (c:FullScreenMode))
(defun c:FullScreenMode ()

  (command "commandlinehide")
  (setvar 'layouttab 0)
  (setvar 'menubar 0)
  (setvar 'statusbar 0)
  (command "filetabclose")
  (command "-toolbar" "michael" "hide")
  (c:ZoomAllandMakeFirstLayoutCurrent)
    
  (princ)
  );defun

;;;Custom Fullscreen Off
  (defun c:wf nil (c:FullScreenModeOff))
(defun c:FullScreenModeOff ()
  
  (command "commandline")
  (command "filetab")
  (setvar 'layouttab 1)
  (setvar 'menubar 1)
  (setvar 'statusbar 1)
  (command "filetab")
  (command "-toolbar" "michael" "show")
  (c:ZoomAllandMakeFirstLayoutCurrent)

  (princ)
 ); end defun

(vl-load-com)

; pbejse https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/layout-order/td-p/3749964
(defun :LayoutsRealOrder (/ order)
  (vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq order (cons (list (vla-get-name lay)
                            (vla-get-taborder lay))
                      order)))
  (mapcar 'car (cdr (vl-sort order '(lambda (j k) (< (cadr j) (cadr k)))))))

 

*Edit* Here is the "(c:ZoomAllandMakeFirstLayoutCurrent)" part.

(defun c:ZoomAllandMakeFirstLayoutCurrent ()
    (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom" "_all"))
  (setvar 'ctab "Model")
  (command "_.zoom" "_extents")
(command ".layout" "set" "model")
  (setvar 'ctab (cadr (member (getvar 'ctab) (append '("Model") (:LayoutsRealOrder) '("Model")))))

 

Thanks for the help!

 

-Michael

0 Likes