PDA

View Full Version : Framing Header



mhannan.100562
2019-11-22, 02:27 PM
Good morning everyone! I'm hoping to get some help with a LISP routine that I'm been working on. Currently the command will drawing two lines between any selected points. I want to add a feature that will draw two lines if the wall width is less than 5.5 and three lines if 5.5 or greater.

Thank you in advance for any help
Matt

devitg.89838
2019-11-29, 10:21 PM
Please upload your.dwg where yo want to apply the lisp

devitg.89838
2019-11-29, 10:56 PM
Some like it


;;;2019-11-22 Matthew Hannan

(defun sm-env-sav (a) ; get System variables
(setq MLST nil)
(repeat (length a)
(setq MLST (append MLST (list (list (car a) (getvar (car a))))))
(setq a (cdr a))
))

(defun sm-env-rest () ; System variable restore
(setq idx 0)
(repeat (length MLST)
(setq val1 (nth idx mlst)
val2 (cadr val1)
val1 (car val1))
(if (= (type val1) 'STR)(setq val1 (strcase val1)))
(cond ((and (= val1 "DIMSTYLE") (/= val2 "*UNNAMED"))
(command "_.dim1" "_restore" val2))
((= val1 "DIMLDRBLK")
(if (= (strlen val2) 0) (setvar val1 ".")(setvar val1 val2)))
((/= val2 "*UNNAMED") (setvar val1 val2)))
(setq idx (+ 1 idx))
)(princ))

(defun toggleOsmode(onoff); if True, on
(setq os (getvar "osmode"))
(cond ((and (> os 0)(< os 16384)(null onoff))(setvar "osmode" (+ os 16384)))
((and (> os 16383) onoff )(setvar "osmode" (- os 16384)))
);conditional
)

(defun sm-mid-pt ( p1 p2)
(mapcar '(lambda (I J)(/ (+ I J) 2)) p1 p2))

(defun sm-kheader-err (errmsg)
(if (/= errmsg "Function cancelled") (princ errmsg))
(sm-env-rest)
(command "_.Undo" "e")
(princ))

(defun c:hdrr (/ ); a1 a2 b1 b2 pnt1 pnt2 pnt3 pnt4)
(setq HeaderLyrName "S-Fram-Headers"
HeaderLyrColor 1
HeaderLyrLineType "Center2")

(command "_.Undo" "be")
(setq olderr *error* *error* sm-knote-err)

(sm-env-sav '("CLAYER" "CECOLOR" "CELTYPE" "ORTHOMODE" "OSMODE"))

(if (not (tblsearch "Layer" "S-Fram-Headers"))
(command "-layer" "n" HeaderLyrName "c" HeaderLyrColor HeaderLyrName "L" HeaderLyrLineType HeaderLyrName ""))



(while (null (setq ent1 (entsel "\nOne side of opening: "))))
(while (null (setq ent2 (entsel "\nOpposite side of opening: "))))
(setq pnt1mid (osnap (cadr ent1) "mid")
pnt1end (osnap pnt1mid "end")
pnt2mid (osnap (cadr ent2) "mid")
pnt2end (osnap pnt2mid "end")
pntMid (sm-mid-pt pnt2mid pnt1mid)
ang1 (angle pnt1mid pnt2mid)
a90 (/ pi 2.0)
a180 pi
)

(toggleOsmode nil)
(setq pt1-pt2 ( distance pnt1mid pnt2mid))
(command "pline" (polar pnt1mid (+ ang1 a180) 2) (polar pnt2mid ang1 2) "")
(setq ln1 (entlast))
(IF (< PT1-PT2 5.0)
(PROGN
(COMMAND ".Offset" "T" LN1 (POLAR PNT1MID (+ ANG1 A90) 0.75) "")
(COMMAND ".change" (ENTLAST) "" "P" "LA" "S-Fram-Headers" "")
(COMMAND ".Offset" "T" LN1 (POLAR PNT1MID (- ANG1 A90) 0.75) "")
(COMMAND ".change" (ENTLAST) "" "P" "LA" "S-Fram-Headers" "")
(COMMAND ".erase" LN1 "")
)
(PROGN
(COMMAND ".change" LN1 "" "P" "LA" "S-Fram-Headers" "")
(COMMAND ".Offset" "T" LN1 (POLAR PNT1MID (+ ANG1 A90) 0.75) "")
(COMMAND ".change" (ENTLAST) "" "P" "LA" "S-Fram-Headers" "")
(COMMAND ".Offset" "T" LN1 (POLAR PNT1MID (- ANG1 A90) 0.75) "")
(COMMAND ".change" (ENTLAST) "" "P" "LA" "S-Fram-Headers" "")
)
)






(sm-env-rest)
(princ)
)
;|«Visual LISP© Format Options»
(180 2 1 0 nil "end of " 100 20 2 2 nil nil T nil T)
;*** DO NOT add text below the comment! ***|;

mhannan.100562
2019-12-02, 02:11 PM
Thanks for helping me with this, but that's not quite what I'm looking for. Attached is a sample of the final look.

Thanks again for any help.
Matthew Hannan

devitg.89838
2019-12-02, 03:55 PM
Thanks for helping me with this, but that's not quite what I'm looking for. Attached is a sample of the final look.

Thanks again for any help.
Matthew Hannan

Change it



(setq pt1-pt2 ( distance pnt1mid pnt2mid))


To


(setq pt1-pt2 (* 2( distance pnt1mid pnt1end)))


Find attached with others adds.

mhannan.100562
2019-12-02, 04:04 PM
Perfect Thank you!