ktbjx Posted October 2, 2018 Posted October 2, 2018 whats wrong with my code??? i know its lousy coding, but could someone help? (defun c:test(/ sel int ent str end reyjus hcol clr ss) (setq reyjus (getreal "\nEnter Radius: ")) (While T (if (setq ss (ssget "_:S" (list '(0 . "TEXT")))) (foreach e (mapcar 'cadr (ssnamex ss)) (setq hcol (atof (cdr (assoc 1 (entget e))))) (cond ((<= hcol 1.5)(setq clr 252)) ((<= hcol 2.5)(setq clr 5)) ((<= hcol 3.5)(setq clr 3)) ((<= hcol 5)(setq clr 30)) ((<= hcol 10)(setq clr 1)) ((> hcol 10)(setq clr 6))) (command "_Change" e "" "_p" "_Color" clr "") ) ) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE")))) (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (+(- (distance str end) (distance str end)) reyjus.)) ;(cons 62 . clr) ) ) ) ) ) (princ) ) my problem is this part: (cons 62 . clr) i put comment because it gives error.. what i wanted is to get the Index color from the text selected above (which is clr), and use that as the color of the circle. it doesnt work >.<" asdasdasd.LSP Quote
dlanorh Posted October 2, 2018 Posted October 2, 2018 Remove the "." It should be (cons 62 clr) Quote
Grrr Posted October 2, 2018 Posted October 2, 2018 When you supply two atoms as arguments to the cons function, it creates a dotted pair: (setq clr 256) >> 256 (cons 62 clr) >> (62 . 256) 1 Quote
ktbjx Posted October 2, 2018 Author Posted October 2, 2018 (edited) 8 minutes ago, dlanorh said: Remove the "." It should be (cons 62 clr) lol thank you for explaining grr! yey! now its working last question, is it possible to solid hatch the circle made as well? on that same (entmake)? Edited October 2, 2018 by ktbjx Quote
Lee Mac Posted October 2, 2018 Posted October 2, 2018 2 hours ago, ktbjx said: is it possible to solid hatch the circle made as well? on that same (entmake)? entmake'ing a hatch entity can be problematic and requires a lot of code; as such, I would suggest either using a call to the standard AutoCAD BHATCH command, or using the ActiveX addhatch method in conjunction with the appendouterloop method - here is an example of the latter. Quote
ktbjx Posted October 2, 2018 Author Posted October 2, 2018 (edited) i will try and read sir, thank you Edited October 2, 2018 by ktbjx Quote
ktbjx Posted October 3, 2018 Author Posted October 3, 2018 21 hours ago, Lee Mac said: entmake'ing a hatch entity can be problematic and requires a lot of code; as such, I would suggest either using a call to the standard AutoCAD BHATCH command, or using the ActiveX addhatch method in conjunction with the appendouterloop method - here is an example of the latter. you were right sir! entmaking hatch is so complex I can't even understand the codes! >.< ill stick to the COMMAND thingy Heres the Added hatch, from my previous code (defun c:Text2(/ sel int ent str end reyjus hcol clr ss sabilog) (setq reyjus (getreal "\nEnter Your Circle Radius: ")) (While T (if (setq ss (ssget "_:S" (list '(0 . "TEXT")))) (foreach e (mapcar 'cadr (ssnamex ss)) (setq hcol (atof (cdr (assoc 1 (entget e))))) (cond ((<= hcol 1.5)(setq clr 252)) ((<= hcol 2.5)(setq clr 5)) ((<= hcol 3.5)(setq clr 3)) ((<= hcol 5)(setq clr 30)) ((<= hcol 10)(setq clr 1)) ((> hcol 10)(setq clr 6))) (command "_Change" e "" "_p" "_Color" clr "") ) ) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE")))) (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (+(- (distance str end) (distance str end)) reyjus.)) (cons 62 250) ) ) (setq sabilog (entlast)) (command "_-bhatch" "Select" (entlast) "" "Properties" "_Solid" "_COLOR" clr "" "") (command ".DRAWORDER" sabilog "" "BACK") (command ".DRAWORDER" (entlast) "" "BACK") ) ) ) (princ) ) 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.