Display full version of the post: Combine 2 lisp files

Sandervp
10.11.2014, 12:40
Hello everybody,I have got 2 lisp files. Both of these lisp files will create a command. I want to make a combination of 2 lisp files. If I change one of these lisp files and I want to add the command of that other lisp. It goes wrong.If I use these commands seperate from each opther, everything is oké. But if I use the combined lisp file, the added command in the lisp file is unknown.How is this possible?One of these lisp files will jumps from layout to layout and finally to my model. Also this lisp uses the zoom extents command at every layout and model.The other lisp locks al of my viewports in a layout. This lisp also changes his color.I want to combine these lisp files.I've found a solution on the internet but it doesn't work. In this sollution I have to create a third lisp file and in this lisp, I have to defun another, new, command first. After that the 2 commands of the other 2 lisp files are written.But this lisp shall not lock all viewports in every layout. The lisp does lock all my viewport in one layout only following zoom extents in every layout.The lisp that I want starts at one layout. He locks the viewports following zoom extents. After that he jumps to the other layout and also locks and zoom this layout etc.... If all the layouts are done, he jumps to the model.Can somebody help me?How do I combine these following lisps:Lisp to zoom extent all my layouts:(defun c:LZE (/ Ctab Layout)  (princ "\nLayouts Zoom Extents")  (setq Ctab (getvar "CTAB"))  (foreach Layout (layoutlist)    (command "LAYOUT" "S" Layout)    (command "PSPACE")    (command "ZOOM" "E")  )  (setvar "CTAB" Ctab)    (command "TILEMODE" "1")    (command "ZOOM" "E")    (command "PURGE" "A" "*" "N")    (command "AUDIT" "Y")    (command "PURGE" "A" "*" "N")    (command "QSAVE")     (princ))Lisp to lock my viewports:(defun c:vpl (/ AD COUNT ENT I PL SS TABNAME VP VPNO)    (setq ad (vla-get-activedocument (vlax-get-acad-object)))    (vlax-for lay (vla-get-layouts ad)        (if (/= (setq TabName (strcase (vla-get-name lay))) "MODEL") ;_ end of /=            (progn                (if (setq ss (ssget                                 "X"                                 (list (cons 0 "viewport")                                 ) ;_ end of list                             ) ;_ end of ssget                    ) ;_ end of setq                    (progn                        (setq count (sslength ss))                        (setq i 0)                        (if (> count 0)                            (progn                                (while (< i count)                                    (setq                                        ent (ssname ss                                                    i                                            ) ;_ end of ssname                                    ) ;_ end of setq                                    (setq vpNo                                             (dxf                                                 69                                                 (entget                                                     ent                                                 ) ;_ end of entget                                             ) ;_ end of dxf                                    ) ;_ end of setq                                    (if (> vpNo 1)                                        (progn                                            (setq vp (vlax-ename->vla-object                                                         ent                                                     ) ;_ end of vlax-ename->vla-object                                            ) ;_ end of setq                                            (if (= (vla-get-clipped                                                       vp                                                   ) ;_ end of vla-get-clipped                                                   :vlax-false                                                ) ;_ end of =                                                (progn                                                    (vla-put-color                                                        vp                                                        3                                                    ) ;_ end of vla-put-color                                                                                           (vla-put-layer                                                        vp                                                        "defpoints"                                                    ) ;_ end of vla-put-layer                                                ) ;_ end of progn                                                (progn                                                    (setq                                                        pl (entget                                                               (dxf                                                                   340                                                                   (entget                                                                       ent                                                                   ) ;_ end of entget                                                               ) ;_ end of dxf                                                           ) ;_ end of entget                                                    ) ;_ end of setq                                                    ;get clip entity                                                    (setq pl (vlax-ename->vla-object                                                                 (dxf -1                                                                      pl                                                                 ) ;_ end of dxf                                                             ) ;_ end of vlax-ename->vla-object                                                    ) ;_ end of setq                                                    (vla-put-color                                                        pl                                                        3                                                    ) ;_ end of vla-put-color                                                    (vla-put-layer                                                        pl                                                        "defpoints"                                                    ) ;_ end of vla-put-layer                                                    (vla-put-color                                                        vp                                                        3                                                    ) ;_ end of vla-put-color                                                                                            (vla-put-layer                                                        vp                                                        "defpoints"                                                    ) ;_ end of vla-put-layer                                                ) ;_ end of progn                                            ) ;_ end of if                                            (vla-put-displaylocked                                                vp                                                :vlax-true                                            ) ;_ end of vla-put-displaylocked                                            (vla-update vp)                                        ) ;_ end of progn                                    ) ;_ end of if                                    (setq i (1+ i))                                ) ;_ end of while                            ) ;_ end of progn                        ) ;_ end of if                    ) ;_ end of progn                ) ;_ end of if            ) ;_ end of progn        ) ;_ end of if    ) ;_ end of vlax-for) ;_ end of defun

Vladimir Michl
10.11.2014, 12:52

Just formally (not tested) - define a combined command "NEWCMD! and call both functions in it: [CODE](defun C:NEWCMD () (C:LZE) (C:VPL) (princ))[/CODE]

Sandervp
10.11.2014, 13:25
Hello Vladimir Michl,I've tried that lisp already, but it doesn't work correctly.This lisp will do the LZE lisp first. If this lisp is ready, I see my model on my screen.The VPL lisp doesn't work in the model. Because there are no viewports.The lisp that I wants must jump to a layout, lock the viewports, zoom extents following jumping to another layout. At the other layout he will do it again. Lock the viewports and zoom extents.The lisp must repeat this till every layout is done. After that he goes back to the model.