Jump to content

Entmake Layers Works But I'm Having Trouble With Color Text vs Number


Recommended Posts

Posted

I'm using this small routine to add some new layers to a drawing:

defun fLayer (fName fColor Ltype fPlot)
 (entmake (list (cons 0 "LAYER")
                (cons 100 "AcDbSymbolTableRecord")
                (cons 100 "AcDbLayerTableRecord")
                (cons 2  fName)
                (cons 6 LType)
                (cons 62 fColor)
                (cons 70 0)                 
                (cons 290 fPlot)
        )
      )
 (princ)
 ); end Layer functions

And it works great if the value I send for the color is a number like 3, 2 or 1. But if I send it text like "White" or "Green" it will not work. I tried using the DXF code of 420 in lieu of 62 as well but still get the same results.

Posted

Okay I found the solution was to use another routine with 430 as the DXF code instead of 62. Was hoping to use only one routine for this.

 

Ooops, actually that didn't resolve it. The colors all default to "White" using 430 and send it something like "Magenta" or "Cyan".

Posted

You could just convert white to 7, etc.

 

Sent from my SM-G920T using Tapatalk

Posted
(defun _pick:colour  (clr / clrs pos)
 ;; Tharwat - 22.Jul.2016	;;
 (setq clrs '("red" "yellow" "green" "cyan" "blue" "magenta" "white"))
 (if (and (= (type clr) 'STR) (setq pos (member (strcase clr t) clrs)))
   (1+ (vl-position (car pos) clrs))
   (if (and (numberp clr) (< 0 clr 257))
     clr
     )
   )
 )

Posted

Or use a cond before entmake

 

(cond
((= (strcase fcolor) "RED") (setq fcolor 1))

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