Author Topic: Closet Shelf Creator  (Read 4435 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Closet Shelf Creator
« on: January 25, 2004, 09:56:33 AM »
This is  routine I wrote to create a "Shelf & Rod" in a closet
by picking the wall corners where the shelf will be and the
picking the side of the wall the shelf will be.

Routine creates the the following  if it doesn't exist.
linetype "Short Dash"
layer "Shelf"
option to create layer "Rod"

Comments, correction or improvements welcome.

CAB

Code: [Select]

;;             Shelf.lsp
;;      Created by C. Alan Butler  2003
;;       Version 1.2 01/22/2004  added linetype create
;;       Version 2.0 01/23/2004  added layer create
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;;
;;
;;

 ;======================
 ;    Start of Routine
 ;======================
(defun c:shelf (/ pto pt1 pt2 usercmd useros str en1 rod shelf lntyp)
  ;; error function & Routine Exit
  (defun *error* (msg)
    (if
      (not
        (member
          msg
          '("console break" "Function cancelled" "quit / exit abort" "")
        )
      )
       (princ (strcat "\nError: " msg))
    ) ; if
    (setvar "osmode" useros)
    (setvar "CMDECHO" usercmd)

    (princ);; Exit quietly
  ) ;
 ;end error function

;;; -------  Some Housekeeping   ------------------
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setvar "PLINEWID" 0) ; did not save this setting
  (setq useros (getvar "osmode")
        str    ""
        lntyp  "Short Dash"
  )
  (setvar "osmode" 175) ; force snaps on

  ;; Line type setup
  (if (not (tblsearch "ltype" lntyp)) ; ltype not found
    (progn
      (prompt (strcat "\nCreating Linetype \"" lntyp "\""))
      (if (not (entmake ; create a linetype
                 (list '(0 . "LTYPE")
                       '(100 . "AcDbSymbolTableRecord")
                       '(100 . "AcDbLinetypeTableRecord")
                       (cons 2 lntyp) ; this allows variables
                       '(70 . 0)
                       '(3 . "Very short dash  - - - - - -")
                       '(72 . 65)
                       '(73 . 2)
                       '(40 . 0.25)
                       '(49 . 0.125)
                       '(74 . 0)
                       '(49 . -0.125)
                       '(74 . 0)
                 ) ; end list
               ) ; end entmake
          )

        (setq lntyp nil)
        ;;create failed flag failed linetype
      ) ; endif
    ) ; end progn
  ) ; endif
  ;;  Layer Setup
  (if (not (tblsearch "layer" "Shelf"))
    (command "-layer" "_M" ; New
             "Shelf" ; name
             "_C" "3" ; color green
             "" "" ; done
  )
    )
  ;;  IF you want the rod on another layer
 ;(if (not (tblsearch "layer" "Rod"))
 ;  (command "-layer" "_M" "Rod"
 ;           "_L" lntyp ; set line type
 ;           "_C" "1"   ; set color
 ;           "" "")
 ;)
  ;; if you want the rod & shelf on same layer use this next line
  ;; as is. to use rod layer change "shelf" to "rod"
  (setq rodlay "Shelf")

  ;; Draw the pline, get the first point
  (if (setq pt1 (getpoint "\nPick points, Enter when done."))
    (progn
      ;;  start the pline command and get second point
      (command "PLINE" pt1 (setq pt2 (getpoint pt1)))
      (if pt2
        (progn
          ;;  loop getting points until user presses enter
          (while (setq pt2 (getpoint pt2 "\nNext point: "))
            (command pt2)
          )
          (command "") ; make sure command is ended
          (princ)
          (setq en1 (entlast)) ; get the pline drawn

          ;; getthe side to offset the shelf to
          (setvar "osmode" 0) ; turn osnaps off
          (initget 1)
          (if (setq pto (getpoint "\nPick Side to offset to:"))
            (progn
              (command "_.offset" 14 en1 pto "") ; shelf line 14
              (setq shelf (entlast))
              (command "_.offset" 12 en1 pto "") ; rod line 12
              (setq rod (entlast))
              (if lntyp ; if linetype exist or was created use it
                (command "Change" rod "" "P" "LT" lntyp "")
              )
              (command "change" shelf "" "p" "la" rodlay "")
              (command "change" shelf "" "p" "la" "shelf" "")
              (entdel en1) ; remove the user drawn line
            ) ; end progn
          ) ; endif pto
        ) ; end progn
      ) ; endif pt2
    ) ; end progn
  ) ; endif pt1
  (*error* "")
  ;; go to *error* for Exit Sequence

) ;_end of defun

;;; Notify user program ready to use
(prompt "\n Shelves Creator Loaded:   Type 'Shelf' to run it.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Closet Shelf Creator
« Reply #1 on: January 25, 2004, 10:45:42 PM »
Cab, for my Shelf & Rod, I use a custom MLine type and a custom button to set the scale, offset, and layer for the line. I can then select any point follow along that line and select the other point for the shelf.

I can post the linetype if you are interested.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Closet Shelf Creator
« Reply #2 on: January 25, 2004, 11:21:52 PM »
K
Curious as always.

Does it handle irregular closets, ie U shaped, L shaped, 45deg walls?

Would like to see how you did it.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Closet Shelf Creator
« Reply #3 on: January 25, 2004, 11:40:24 PM »
Here are my only personal line types.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

hendie

  • Guest
Closet Shelf Creator
« Reply #4 on: January 26, 2004, 04:08:19 AM »
that first one is okay if you're drawing in imperial but what if you're drawing in metric ?














 :P

Dommy2Hotty

  • Guest
Closet Shelf Creator
« Reply #5 on: February 02, 2004, 11:52:59 AM »
Here's the one I made for closets...it uses a polyline for irregular closets...

(defun c:RODSHELF()

(command "._pline") ; start pline
(while (eq (logand (getvar "CmdActive") 1) 1) ; while active command
(command pause) ; get user's input
) ;_ closes while


(setq PL (entlast))

(setq INT (getpoint "\nSelect Interior of closet : " ))
;gets side to offset

(command "offset" "12.0" PL INT "")

(setq SHELF (entlast))

(command "change" SHELF "" "P" "LA" "CAB" "")

(command "offset" "10.0" PL INT "")

(setq ROD (entlast))

(command "change" ROD "" "P" "LA" "CAB" "LT" "CENTER2" "")

(command "erase" PL "")

(command "explode" SHELF "")

(command "explode" ROD "")

(princ)

)
(princ)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Closet Shelf Creator
« Reply #6 on: February 02, 2004, 12:36:04 PM »
Paste this in a custom.mln file and load it with mlstyle

justification = zero, scale = 1, style = shelf

Quote

MLSTYLE
2
 SHELF
70
 0
3
 SHELF AND ROD
62
 256
51
 90.00000000000000
52
 90.00000000000000
71
 2
49
 12.00000000000000
62
 256
6
 Continuous
49
 10.00000000000000
62
 256
6
 DASHED
0
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Closet Shelf Creator
« Reply #7 on: February 02, 2004, 12:42:53 PM »
Oh.. .and yes CAB it DOES handle irregular shapes
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie