PDA

View Full Version : Hopefully easy lisp help needed



gliderflyer
2013-09-09, 04:43 PM
It's been awhile and my lisp skills are rusty. Very rusty.

I have a lisp routine that draws a 2 section leader with no text. It then inserts a weld symbol at the end of the leader.
It works great but I'd like the routine to behave so that the leader can be as many sections as the user wants and then adds the weld symbol.
Am I going to need to add variables (PT1 PT2 etc.) and draw the leader to those points or can this routine be easily modified?

The 2 section leader is defined by the three pauses. I was hoping there was an easy modification this line to make it work.

Thanks!
Randy



(defun c:WLDLDR7 (/ CL SM OM)
(setvar "cmdecho" 0)
;
;get current variables
(setq CL (getvar "clayer"))
(setq SM (getvar "osmode"))
(setq OM (getvar "orthomode"))


(setvar "osmode" 0)
(setvar "orthomode" 0)

(princ "\n Multi Section Weld Leader Right")

(command "-layer" "s" "s-extent" "")
(command "-dimstyle" "r" "ssf-weld-leader")
(command "dimscale" sf)
(setvar "orthomode" 0)

(command "leader" pause pause pause "" "" "n")
(setvar "orthomode" 1)
(command "_insert" "wsym-rgtn" "@" sf sf "" "")
(command "explode" "l" "" "")

;put setvars back to starting values
(setvar "clayer" CL)
(setvar "osmode" SM)
(setvar "orthomode" OM)
(princ)

)

jdiala
2013-09-10, 09:00 PM
For my first post gliderflyer.
Try this. Throws up an error but will do the work.


;;;; jDiala 09-10-13 ;;;;
;;;; ;;;;;;;;;;;;;;;;;;;;
(defun C:WLDLDR7 ( / l p p2 o os *error*)
(defun *error* ( msg )
(setvar 'orthomode o)
(setvar 'osmode os)
(setvar 'clayer l)
(setvar 'cmdecho c)
(if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(setq o (getvar 'orthomode)
os (getvar 'osmode)
l (getvar 'clayer)
c (getvar 'cmdecho)
)
(setvar 'orthomode 0)
(setvar 'cmdecho 0)
(setvar 'osmode 0)
(setvar 'clayer "s-extent")


(command "-dimstyle" "r" "ssf-weld-leader")
(command "leader" pause pause )
(if (= 1 (getvar "cmdactive"))
(command (setq p (getvar 'lastpoint)) (setvar 'orthomode 1) pause "" "" "n")
)
(vla-InsertBlock
(vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vlax-3d-point (getvar 'lastpoint)) "wsym-rgtn" 1 1 1 0)
(vla-explode (vlax-ename->vla-object (entlast)))
(while t
(while
(eq
(car
(setq p2
(grread t 15 0))) 5 )
(redraw)
(if (listp (setq p2 (cadr p2)))
(grdraw p p2 3 3)
)

)
(entmake
(list
(cons 0 "LEADER")
(cons 100 "AcDbEntity")
(cons 67 0)
(cons 410 "Model")
(cons 8 "s-extent")
(cons 100 "AcDbLeader")
(cons 3 "ssf-weld-leader")
(cons 71 1)
(cons 72 0)
(cons 73 3)
(cons 74 1)
(cons 75 0)
(cons 40 0.0)
(cons 41 0.0)
(cons 76 2)
(cons 10 (cadr p2))
(cons 10 p)
(cons 211 '(1.0 0.0 0.0))
(cons 210 '(0.0 0.0 1.0))
(cons 212 '(0.0 0.0 0.0))
(cons 213 '(0.0 0.0 0.0))
)
)
)

(setvar 'orthomode o)
(setvar 'osmode os)
(setvar 'clayer l)
(setvar 'cmdecho c)
(princ)
)