j_spawn_h Posted July 15, 2012 Posted July 15, 2012 I thought I could do this but some reason I am getting this error. "; error: bad argument type: stringp (3.0 "x" 11.25)" I am trying to label my polylines with their width, thickness, and adding the letter x in the middle. (defun c:pt (/ layerset hr raf1 raf2 ss en ed p10 p11 mpt d2d d1d d3d d4d lan tan fg hg) (defun errorhandler (s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) (princ "SW function cancelled!")) (setvar "clayer" layerset) (setvar "orthomode" orthoset) (setvar "osmode" osset) (setvar "cmddia" cmddiaset) (setvar "attdia" attdiaset) (setvar "regenmode" 1) (setq *error* olderr) (princ)) (setq layerset (getvar "clayer")) ;----------PICK WHICH LINES YOU WANT TO LABEL------------- (setq hr (getstring "\nFlush/Drop Beam or Header?(f/h): ")) (if (= hr "f") (progn (command "_.layer" "s" "s-frm-beam" "off" "*" "n" "on" "s-anno-text" "s" "s-anno-text" "" ""))) (if (= hr "h") (progn (command "_.layer" "s" "s-frm-header" "off" "*" "n" "on" "s-anno-text" "s" "s-anno-text" "" ""))) (command "textsize" "6" "") (command "_.style" "jaytxt" "romans" "0" "0.80" "" "" "" "") (and (setq ss (ssget '((0 . "*polyline")))) (while (setq en (ssname ss 0)) (setq ed (entget en)) (setq p10 (cdr (assoc 10 ed))) (setq p9 (reverse ed)) (setq p11 (cdr (assoc 10 p9))) (setq mpt (mapcar '(lambda (a b) (* (+ a b) 0.5)) p10 p11)) (setq ltype (cdr (cond ((assoc 6 ed))))) (setq depth (cdr (cond ((assoc 39 ed))))) (setq width (cdr (cond ((assoc 40 ed))))) ;(if (= width "1.75") (setq w1 1.75)) ;(if (= width "3") (setq w1 2)) ;(if (= depth "9.25") (setq d1 9.25)) ;(if (= depth "11.25") (setq d1 12)) (setq label (list width"x"depth)) (defun radians->degrees (r)(cvunit r "radian" "degree")) ;-------TEXT JUSTIFICATION---------------------------------------- (setq lan (angle p10 p11)) (setq ad (radians->degrees lan)) (if (and (> ad 90.1) (<= ad 270.1)) (progn (setq ptemp p10) (setq p10 p11) (setq p11 ptemp) (setq lan (angle p10 p11)) (setq ad (radians->degrees lan)))) (setq dir (if (< (* pi 0.5) lan (* pi 1.5)) - +)) (setq r3(entmake (list (cons 0 "TEXT") (cons 8 (getvar "CLAYER")) (cons 7 (getvar "TEXTSTYLE")) (cons 40 (getvar "TEXTSIZE")) (cons 41 0.80) (cons 72 4) (setq fg(cons 10 (setq r1(polar mpt (dir lan (+ 1)) (getvar "TEXTSIZE"))))) (setq hg(cons 11 (setq r2(polar mpt (dir lan (+ 1)) (getvar "TEXTSIZE"))))) (setq gg(cons 50 lan)) (setq rg(cons 1 (strcat label)))))) (ssdel en ss))) (command "_.layer" "on" "*" "" "") (setvar "clayer" layerset) (prin1)) Quote
BlackBox Posted July 15, 2012 Posted July 15, 2012 Consider the data TYPE of your width and depth variables, then look at the STRCAT parameter. Hint - Look into the RTOS function. Quote
Lee Mac Posted July 15, 2012 Posted July 15, 2012 The strcat function does not convert a list to a string, but concatenates two or more strings. You will need to convert the reals (numerical values) to strings using the rtos function, then concatenate the resultant strings using strcat before supplying the string to DXF Group Code 1. Also, the variables orthoset, osset, cmddiaset & attdiaset are not defined, and hence will cause your error handler to encounter an error when evaluating. Although, the error handler will never evaluate, as you have not redefined the *error* symbol. Also, why the use of cond statements here? (setq ltype (cdr (cond ((assoc 6 ed))))) (setq depth (cdr (cond ((assoc 39 ed))))) (setq width (cdr (cond ((assoc 40 ed))))) If the DXF group can be found, the value will be returned by the assoc function, else the assoc function will return nil. The use of cond is completely redundant. Quote
Recommended Posts
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.