
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings all! I just started a new position at a steel detailing company. From what I hear, they just recently upgraded to AutoCAD 2016 and some of the "tools" they have been using are no longer functioning correctly.
I have a Python programming background, so learning autoLisp was pretty straightforward, but I have -zero- experience with AutoCAD itself. After looking through and reengineering the code, I don't see why it isn't functioning correctly, and was hoping someone here might be able to peruse and find any glaring issues.
The routine stops after creating a rectangle and says: error bad argument type: consp 0.0
Thanks for any and all help. Cheers!
(setvar "cmdecho" 0)
(setq deckwidth 0 decklength 0 lapleft 0 lapright 0 l_text 0 ang 0 t_distance 0 pt1 '(0 0)
pt2 '(0 0) pt3 '(0 0) pt4 '(0 0) x1 0 x2 0 x3 0)
;this zeroes the variables for the new rectangle
(setq deckcolor (strcase (getstring T "\nEnter the deck color code: ")))
;this sets the color code for the deck sequence color
(setq current_ltype (getvar "celtype"))
;this retrieves the current linetype and sets it to "current_ltype".
(command "setvar" "celtype" "bylayer")
;this sets the linetype to "bylayer" for this routine.
(setq current_lcolor (getvar "cecolor"))
;this retrieves the current line color and sets it to "current_lcolor".
(command "setvar" "cecolor" "bylayer")
;this sets the line color to "bylayer" for this routine.
(initget 7 "Y N")
(setq lapleft (getkword "\nIs deck lapped at the left end? <Y/N>: "))
;this prompts the user for the left end lap condition and sets it to "lapleft"
(initget 7 "Y N")
(setq lapright (getkword "\nIs deck lapped at the right end? <Y/N>: "))
;this prompts the user for the right end lap condition and sets it to "lapright"
(initget 7 "Y N")
(setq prt_text (getkword "\nPrint the deck length? <Y/N>: "))
;this prompts the user to decide on printing the deck length.
(initget 7 "Y N")
(setq vdecking (getkword "\nIs this 36 inch decking? <Y/N>: "))
;this asks the user if the deck width is 36inch standard
(setq deckwidth 36)
;this sets the width of the rectangle in inch units. (Also-start here for slope function)
(setq pt1 (getpoint "\nPick the deck starting point: "))
;this prompts the user for a starting point and sets it to "pt1"
(setq pt2 (getpoint "\nPick the deck ending point: "))
;this prompts the user for an ending point and sets it to "pt2"
(setq x1 (car pt1))
;this extracts the "x" coordinate from "pt1" and sets it to "x1"
;lapped condition-left
(setq x3 (- (car pt1) 2))
;this extracts the "x" coordinate from "pt1", subtracts 3 inches from it
;and sets it to "x3". Changed subtraction of 3 to 2.
(setq pt3 (cons x3 (cdr pt1)))
;this combines the new "x3" coordinate and the old "y" coordinate of "pt1"
;and sets "pt3", the point where the rectangle starts with panel lap on the
;left end
(setq y1 (cadr pt1))
;this extracts the "y" coordinate from pt1 and sets it to "y1"
(setq x2 (car pt2))
;this extracts the "x" coordinate from pt2 and sets it to "x2"
(setq decklength (- x2 x1))
;this finds the length between the two coordinates and sets it to "decklength"
(command "osmode" 0)
;turns running object snap modes off
;lapped condition-right
(setq pt4 (list (if (= lapright "Y") (+ (+ decklength x1) 2) (+ decklength x1)) (+ deckwidth y1)))
;this sets the proper corner for the right end lap condition. Changed add of 3 to add
;of 2.
(command "rectang" (if (= lapleft "N") pt1 pt3) pt4)
;this enters the rectangle command at the command line, starts the rectangle
;at the proper point per the "lapleft" condition then places the opposite corner
;using the variables "decklength", "deckwidth" and "lapright".
(command "osmode" 35)
;turns running object snap modes on
(setq l_text (rtos (- (cadr (nth 16 (entget (entlast)))) (cadr (assoc 10 (entget (entlast))))) 4 3))
;this finds the database information for the last (rectangle) drawn, retrieves the left and right
;points, calculates the length (in foot-inch format) and sets it to the variable "l_text"
(setq ang (eval (angle pt1 pt4)))
;this finds the angle between the first pick point and the opposite corner and sets it to "ang"
;(variable in degree units)
(setq t_distance (/ (distance pt1 pt4) 2))
;this finds the distance between the first pick point and the opposite corner, divides it by two,
;and sets it to "t_distance"
(if (= prt_text "Y")
(command "insert" "deck_length_text" (polar pt1 ang t_distance) "" "" "0" l_text)
;this inserts a visible attributed text for deck length
(command "insert" "deck_length_text_inv" (polar pt1 ang t_distance) "" "" "0" l_text)
;if "prt_text="N", then an invisible attributed text will be inserted at the same point
) ;closes the 'if' statement
;(if (= prt_text "Y")
;(setq key (append (list l_text) (list key)))
;this sets and updates the "key" deck lengths of variable "l_text". "key" is not zeroed
;when the Deck36 routine is re-run.
😉 ;closes the 'if' statement
(command "setvar" "celtype" current_ltype)
;this restores the previous linetype.
(command "setvar" "cecolor" current_lcolor)
;this restores the previous line color.
(princ)
Solved! Go to Solution.