Jump to content

Combine three lisp routine into one routine.


Recommended Posts

Hi All,


I need some help i have three lisp routines that i would like to combine into one routine. they all use the same objects to get their results so i was wondering if there was a way to combine them together. the order of would be as follows:


1. olo (Offset Polylines)

2. exl (Extrusion Lengths) the only that i see with this one is that it requires use input for placement, i would for it to place the results to the outside of lines. run the lisp routine by creating a rectangle exploded to see what it does.

3. pte (Panel Tab Extension)


They all run perfectly by themselves, but im just trying to speed up the process. Here are the codes that i'm using. any help would be appreciated.





[email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email]    September 2003
(defun c:olo( / plines    ; selection set of polylines
           ext    ; extrnal point
            dist    ; distance to offset
            poly    ; a polyline from plines
            plist    ; the list of poly
            del    ; polyline to delete
            int    ; internal point
 (command "undo" "begin")
 (princ "select polylines")
 (setq plines (ssget)
   i 0
   ext (getvar "limmax")
   dist (getdist (strcat "distance <" (if olddist
                                         (rtos olddist)   ;use old value as default
                                          "") ">"))) 
 (if (not dist) (setq dist olddist))                      ;reuse old distance if user press <Enter>
 (repeat (sslength plines)
   (setq poly (ssname plines i))
   (setq plist (entget poly))
   (command "offset" dist poly ext "")
   (setq del (entlast)
     int (polar
       (cdr (assoc 10 (entget del)))
              (cdr (assoc 10 (entget del)))
              (cdr (assoc 10 plist)))
            (* 2 (distance (cdr (assoc 10 plist))
                   (cdr (assoc 10 (entget del)))))))
   (command "offset" dist poly int "")
    (command "_.change" (entlast) "" "_p" "_la" (getvar 'clayer) "")
  (entdel del)
   (setq i (1+ i)))
 (command "undo" "end")
 (setq olddist dist)                                      ;preserve current distance for next run

;Extrusion Length
(defun c:EXTL (/ cEnt tStr tBox tHgt tWid gr sPt cPt lAng bPt tPt pt1 pt2 pt3 pt4)
 (if (and (setq cEnt (car (entsel "\nSelect Object: ")))
          (member (cdr (assoc 0 (entget cEnt)))
                  '("LWPOLYLINE" "POLYLINE" "LINE")))
     (setq tStr (strcat "1@" (rtos (- (vla-get-length
                        (vlax-ename->vla-object cEnt)) 4.0)) (strcat "''"))
           tBox (textbox (list (cons 1 tStr) (cons 40 (getvar "TEXTSIZE"))))
           tHgt (- (cadadr tBox) (cadar tBox))
           twid (- (caadr tBox) (caar tBox)))
     (princ "\nPosition Text...")
     (while (eq 5 (car (setq gr (grread t 5 0))))
       (if (listp (setq sPt (cadr gr)))
           (setq cPt  (vlax-curve-getClosestPointto cEnt sPt)
                 lAng (angle cPt sPt)
                 bpt  (polar cPt lAng (/ (getvar "TEXTSIZE") 2.))
                 tpt  (polar bpt lAng tHgt)
                 mPt  (polar bPt lAng (/ tHgt 2.))
                 pt1  (polar bpt (+ lAng (/ pi 2.)) (/ tWid 2.))
                 pt2  (polar bPt (- lAng (/ pi 2.)) (/ tWid 2.))
                 pt3  (polar tpt (+ lAng (/ pi 2.)) (/ tWid 2.))
                 pt4  (polar tPt (- lAng (/ pi 2.)) (/ tWid 2.)))
           (grvecs (list -3 pt1 pt2 pt3 pt4 pt1 pt3 pt2 pt4)))))
     (if (eq 3 (car gr))
         (setq lAng (- lAng (/ pi 2.)))
         (cond ((and (> lAng (/ pi 2)) (<= lAng pi))
                (setq lAng (- lAng pi)))
               ((and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
                (setq lAng (+ lAng pi))))
         (Make_Text mPt tStr lAng))))
   (princ "\n<!> Incorrect Selection <!>"))
(defun Make_Text  (pt val rot)
     (cons 0 "TEXT")
     (cons 8 (getvar "CLAYER"))
     (cons 62 1)
     (cons 10 pt)
     (cons 40 (getvar "TEXTSIZE"))
     (cons 1 val)
     (cons 50 rot)
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 71 0)
     (cons 72 1)
     (cons 73 2)
     (cons 11 pt))))

(defun c:PTE(/ lSet actDoc lDel doMode objLst)
(princ "\n>>> Select lines to extend/reduce <<< ")
(setq lSet
'((0 . "LINE"))));
(setq lDel
(getreal "\nSpecify : "))
); end and
(initget 1 "Positive Negative Both")
(setq doMode
(getkword "\nSpecify direction [Positive/Negative/Both]: ")
objLst(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp 
(mapcar 'cadr(ssnamex lSet))))); end setq
(setq actDoc
(vlax-get-acad-object)))); end vla-StartUndoMark
(if(member doMode '("Negative" "Both"))
(foreach ln objLst
(vlax-put ln 'startpoint
(vlax-get ln 'startpoint)
(vlax-get ln 'angle)(- lDel))); end vlax-put
); end foreach
); end if
(if(member doMode '("Positive" "Both"))
(foreach ln objLst
(vlax-put ln 'endpoint
(vlax-get ln 'endpoint)
(vlax-get ln 'angle)lDel))
); end foreach
); end if
(vla-EndUndoMark actDoc)
); end progn
); end if

Link to comment
Share on other sites

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.

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