progeCAD support, tips and troubleshooting forum. progeCAD works very similar to some versions of AutoCAD. Moderated.

Moderators: caddit, Moderators

#2361 by harebal20
Fri Mar 03, 2017 12:23 pm
Hello everyone,

I am new to the forum and would like to say thank you for this chance to be apart of this group.
I am also a new user for progeCAD. I have used AutoCAD for 10+ yrs and have made the switch. A small issue has come to light though. I have been using a LISP routine that was shared on a forum post (not sure of the exact forum though) and now that I am using the different program it will not read the LISP routine for some reason. It works completely fine with AutoCAD but will not run with progeCAD. Could someone assist me please? what is stumping me is that it will work with one program but not the other.

;; PanelDivRect.lsp [command name: PDR]
;; To Divide a Rectangular area into equal-sized Panels, with
;; intermediate spaces/elements between them, e.g. store-front
;; framing members, fence posts, property boundaries if zero-
;; width space between, stiles & rails in doors, etc.
;; User specifies:
;; a. whether to divide in one direction or both;
;; b. whether to draw a space/element around the perimeter;
;; c. the number of panels [in each direction if applicable];
;; d. the width of the spaces/elements between/around;
;; e. three corners of the rectangular area to divide.
;; Routine saves settings and offers them as defaults on
;; subsequent use.

;; Kent Cooper, December 2010

(defun C:PDR ; = Panel Divider, Rectangular
(/ *error* cmde osm blipm orthom divdirtemp perimtemp
pnlqLtemp pnlqWtemp spcwtemp cor1 corL len angL
corW angW wid spcqL spcqW pnlL pnlW)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); end if
(command)
(setvar 'osmode osm)
(setvar 'blipmode blipm)
(setvar 'orthomode orthom)
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
); end defun - *error*
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(command "_.undo" "_begin")
(setq
osm (getvar 'osmode)
blipm (getvar 'blipmode)
orthom (getvar 'orthomode)
); end setq

(initget (if *divdir* 0 1) "1 2"); no Enter on first use
(setq
divdirtemp
(getkword
(strcat
"Divide one way or both {1/2}?"
(if *divdir* (strcat " <" *divdir* ">") "")
": "
); end strcat
); end getkword & divdirtemp
*divdir* (if divdirtemp divdirtemp *divdir*)
); end setq

(initget (if *perim* 0 1) "Yes No"); no Enter on first use
(setq
perimtemp
(getkword
(strcat
"Space/element around perimeter {Yes/No}?"
(if *perim* (strcat " <" (substr *perim* 1 1) ">") "")
": "
); end strcat
); end getkword & perimtemp
*perim* (if perimtemp perimtemp *perim*)
); end setq

(initget (if *pnlqL* 6 7)); no Enter on first use, no 0, no negative
(setq ; for PaNeL Quantity in direction of Length [1st direction]
pnlqLtemp
(getint
(strcat
"\nNumber Panels"
(if (= *divdir* "2") " in first direction" "")
(if *pnlqL* (strcat " <" (itoa *pnlqL*) ">") ""); default only if not first use
": "
); end strcat
); end getdist & pnlqLtemp
*pnlqL* (if pnlqLtemp pnlqLtemp *pnlqL*)
); end setq

(if (= *divdir* "2")
(progn ; then
(initget (if *pnlqW* 6 7)); no Enter on first use, no 0, no negative
(setq ; for PaNeL Quantity in direction of Width [2nd direction]
pnlqWtemp
(getint
(strcat
"\nNumber Panels in second direction"
(if *pnlqW* (strcat " <" (itoa *pnlqW*) ">") ""); default only if not first use
": "
); end strcat
); end getdist & pnlqLtemp
*pnlqW* (if pnlqWtemp pnlqWtemp *pnlqW*)
); end setq
); end progn
(setq *pnlqW* 1); else
); end if

(initget (if *spcw* 4 5) "A B C"); no Enter on first use, no negative
(setq
spcwtemp
(getdist
(strcat
"\nWidth of space/element between Panels, or [A=1.75/B=2/C=3.5]"
(if *spcw* (strcat " <" (rtos *spcw* 2 4) ">") ""); default only if not first use
": "
); end strcat
); end getdist & spcwtemp
*spcw*
(cond
((= spcwtemp "A") 1.75)
((= spcwtemp "B") 2)
((= spcwtemp "C") 3.5)
((numberp spcwtemp) spcwtemp); user entered number or picked distance
(T *spcw*); otherwise, user hit Enter - keep value
); end cond & *spcw*
); end setq

(setvar 'orthomode 0)
(setq
cor1 (getpoint "\nFirst corner:")
corL
(getpoint cor1
(strcat
"\nOther End of "
(if (= *divdir* "1")
"Length to be divided:"
"Length in first direction:"
); end if
); end strcat
); end getpoint & corL
len (distance cor1 corL)
angL (angle cor1 corL)
); end setq
(while
(not
(and
(setq corW
(getpoint cor1
(strcat
"\nOther Side of "
(if (= *divdir* "1")
"Width:"
"Width in second direction:"
); end if
); end strcat
); end getpoint
); end setq & corW
(equal
(abs
(rem
(-
(setq angW (angle cor1 corW))
angL
); end -
pi
); end rem
); end abs
(/ pi 2)
1e-6
); end equal
); end and
); end not
(prompt "\nThree points must form right angle.")
); end while
(setq
wid (distance cor1 corW)
spcqL (if (= *perim* "Yes") (1+ *pnlqL*) (1- *pnlqL*))
spcqW (if (= *perim* "Yes") (1+ *pnlqW*) (1- *pnlqW*))
pnlL (/ (- len (* *spcw* spcqL)) *pnlqL*)
pnlW (/ (- wid (* *spcw* spcqW)) *pnlqW*)
); end setq

(setvar 'blipmode 0)
(setvar 'osmode 0)

(if (= *perim* "Yes")
(progn
(command "_.pline" cor1 corL (polar corL angW wid) corW "_close"); draw perimeter
(setq cor1 ; set starting point inboard of perimeter by space width both ways
(polar (polar cor1 angL *spcw*) angW *spcw*)
); end setq
); end progn
); end if

(repeat *pnlqW*
(setq corS cor1) ; Starting corner for individual panel
(repeat *pnlqL*
(command
"_.pline"
corS
(polar corS angL pnlL)
(polar (getvar 'lastpoint) angW pnlW)
(polar corS angW pnlW)
"_close"
); end command
(setq corS (polar corS angL (+ pnlL *spcw*))); for next one this row
); end repeat - pnlqL
(setq cor1 (polar cor1 angW (+ pnlW *spcw*))); new starting point for next row
); end repeat - pnlqW

(setvar 'osmode osm)
(setvar 'blipmode blipm)
(setvar 'orthomode orthom)
(command "_.undo" "_end")
(setvar 'cmdecho cmde)
(princ)
); end defun


John
#2362 by jouni
Wed Mar 08, 2017 8:59 am
Hello

First change all ' to " like this:

(command)
(setvar "osmode" osm)
(setvar "blipmode" blipm)
(setvar "orthomode" orthom)
(command "_.undo" "_end")
(setvar "cmdecho" cmde)
); end defun - *error*
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_.undo" "_begin")
(setq
osm (getvar "osmode")
blipm (getvar "blipmode")
orthom (getvar "orthomode")
); end setq

Then you can run it. I had this error:

Command: C:PDR
Command: PDR
Divide one way or both {1/2}?: 1
Space/element around perimeter {Yes/No}?: y
Number Panels: 2
Width of space/element between Panels, or [A=1.75/B=2/C=3.5]: a
Error: bad argument type

I tried also A and number 3.5. So I do not know what is wrong. Hopefully this leads you forward.
#2363 by harebal20
Wed Mar 08, 2017 4:31 pm
Thank you very much that was great help.

I had the same error occur, however, I found the issue. Later in the program I had to replace the ' to " like at the beginning of the program.

Again, thank you very much.