See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Closet Rod & Shelf LSP Not Working

  1. #1
    Active Member
    Join Date
    2007-02
    Posts
    61
    Login to Give a bone
    0

    Default Closet Rod & Shelf LSP Not Working

    Hi All:

    I'm desperately trying to learn LSP by looking at other people's routines, reading etc. I got this LSP from Harry's Get The Code but it doesn't seem to be working. I get the following:

    "Command: shelfrod
    Pick STUD WALL LINE to offset:
    Specify point toward closet: bad argument type: stringp nil
    Enter new layer name <0>:
    Enter property to change
    [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]:
    Command:"

    The whole routine follows. Any ideas?

    Code:
    ;;; CADALYST 07/08  www.cadalyst.com/code 
    ;;; Tip 2295: ShelfRod.lsp	Draw Closet Detail	(c) 2008 Mike Carter
    
    ;This routine offsets a given wall line by 12" and by 10" and changes new lines to the F?CAB and F?DASH layers.  Used for drawing shalves and rods in closets.
    
    (defun *error* (msg)
    	(setvar "OSMODE" TOSMODE)
    	(setvar "ORTHOMODE" TORTHOMODE)
    	(setvar "CLAYER" TCLAYER)
    	(prompt msg)
    	(princ)
    );end defun
    
    (DEFUN C:SHELFROD ()
    	(graphscr)
    	(setvar "CMDECHO" 0)
    	(setq
    		TOSMODE (getvar "OSMODE")
    		TORTHOMODE (getvar "ORTHOMODE")
    		TCLAYER (getvar "CLAYER")
    	)
    	(setvar "OSMODE" 512); nearest
    	(setq
    		wallline (entsel "\nPick STUD WALL LINE to offset: ")
    		firstendpnt (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
    		secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
    		pnt2 (getpoint "\nSpecify point toward closet: ")
    		ang1 (angle firstendpnt secondendpnt)
    	);end setq
    	(if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
    		(setq ang1 (+ ang1 pi))
    	);end if
    
    	(setvar "OSMODE" 0); none
    	(command
    		"offset" 12 wallline pnt2 ""
    		"change" "L" "" "P" "LA" (STRCAT PREFIX "CAB") ""
    		"offset" 10 wallline pnt2 ""
    		"change" "L" "" "P" "LA" (STRCAT PREFIX "DASH") ""
    	);end command
    	(setvar "OSMODE" 512); nearest
    	(setq
    		pnt3 (getpoint "\nPick START OF HANGERS on dashed ROD LINE: ")
    		pnt4 (getpoint "\nPick END OF HANGERS on dashed ROD LINE: ")
    		rodlength (distance pnt3 pnt4)
    		hangerdist 1.0
    	);end setq
    	(command
    		"erase" "L" ""
    		"erase" "L" ""
    	)
    	(setvar "OSMODE" 0); none
    	(while (>= (- rodlength hangerdist) 0)
    		(setq
    			rotate (rtos (getvar "DATE") 2 12)
    			rotate (substr rotate (strlen rotate))
    		);end setq
    		(if (= rotate "0")(setq rotate "5"))
    		(setq
    			rotate (atoi rotate)
    			rotate (/ rotate 5.0)
    			rotate (- rotate 1)
    			rotate (* rotate 10)
    		);end setq
    		(cond 
    			((= rotate -8.0)(setq rotate -4.5))
    			((= rotate -6.0)(setq rotate 1.5))
    			((= rotate -4.0)(setq rotate -7.5))
    			((= rotate -2.0)(setq rotate 5.5))
    			((= rotate 0.0)(setq rotate 4.0))
    			((= rotate 2.0)(setq rotate 0.5))
    			((= rotate 4.0)(setq rotate -6.0))
    			((= rotate 6.0)(setq rotate -2.5))
    			((= rotate 8.0)(setq rotate 8.0))
    		);end cond
    		(command
    			"-layer" "T" (strcat prefix "FURN") "M" (strcat prefix "FURN") ""
    			"line" "fro" pnt3 (strcat "@9<" (angtos (+ ang1 (* (/ 90.0 180.0) pi)))) (strcat "@18<" (angtos (- ang1 (* (/ 90.0 180.0) pi)))) ""
    			"rotate" "L" "" pnt3 rotate
    			"move" "P" "" "0,0" (strcat "@" (rtos hangerdist) "<" (angtos (angle pnt3 pnt4)))
    		);end command
    		(setq counter 1)
    		(while (< counter 12000)
    			(setq counter (+ counter 1))
    		);end while
    		(setq hangerdist (+ hangerdist (+ 2 (/ rotate 8.0))))
    	);end while
    	(command
    		"offset" 12 wallline pnt2 ""
    		"change" "L" "" "P" "LA" (STRCAT PREFIX "CAB") ""
    		"offset" 10 wallline pnt2 ""
    		"change" "L" "" "P" "LA" (STRCAT PREFIX "DASH") ""
    	)
    	(prompt "\nPosition text: ")
    	(setvar "ORTHOMODE" 0)
    	(command
    		"text" "C" (getvar "LASTPOINT") (angtos ang1) "1R & 1S"
    		"change" "L" "" "P" "LA" (STRCAT PREFIX "TEXT") ""
    		"move" "L" "" (getvar "LASTPOINT") pause
    	);end command
    	(setvar "OSMODE" TOSMODE)
    	(setvar "ORTHOMODE" TORTHOMODE)
    	(setvar "CLAYER" TCLAYER)
    	(princ)
    );end defun
    
    (C:SHELFROD)
    Last edited by Opie; 2008-06-12 at 02:06 PM. Reason: [CODE] tags added, see Moderator Note

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Closet Rod & Shelf LSP Not Working

    The initial problem I found is it is missing the assignment of the PREFIX variable. It is also assuming the layers are already created in your drawing.

    Another thing would to bring the defun of the *error* routine into the main routine and then localize your variables. Localizing your variable is, first, determining which variables need to only be available while the routine is running. These would be variables that the routine sets during its execution. For the ones that may be used by other routines or are set by other routines, then do not localize those variables. Now to localize the variables, you place the variable names which you know are not needed outside of this routine into the ( ) which follows the (DEFUN C:SHELFROD. Some that I feel should be localized are:
    Code:
    (DEFUN C:SHELFROD (/	       ANG1	   COUNTER     FIRSTENDPNT
    		   HANGERDIST  PNT2	   PNT3	       PNT4
    		   RODLENGTH   ROTATE	   SECONDENDPNT
    		   TCLAYER     TORTHOMODE  TOSMODE     WALLLINE
    		  )
    There is also an error with the placement of the text.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    1

    Default Re: Closet Rod & Shelf LSP Not Working

    This is a poor example of a lisp routine.
    I modified it to work if you only select a line object. That too needs to be fixed.
    But I have no more time tonight.
    Code:
    ;;; CADALYST 07/08  www.cadalyst.com/code 
    ;;; Tip 2295: ShelfRod.lsp	Draw Closet Detail	(c) 2008 Mike Carter
    
    ;; This routine offsets a given wall line by 12" and by 10" and changes
    ;; new lines to the F?CAB and F?DASH layers.  Used for drawing shalves
    ;; and rods in closets.
    
    
    (DEFUN C:SHELFROD (/ ANG1 COUNTER FIRSTENDPNT HANGERDIST PAUSE PNT2 PNT3 PNT4
                       PREFIX RODLENGTH ROTATE SECONDENDPNT TCLAYER TORTHOMODE
                       TOSMODE WALLLINE *error*
                      )
    
      (defun *error* (msg)
        (setvar "OSMODE" TOSMODE)
        (setvar "ORTHOMODE" TORTHOMODE)
        (setvar "CLAYER" TCLAYER)
        (prompt msg)
        (princ)
      )       ;end defun  
      
    (defun LayerMake(lyrname Color ltype)
      (if (tblsearch "LAYER" lyrname)
        (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
        (command "._Layer" "_Make" lyrname "_Color"
                 (if (or (null color)(= Color "")) "_White" Color) lyrname
                 "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
      )
    )
      
      (graphscr)
      (setvar "CMDECHO" 0)
      (setq
        TOSMODE    (getvar "OSMODE")
        TORTHOMODE (getvar "ORTHOMODE")
        TCLAYER    (getvar "CLAYER")
      )
      (setvar "OSMODE" 512) ; nearest
    
      
      ; CAB added
      (or Prefix (setq Prefix "F1"))
      (LayerMake "F1CAB" "white" nil)
      (LayerMake "F1Dash" "white" "Dashed")
      (LayerMake "F1Furn" "green" nil)
      (LayerMake "F1Text" "Yellow" nil)
    
      
      (setq
        wallline     (entsel "\nPick STUD WALL LINE to offset: ") ; CAB must be a line !!
        firstendpnt  (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
        secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
        pnt2         (getpoint "\nSpecify point toward closet: ")
        ang1         (angle firstendpnt secondendpnt)
      )       ;end setq
      (if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
        (setq ang1 (+ ang1 pi))
      )       ;end if
    
      (setvar "OSMODE" 0) ; none
      (command "offset" 12 wallline pnt2 "")
      (command "change" "L" "" "P" "LA" (STRCAT PREFIX "CAB") "")
      (command "offset" 10 wallline pnt2 "")
      (command "change" "L"  "" "P" "LA" (STRCAT PREFIX "DASH") "")       ;end command
      (setvar "OSMODE" 512) ; nearest
      (setq
        pnt3       (getpoint "\nPick START OF HANGERS on dashed ROD LINE: ")
        pnt4       (getpoint "\nPick END OF HANGERS on dashed ROD LINE: ")
        rodlength  (distance pnt3 pnt4)
        hangerdist 1.0
      )       ;end setq
      (command "erase" "L" "" "erase" "L" "")
      (setvar "OSMODE" 0) ; none
      (while (>= (- rodlength hangerdist) 0)
        (setq
          rotate (rtos (getvar "DATE") 2 12)
          rotate (substr rotate (strlen rotate))
        )     ;end setq
        (if (= rotate "0")
          (setq rotate "5")
        )
        (setq
          rotate (atoi rotate)
          rotate (/ rotate 5.0)
          rotate (- rotate 1)
          rotate (* rotate 10)
        )     ;end setq
        (cond
          ((= rotate -8.0) (setq rotate -4.5))
          ((= rotate -6.0) (setq rotate 1.5))
          ((= rotate -4.0) (setq rotate -7.5))
          ((= rotate -2.0) (setq rotate 5.5))
          ((= rotate 0.0) (setq rotate 4.0))
          ((= rotate 2.0) (setq rotate 0.5))
          ((= rotate 4.0) (setq rotate -6.0))
          ((= rotate 6.0) (setq rotate -2.5))
          ((= rotate 8.0) (setq rotate 8.0))
        )     ;end cond
        (command "-layer" "T" (strcat prefix "FURN") "M" (strcat prefix "FURN") "")
        (command "line" "fro" pnt3
          (strcat "@9<" (angtos (+ ang1 (* (/ 90.0 180.0) pi))))
          (strcat "@18<" (angtos (- ang1 (* (/ 90.0 180.0) pi))))
          "")
        (command "rotate" "L" "" pnt3 rotate)
        (command "move" "P" "" "0,0"
          (strcat "@" (rtos hangerdist) "<" (angtos (angle pnt3 pnt4)))
        )     ;end command
        ;|( (setq counter 1) ; CAB removed delay
       while (< counter 12000)
          (setq counter (+ counter 1))
        )     ;end while |;
        (setq hangerdist (+ hangerdist (+ 2 (/ rotate 8.0))))
      )       ;end while
      (command "offset" 12 wallline pnt2 "")
      (command "change" "L" "" "P" "LA" (STRCAT PREFIX "CAB") "")
      (command "offset" 10 wallline pnt2 "")
      (command "change" "L" "" "P" "LA" (STRCAT PREFIX "DASH") "")
      (prompt "\nPosition text: ")
      (setvar "ORTHOMODE" 0)
      ;;  CAB changed
     ;; If text height is undefined (signified by 0 in the table) 
      (if (zerop (cdr(assoc 40(tblsearch "style" (getvar "textstyle")))))
        ;; Draw the text using the current text height (textsize) 
        (command ".text" "c" "_non" (getvar "LASTPOINT") ""(angtos ang1) "1R & 1S")
        ;; Otherwise use the defined text height 
        (command ".text" "c" "_non" (getvar "LASTPOINT") (angtos ang1) "1R & 1S")
      ) ; endif
      ;; (command "text" "C" (getvar "LASTPOINT") (angtos ang1) "1R & 1S")
      
      (command "change" "L" "" "P" "LA" (STRCAT PREFIX "TEXT") "")
      (command "move" "L" "" (getvar "LASTPOINT") pause)
      (setvar "OSMODE" TOSMODE)
      (setvar "ORTHOMODE" TORTHOMODE)
      (setvar "CLAYER" TCLAYER)
      (princ)
    )         ;end defun

Similar Threads

  1. Closet Shelving
    By ty_demo15 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2008-02-05, 06:33 PM
  2. Where can I get this type of closet?
    By Dave Lewis in forum Revit Architecture - General
    Replies: 1
    Last Post: 2006-12-16, 10:57 PM
  3. Closet Shelf and Pole on Angled Wall
    By tonyisenhoff in forum Revit Architecture - General
    Replies: 5
    Last Post: 2006-10-25, 02:28 PM
  4. Closet rod and shelves
    By Bill.Jensen in forum ACA General
    Replies: 2
    Last Post: 2006-05-25, 11:59 AM
  5. Closet shelf and rod
    By rodneyf in forum Revit Architecture - General
    Replies: 3
    Last Post: 2003-09-23, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •