Hello there. This works for my everyday drawing needs;
;; LAYERS TO USE LAYERS TO USE LAYERS TO USE LAYERS TO USE LAYERS TO USE LAYERS TO USE ;;
;; New layer, yxTEMP
(setq flag (tblsearch "layer" "yxTEMP"))
; find out if the layer exists
(if flag ; if the layer exists
(progn
(command "_.layer" "_on" "yxTEMP" "") ; if the layer is off
(command "_.layer" "_thaw" "yxTEMP" "") ; if the layer is frozen
) ;_ progn
) ;_ if
(command "_.layer" "M" "yxTEMP" "")
(command "_.layer" "P" "N" "yxTEMP" "")
(command "_.layer" "C" "2" "yxTEMP" "")
(command "_.color" "ByLayer")
;; New layer, WALL-FINISH
(command "_.layer" "M" "WALL-FINISH" "")
(command "_.layer" "C" "4" "WALL-FINISH" "")
(command "_.color" "ByLayer")
;; New layer, ROUGH-OUTLINE
(command "_.layer" "M" "ROUGH-OUTLINE" "")
(command "_.layer" "C" "223" "ROUGH-OUTLINE" "")
(command "_.color" "ByLayer")
(setvar "clayer" "0")
;; SUB-FUNCTION: dtr, Degrees to Radians ;;
(defun dtr (x) ; define degrees to radians function
(* pi (/ x 180.0)) ; (angle / 180) * PI
) ;_ end of dtr
;; FUNCTION: yxML.lsp
(defun c:yxML (/ pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 pt10 pt11 pt12)
; local variables
(yxERR)
(setvar "osmode" (+ 1 32)) ; snaps to ENDpoint and INTersection
(setvar "orthomode" 1) ; 1=on
;; command to check if UCS is set to World if not restore it
(command "_ucs" "w")
;; Options for different thicknesses of walls
(if (not *dp-yx:wt*)
(setq *dp-yx:wt* 0.10) ; default prompt: wall thickness
) ;_ if
(setq
yx:wt (getreal
(strcat "\n Thickness of wall (in meter): <"
(rtos *dp-yx:wt* 2 2)
">: "
)
)
)
(if (not yx:wt)
(setq yx:wt *dp-yx:wt*)
(setq *dp-yx:wt* yx:wt)
) ;_ if
;; Line offset settings
(setq yxTEMP-Offset 0.000) ; offset, on center
(setq ROUGH-Offset (/ yx:wt 2.0)) ; offset, on each side
(setq WALL-Offset (+ (/ yx:wt 2.0) 0.025)) ; offset, on each side
(setq pt1 (getpoint "\n Pick Starting point: "))
;; while
(while
(if pt1
(progn
(setq pt2 (getpoint pt1 "\n Pick Ending point: "))
(if pt2
(progn
(setq ang (angle pt1 pt2)
;; for yxTEMP on center
pt3 (polar pt2 (+ ang (dtr 90.0)) yxTEMP-Offset)
pt4 (polar pt1 (+ ang (dtr 90.0)) yxTEMP-Offset)
;; for ROUGH-OUTLINE (one side)
pt5 (polar pt2 (+ ang (dtr 90.0)) ROUGH-Offset)
pt6 (polar pt1 (+ ang (dtr 90.0)) ROUGH-Offset)
;; for WALL-FINISH (one side)
pt7 (polar pt2 (+ ang (dtr 90.0)) WALL-Offset)
pt8 (polar pt1 (+ ang (dtr 90.0)) WALL-Offset)
;; for ROUGH-OUTLINE (other side)
pt9 (polar pt2 (+ ang (dtr 90.0)) (- ROUGH-Offset))
pt10 (polar pt1 (+ ang (dtr 90.0)) (- ROUGH-Offset))
;; for WALL-FINISH (other side)
pt11 (polar pt2 (+ ang (dtr 90.0)) (- WALL-Offset))
pt12 (polar pt1 (+ ang (dtr 90.0)) (- WALL-Offset))
) ;_ setq
;; Make the line offset 1 unit from point
;; yxTEMP on center
(entmake (list
(cons 0 "LINE")
(cons 10 pt3) ; start point
(cons 11 pt4) ; end point
(cons 8 "yxTEMP") ; new layer
) ;_ list
) ;_ entmake
;; ROUGH-OUTLINE (one side)
(entmake (list
(cons 0 "LINE")
(cons 10 pt5)
(cons 11 pt6)
(cons 8 "ROUGH-OUTLINE")
) ;_ list
) ;_ entmake
;; WALL-FINISH (one side)
(entmake (list
(cons 0 "LINE")
(cons 10 pt7)
(cons 11 pt8)
(cons 8 "WALL-FINISH")
) ;_ list
) ;_ entmake
;; ROUGH-OUTLINE (other side)
(entmake (list
(cons 0 "LINE")
(cons 10 pt9)
(cons 11 pt10)
(cons 8 "ROUGH-OUTLINE")
) ;_ list
) ;_ entmake
;; WALL-FINISH (other side)
(entmake (list
(cons 0 "LINE")
(cons 10 pt11)
(cons 11 pt12)
(cons 8 "WALL-FINISH")
) ;_ list
) ;_ entmake
) ;_ 2nd progn
) ;_ 2nd if
) ;_ 1st progn
) ;_ 1st if
(setq pt1
(getpoint ; pt2, put view rubber-band action
"\n Pick other Starting point or press Enter/Esc to Exit: "
)
)
) ;_ while
;;(reset)
(princ)
) ;_ end of