Jump to content

Need help with a Lumber lisp Routine


wipo

Recommended Posts

I have a few lisp routine that I used before in my previous job. I trying to load them at my new station, but when I type it in the command line it tells this

; error: no function definition: $START what need to done to make it work. Thx in advance.

 

(defun C:LUMBER ()LUMBER
 ($start)
 (setq lay (getvar "clayer"))
 ($setvar "clayer" lay)
 (defun D90 () (* pi 0.5))
 (defun D270 () (* pi 1.5))
 (setq OLD_ERR *error*
*error* STLP:ERR
 )
 ($setvar "cmdecho" 0)
 (if set2layr
   (set2layr "S-DETL-WOOD" "S")
 )
 (if (not L_THK)
   (setq L_THK 2.0)
 )
 (if (not L_DEP)
   (setq L_DEP 4.0)
 )
 (if (not LL_THK)
   (setq LL_THK 2.0)
 )
 (if (not LL_DEP)
   (setq LL_DEP 2.0)
 )
 (if (not LR_THK)
   (setq LR_THK 2.0)
 )
 (if (not LR_DEP)
   (setq LR_DEP 2.0)
 )
 (if (not TOG_LVIEW)
   (setq TOG_LVIEW 2)
 )
 (if (not TOG_MTYPE)
   (setq TOG_MTYPE 2)
 )
 (if (not TOG_DTYPE)
   (setq TOG_DTYPE 0)
 )
 (if (not TOG_LLEFT)
   (setq TOG_LLEFT 0)
 )
 (if (not TOG_LRIGHT)
   (setq TOG_LRIGHT 0)
 )
 (if (not LUM_GAP)
   (setq LUM_GAP 0.0)
 )
 (setq dcl_id (load_dialog "lumber.dcl"))
 (if (not (new_dialog "lumber" dcl_id))
   (exit)
 )
 (set_tile "edt_thk" (rtos L_THK 4 4))
 (set_tile "edt_dep" (rtos L_DEP 4 4))
 (set_tile "edt_gap" (rtos LUM_GAP 4 4))
 (if (= TOG_LLEFT 1)
   (set_tile "tog_lleft" "2")
 )
 (if (= TOG_LRIGHT 1)
   (set_tile "tog_lright" "2")
   ($finish)
 )
 (defun SET:VIEW (VW)
   (cond
     ((= VW 1)
      (mode_tile "rad_mb2" 1)
      (mode_tile "rad_mb3" 1)
      (mode_tile "rad_mb4" 1)
      (mode_tile "rad_sgl" 1)
      (setq TOG_MTYPE 1)
      (set_tile "rad_mb1" "2")
      (if (= TOG_DTYPE 0)
 (progn
   (setq TOG_DTYPE 1)
   (set_tile "rad_dbl" "2")
 )
      )
     )
     ((= VW 2)
      (mode_tile "rad_mb2" 0)
      (mode_tile "rad_mb3" 0)
      (mode_tile "rad_mb4" 0)
      (mode_tile "rad_sgl" 1)
      (if (= TOG_DTYPE 0)
 (progn
   (setq TOG_DTYPE 1)
   (set_tile "rad_dbl" "2")
 )
      )
     )
     (T
      (mode_tile "rad_mb2" 0)
      (mode_tile "rad_mb3" 0)
      (mode_tile "rad_mb4" 0)
      (mode_tile "rad_sgl" 0)
     )
   )
 )
 (cond
   ((= TOG_LVIEW 0) (set_tile "rad_thk" "2"))
   ((= TOG_LVIEW 1) (set_tile "rad_dep" "2"))
   ((= TOG_LVIEW 2) (set_tile "rad_sec" "2"))
 )
 (cond
   ((= TOG_MTYPE 1) (set_tile "rad_mb1" "2"))
   ((= TOG_MTYPE 2) (set_tile "rad_mb2" "2"))
   ((= TOG_MTYPE 3) (set_tile "rad_mb3" "2"))
   ((= TOG_MTYPE 4) (set_tile "rad_mb4" "2"))
 )
 (SET:VIEW TOG_LVIEW)
 (cond
   ((= TOG_DTYPE 0) (set_tile "rad_sgl" "2"))
   ((= TOG_DTYPE 1) (set_tile "rad_dbl" "2"))
   ((= TOG_DTYPE 2) (set_tile "rad_tpl" "2"))
 )
 (defun CK:LLEFT ()
   (if (= TOG_LLEFT 1)
     (progn
(mode_tile "edt_lthk" 0)
(mode_tile "edt_ldep" 0)
     )
     (progn
(mode_tile "edt_lthk" 1)
(mode_tile "edt_ldep" 1)
     )
   )
   (set_tile "edt_lthk" (rtos LL_THK 4 4))
   (set_tile "edt_ldep" (rtos LL_DEP 4 4))
 )
 (defun CK:LRIGHT ()
   (if (= TOG_LRIGHT 1)
     (progn
(mode_tile "edt_rthk" 0)
(mode_tile "edt_rdep" 0)
     )
     (progn
(mode_tile "edt_rthk" 1)
(mode_tile "edt_rdep" 1)
     )
   )
   (set_tile "edt_rthk" (rtos LR_THK 4 4))
   (set_tile "edt_rdep" (rtos LR_DEP 4 4))
 )
 (CK:LLEFT)
 (CK:LRIGHT)
 (action_tile "edt_thk" "(setq L_THK (distof $value))")
 (action_tile "edt_dep" "(setq L_DEP (distof $value))")
 (action_tile
   "tog_lleft"
   "(setq TOG_LLEFT (atoi $value)) (CK:LLEFT)"
 )
 (action_tile "edt_lthk" "(setq LL_THK (distof $value))")
 (action_tile "edt_ldep" "(setq LL_DEP (distof $value))")
 (action_tile
   "tog_lright"
   "(setq TOG_LRIGHT (atoi $value)) (CK:LRIGHT)"
 )
 (action_tile "edt_rthk" "(setq LR_THK (distof $value))")
 (action_tile "edt_rdep" "(setq LR_DEP (distof $value))")
 (action_tile "rad_thk" "(setq TOG_LVIEW 0) (SET:VIEW 0)")
 (action_tile "rad_dep" "(setq TOG_LVIEW 1) (SET:VIEW 1)")
 (action_tile "rad_sec" "(setq TOG_LVIEW 2) (SET:VIEW 2)")
 (action_tile "rad_mb1" "(setq TOG_MTYPE 1)")
 (action_tile "rad_mb2" "(setq TOG_MTYPE 2)")
 (action_tile "rad_mb3" "(setq TOG_MTYPE 3)")
 (action_tile "rad_mb4" "(setq TOG_MTYPE 4)")
 (action_tile "edt_gap" "(setq LUM_GAP (distof $value))")
 (action_tile "rad_sgl" "(setq TOG_DTYPE 0)")
 (action_tile "rad_dbl" "(setq TOG_DTYPE 1)")
 (action_tile "rad_tpl" "(setq TOG_DTYPE 2)")
 (action_tile "accept" "(done_dialog 4)")
 (action_tile "cancel" "(done_dialog 0)")
 (setq DO_NEXT (start_dialog))
 (if (= DO_NEXT 4)
   (progn
;;; Set finished size
     (if (> 7.0 L_THK)
(setq L_THK1 (- L_THK 0.5))
(setq L_THK1 (- L_THK 0.75))
     )
     (if (> 7.0 L_DEP)
(setq L_DEP1 (- L_DEP 0.5))
(setq L_DEP1 (- L_DEP 0.75))
     )
     (if (> 7.0 LL_THK)
(setq LL_THK1 (- LL_THK 0.5))
(setq LL_THK1 (- LL_THK 0.75))
     )
     (if (> 7.0 LL_DEP)
(setq LL_DEP1 (- LL_DEP 0.5))
(setq LL_DEP1 (- LL_DEP 0.75))
     )
     (if (> 7.0 LR_THK)
(setq LR_THK1 (- LR_THK 0.5))
(setq LR_THK1 (- LR_THK 0.75))
     )
     (if (> 7.0 LR_DEP)
(setq LR_DEP1 (- LR_DEP 0.5))
(setq LR_DEP1 (- LR_DEP 0.75))
     )
     (cond
((= TOG_LVIEW 0)
;;;Plan on thickness
 (cond
   ((= TOG_DTYPE 0) (LMB:THICK1))
   ((= TOG_DTYPE 1) (LMB:THICK2))
   ((= TOG_DTYPE 2) (LMB:THICK3))
 )
)
((= TOG_LVIEW 1)
;;;Plan on Depth
 (cond
   ((= TOG_DTYPE 0) (LMB:DEPTH1))
   ((= TOG_DTYPE 1) (LMB:DEPTH2))
   ((= TOG_DTYPE 2) (LMB:DEPTH3))
 )
)
((= TOG_LVIEW 2)
;;;Section
 (cond
   ((= TOG_DTYPE 0) (LMB:SECT1))
   ((= TOG_DTYPE 1)
    (if (= TOG_LLEFT 1)
      (LMB:SECT2L)
      (LMB:SECT2)
    )
   )
   ((= TOG_DTYPE 2) (LMB:SECT3))
 )
)
     )
   )
 )
 (princ)
)
;;; Single Line on Thickness
(defun LMB:THICK1 (/ PT1 PT2 PT3 PT4 D2)
 (setq PT1 (getpoint "\nLeft Center Placement Point: "))
 (setq PT2 (getpoint PT1 "\nLumber Length-Angle: "))
 (setq ANG (angle PT1 PT2))
 (command "._line" PT1 PT2 "")
 (setq EL1 (entlast))
 (setq D2 (+ L_THK1 LUM_GAP))
 (cond
   ((= TOG_MTYPE 2)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
   )
   ((= TOG_MTYPE 3)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
   )
   ((= TOG_MTYPE 4)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 3))
    )
   )
 )
)
;;; Double Line on Thickness
(defun LMB:THICK2 (/ PT1 PT2 PT3 PT4 D2)
 (setq PT1 (getpoint "\nLower Left Placement Point: "))
 (setq PT2 (getpoint PT1 "\nLumber Length-Angle: "))
 (setq ANG (angle PT1 PT2))
 (setq PT3 (polar PT2 (+ ANG (D90)) L_THK1)
PT4 (polar PT1 (+ ANG (D90)) L_THK1)
 )
 (command "._pline" PT1 "w" 0 0 PT2 PT3 PT4 "c")
 (setq EL1 (entlast))
 (setq D2 (+ L_THK1 LUM_GAP))
 (cond
   ((= TOG_MTYPE 2)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
   )
   ((= TOG_MTYPE 3)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
   )
   ((= TOG_MTYPE 4)
    (command "._copy" EL1 "" PT1 (polar PT1 (+ ANG (D90)) D2))
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
    (command "._copy"
      EL1
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 3))
    )
   )
 )
)
;;; Section Double Line
(defun LMB:SECT2 (/ PT1 PT2 PT3 PT4 D2)
 (setq PT1 (getpoint "\nLower Left Placement Point: ")
ANG (getangle PT1 "\nRotation Angle: ")
PT2 (polar PT1 ANG L_DEP1)
PT3 (polar PT2 (+ ANG (D90)) L_THK1)
PT4 (polar PT1 (+ ANG (D90)) L_THK1)
 )
 (command "._pline" PT1 "w" 0 0 PT2 PT3 PT4 "c")
 (setq EL1 (entlast))
 (command "._line" PT1 PT3 "")
 (setq EL2 (entlast))
 (command "._line" PT2 PT4 "")
 (setq EL3 (entlast))
 (command "._change" EL2 EL3 "" "p" "c" "1" "")
 (setq D2 (+ L_THK1 LUM_GAP))
 (cond
   ((= TOG_MTYPE 2)
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) D2)
    )
   )
   ((= TOG_MTYPE 3)
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) D2)
    )
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
   )
   ((= TOG_MTYPE 4)
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) D2)
    )
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 2))
    )
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 (+ ANG (D90)) (* D2 3))
    )
   )
 )
)
;;; Section Double Line w/Ledgers
(defun LMB:SECT2L (/ PT1 PT2 PT3 PT4 D2)
 (setq PT1 (getpoint "\nLower Left Placement Point: "))
 (setq ANG 0.0)
 (setq PT2 (polar PT1 ANG LL_THK1))
 (setq PT3 (polar PT2 (+ ANG (D90)) LL_DEP1))
 (setq PT4 (polar PT1 (+ ANG (D90)) LL_DEP1))
 (command "._pline" PT1 "w" 0 0 PT2 PT3 PT4 "c")
 (command "._line" PT1 PT3 "")
 (setq EL2 (entlast))
 (command "._line" PT2 PT4 "")
 (setq EL3 (entlast))
 (command "._change" EL2 EL3 "" "p" "c" "1" "")
 (setq PT1 PT2)
 (setq PT2 (polar PT1 ANG L_THK1)
PT3 (polar PT2 (+ ANG (D90)) L_DEP1)
PT4 (polar PT1 (+ ANG (D90)) L_DEP1)
 )
 (command "._pline" PT1 PT2 PT3 PT4 "c")
 (setq EL1 (entlast))
 (command "._line" PT1 PT3 "")
 (setq EL2 (entlast))
 (command "._line" PT2 PT4 "")
 (setq EL3 (entlast))
 (command "._change" EL2 EL3 "" "p" "c" "1" "")
 (setq D2 (+ L_THK1 LUM_GAP))
 (cond
   ((= TOG_MTYPE 2)
    (command "._copy" EL1 EL2 EL3 "" PT1 (polar PT1 ANG D2))
    (setq PT1 (polar PT2 ANG D2))
   )
   ((= TOG_MTYPE 3)
    (command "._copy" EL1 EL2 EL3 "" PT1 (polar PT1 ANG D2))
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 ANG (* D2 2))
    )
    (setq PT1 (polar PT2 ANG (* D2 2)))
   )
   ((= TOG_MTYPE 4)
    (command "._copy" EL1 EL2 EL3 "" PT1 (polar PT1 ANG D2))
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 ANG (* D2 2))
    )
    (command "._copy"
      EL1
      EL2
      EL3
      ""
      PT1
      (polar PT1 ANG (* D2 3))
    )
    (setq PT1 (polar PT2 ANG (* D2 3)))
   )
 )
 (setq PT2 (polar PT1 ANG LR_THK1))
 (setq PT3 (polar PT2 (+ ANG (D90)) LR_DEP1))
 (setq PT4 (polar PT1 (+ ANG (D90)) LR_DEP1))
 (command "._pline" PT1 "w" 0 0 PT2 PT3 PT4 "c")
 (command "._line" PT1 PT3 "")
 (setq EL2 (entlast))
 (command "._line" PT2 PT4 "")
 (setq EL3 (entlast))
 (command "._change" EL2 EL3 "" "p" "c" "1" "")
)
;;; Double Line on Depth
(defun LMB:DEPTH2 (/ PT1 PT2 PT3 PT4)
 (setq PT1 (getpoint "\nLower Left Placement Point: "))
 (setq PT2 (getpoint PT1 "\nLumber Length-Angle: "))
 (setq ANG (angle PT1 PT2))
 (setq PT3 (polar PT2 (+ ANG (D90)) L_DEP1)
PT4 (polar PT1 (+ ANG (D90)) L_DEP1)
 )
 (command "._pline" PT1 "w" 0 0 PT2 PT3 PT4 "c")
 (setq EL1 (entlast))
)

Edited by SLW210
added code tags!!
Link to comment
Share on other sites

The message is exactly that $start does not exist it probably existed in your acaddoc.lsp etc and was loaded on starting autocad. You need to find it. Try ;($start) and see what happens

Link to comment
Share on other sites

Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags.

 

SLW210 perhaps this should be made a STICKY?

 

It seems that almost every first post of this type, you or another administrator, or member

needs to supply this link or clarify this instruction.

When I recently wanted to advise a newbie of this, I was unable to find the link to it.

Link to comment
Share on other sites

It's already a sticky: http://www.cadtutor.net/forum/forumdisplay.php?21-AutoLISP-Visual-LISP-amp-DCL

 

And also, lisp questions should be posted in the Autolisp section of the forum, which is where this thread has been moved. ;)

 

I missed that, where was it?

 

Usually the first thing I check when going through the threads. :ouch:

 

So I fixed it for you wipo, it isn't that difficult to add Code Tags, just [NOPARSE]

"YOUR CODE HERE"

[/NOPARSE]

 

When editing you can also use "Go Advanced" at lower right of reply box and you will get the # that automagically adds the [NOPARSE]


[/NOPARSE] then copy and paste the code in between.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...