Jump to content

Entmake Circle Color


ktbjx

Recommended Posts

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

Link to comment
Share on other sites

 

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 by ktbjx
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...