Homerun Lisp routine that has stopped

Homerun Lisp routine that has stopped

j.pratt8S23E
Contributor Contributor
955 Views
6 Replies
Message 1 of 7

Homerun Lisp routine that has stopped

j.pratt8S23E
Contributor
Contributor

I have an homerun.lsp routine that has worked in the past and after moving to a new company I now can't get it to  work for some reason.   When I run it it just prints the princ line followed with "error:  quit / exit abort"

 

I'm not sure what is causing the error out of the routine.   Could someone with knowledge look at this or try it and see what could be the issue?  I have the code for the lsp routine as well as the dcl file for the dialog box and both are zipped as an attachment.

Homerun.lsp

(defun c:hr ();
  (princ "\nHOMERUN.lsp)
  (if (= place_cir nil) (setq place_cir "0"))
  (if (= place_pnl nil) (setq place_pnl "0"))
  (if (= no_circuits nil) (setq no_circuits "1"))
  (if (= to_panel nil) (setq to_panel ""))
  (setq dcl_id (load_dialog "homerun.dcl"))
  (if (not (new_dialog "homerun" dcl_id))
    (exit)
  )
  (set_tile "place_cir" place_cir)
  (set_tile "place_pnl" place_pnl)
  (if (= place_pnl "0") (mode_tile "to_panel" 1))
  (set_tile "to_panel" to_panel)
  (set_tile "no_circuits" no_circuits)
  (mode_tile "no_circuits" 2)
  (action_tile "place_pnl" "(setq place_pnl $value)(mode_tile \"to_panel\" (- 1 (atoi $value)))")
  (action_tile "place_cir" "(setq place_cir $value)")
  (action_tile "to_panel" "(setq to_panel $value)")
  (action_tile "no_circuits" "(setq no_circuits $value)")
  (start_dialog)
  (unload_dialog dcl_id)
  (setq cstyle (getvar "textstyle"))
  (setq reset (getvar"clayer"))
  (setq sf (getvar "dimscale"))
  (setq arrsize (* 0.16 sf))
  (setq arrwidth (* arrsize 0.333))
  (command "redraw")
  (setq sp (getpoint "\nSelect start point: "))
  (setq dp (getpoint sp "\nSelect start angle: "))
  (setq sar (angle sp dp))
  (setq sad (* sar (/ 180 pi)))
  (setq tsp (polar sp (+ sar pi) (* 0.2 sf)))
  (if (= place_pnl "1") (progn
    (command "layer" "s" "note" "")
    (command "text" "s" "4" "M" tsp "" 0 (prin1 to_panel))
  ))
  (command "layer" "s" "E-Homerun" "")
  (setq count 0)
  (while (< count (atoi no_circuits))
    (setq ep (polar sp sar arrsize))
    (command "pline" sp "w" 0 arrwidth ep "")
    (if (= place_cir "1") (progn
      (setq c (1+ count))
      (command "layer" "s" "note" "")
      (prompt "\nCircuit No. ") (prompt (rtos c 5))
      (setq ctext (getstring ": "))
      (setq cnsp (polar sp sar (/ (distance sp ep) 2.0)))
      (setq cnsp (polar cnsp (+ sar (/ pi 2.0)) (* 0.15 sf)))
      (command "text" "s" "4" "m" cnsp "" 0 (prin1 ctext))
      (command "layer" "s" "E-Homerun" "")
    ))
    (setq sp ep)
    (setq count (1+ count))
  )
  (setvar "textstyle" cstyle)
  (command "pline" sp "w" 0 0 "a")
)

homerun.dcl

homerun : dialog {
    label = "Draw Home Run";
    : image { label = "Zork!";
        key = "tester";
    }
    : boxed_column { label = "Panel Text:";
    : toggle { label = "Place"; 
        key = "place_pnl";
        mnemonic = "C";
    }
    : edit_box { label = "Designation:";
        key = "to_panel";
        mnemonic = "L";
    }
    }
    : boxed_column { label = "Circuit Numbers:";
    : toggle { label = "Place";
        key = "place_cir";
        mnemonic = "P";
    }
    : edit_box { label = "No. of circuits:";
        mnemonic = "N";
        key = "no_circuits";
        allow_accept = true;
    }
    }
    ok_cancel;
}

Thanks a ton!

0 Likes
956 Views
6 Replies
Replies (6)
Message 2 of 7

ronjonp
Mentor
Mentor

Try closing you text here: 

(princ "\nHOMERUN.lsp")

You also might want to localize your variables .. that can cause headaches too.

(/	      arrsize  arrwidth	c	 cnsp	  count	   cstyle   ctext    dcl_id
	     dp	      ep       no_circuits	 place_cir	   place_pnl	     reset
	     sad      sar      sf	sp	 to_panel tsp
	    )
0 Likes
Message 3 of 7

j.pratt8S23E
Contributor
Contributor

Yeah closing that with the quote didn't fix it.  As far as localization not sure how to do that.  I know nothing about coding.

 

Thanks for trying.. 

0 Likes
Message 4 of 7

ronjonp
Mentor
Mentor

You might check that the layers 'note' and 'e-homerun' exist in the drawing as well as the textstyle '4' .. that is what is crashing here.

To create the layers and set them use:

(command "layer" "m" "note" "")

rather than

(command "layer" "s" "note" "")
0 Likes
Message 5 of 7

j.pratt8S23E
Contributor
Contributor

Yeah it's weird nothing has fixed this issue.   So not sure what could be causing it.

 

Thanks for the help.

0 Likes
Message 6 of 7

Jonathan3891
Advisor
Advisor

It worked fine for me once I met all the requirements.

 

Required Layers:
E-Homerun

Note

 

Required Text Style:

4

 

defun c:hr (/);
  (princ "\nHOMERUN.lsp")
  (if (= place_cir nil) (setq place_cir "0"))
  (if (= place_pnl nil) (setq place_pnl "0"))
  (if (= no_circuits nil) (setq no_circuits "1"))
  (if (= to_panel nil) (setq to_panel ""))
  (setq dcl_id (load_dialog "homerun.dcl"))
  (if (not (new_dialog "homerun" dcl_id))
    (exit)
  )
  (set_tile "place_cir" place_cir)
  (set_tile "place_pnl" place_pnl)
  (if (= place_pnl "0") (mode_tile "to_panel" 1))
  (set_tile "to_panel" to_panel)
  (set_tile "no_circuits" no_circuits)
  (mode_tile "no_circuits" 2)
  (action_tile "place_pnl" "(setq place_pnl $value)(mode_tile \"to_panel\" (- 1 (atoi $value)))")
  (action_tile "place_cir" "(setq place_cir $value)")
  (action_tile "to_panel" "(setq to_panel $value)")
  (action_tile "no_circuits" "(setq no_circuits $value)")
  (start_dialog)
  (unload_dialog dcl_id)
  (setq cstyle (getvar "textstyle"))
  (setq reset (getvar"clayer"))
  (setq sf (getvar "dimscale"))
  (setq arrsize (* 0.16 sf))
  (setq arrwidth (* arrsize 0.333))
  (command "redraw")
  (setq sp (getpoint "\nSelect start point: "))
  (setq dp (getpoint sp "\nSelect start angle: "))
  (setq sar (angle sp dp))
  (setq sad (* sar (/ 180 pi)))
  (setq tsp (polar sp (+ sar pi) (* 0.2 sf)))
  (if (= place_pnl "1") (progn
    (command "layer" "s" "note" "")
    (command "text" "s" "4" "M" tsp "" 0 (prin1 to_panel))
  ))
  (command "layer" "s" "E-Homerun" "")
  (setq count 0)
  (while (< count (atoi no_circuits))
    (setq ep (polar sp sar arrsize))
    (command "pline" sp "w" 0 arrwidth ep "")
    (if (= place_cir "1") (progn
      (setq c (1+ count))
      (command "layer" "s" "note" "")
      (prompt "\nCircuit No. ") (prompt (rtos c 5))
      (setq ctext (getstring ": "))
      (setq cnsp (polar sp sar (/ (distance sp ep) 2.0)))
      (setq cnsp (polar cnsp (+ sar (/ pi 2.0)) (* 0.15 sf)))
      (command "text" "s" "4" "m" cnsp "" 0 (prin1 ctext))
      (command "layer" "s" "E-Homerun" "")
    ))
    (setq sp ep)
    (setq count (1+ count))
  )
  (setvar "textstyle" cstyle)
  (command "pline" sp "w" 0 0 "a")
)

 


Jonathan Norton
Blog | Linkedin
0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@j.pratt8S23E wrote:

Yeah it's weird nothing has fixed this issue.   So not sure what could be causing it. ....


In addition to @Jonathan3891 's listed requirements, it's also necessary that the Text Style called "4" is defined without a fixed height.  If it has a fixed  height, the "" in each Text command, which is accepting the default most-recently-used height, should be removed, because there will be no height prompt to be answered.

Kent Cooper, AIA
0 Likes