CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedCombine 2 lisp files

 Post Reply Post Reply
Author
Sandervp View Drop Down
Groupie
Groupie


Joined: 02.Jun.2014
Location: Netherlands
Using: Autocad 2015 and older
Status: Offline
Points: 30
Direct Link To This Post Topic: Combine 2 lisp files
    Posted: 10.Nov.2014 at 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.
Back to Top
Vladimir Michl View Drop Down
Moderator Group
Moderator Group

Arkance Systems CZ

Joined: 26.Jul.2007
Location: Czech Republic
Using: Autodesk software
Status: Offline
Points: 2124
Direct Link To This Post Posted: 10.Nov.2014 at 12:52
Just formally (not tested) - define a combined command "NEWCMD! and call both functions in it:
 
(defun C:NEWCMD ()
 (C:LZE)
 (C:VPL)
 (princ)
)
Vladimir Michl (moderator)
ARKANCE - https://arkance.world - Autodesk Platinum Partner
Back to Top
Sandervp View Drop Down
Groupie
Groupie


Joined: 02.Jun.2014
Location: Netherlands
Using: Autocad 2015 and older
Status: Offline
Points: 30
Direct Link To This Post Posted: 10.Nov.2014 at 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
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,070 seconds.