Jump to content

Recommended Posts

Posted (edited)
12 hours ago, Dien nguyen said:

I used this lisp to convert the color of the object to true color. Now I'm looking for a way to change the color of all layers from RGB to TrueColor. I consulted Lee-Mac's website but I still don't know how to use it. Please help.

image.thumb.png.52b605edce20d3f8fd8ca078472271a0.png

 

Try this:

(defun c:foo ( / accm c ly nm)
    (setq accm
        (vla-getinterfaceobject (vlax-get-acad-object)
            (strcat "AutoCAD.AcCmColor." (substr (getvar 'ACADVER) 1 2))
        )
    )
    (while
        (setq ly (tblnext "layer" (not ly)))
        (and
            (wcmatch (setq nm (cdr (assoc 2 ly))) "~*|*")
            (setq c (cdr (assoc 62 ly)))
            (progn
                (vla-put-ColorIndex accm c)
                (entmod
                    (append
                        (entget (tblobjname "layer" nm))
                        (list
                            (cons 420
                                (apply 'LM:RGB->True 
                                    (mapcar
                                        'vlax-get-property 
                                        (list accm accm accm)
                                        '(red green blue)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )
    (vlax-release-object accm)
    (princ)
)

;; RGB -> True - Lee Mac 2011
;; Args: r,g,b - Red,Green,Blue values

(defun LM:RGB->True (r g b) 
    (+ 
       (lsh (fix r) 16)
       (lsh (fix g) 8)
       (fix b)
    )
)

 

Edited by Jonathan Handojo
  • Like 1
Posted
10 hours ago, Jonathan Handojo said:

 

Try this:

(defun c:foo ( / accm c ly nm)
    (setq accm
        (vla-getinterfaceobject (vlax-get-acad-object)
            (strcat "AutoCAD.AcCmColor." (substr (getvar 'ACADVER) 1 2))
        )
    )
    (while
        (setq ly (tblnext "layer" (not ly)))
        (and
            (wcmatch (setq nm (cdr (assoc 2 ly))) "~*|*")
            (setq c (cdr (assoc 62 ly)))
            (progn
                (vla-put-ColorIndex accm c)
                (entmod
                    (append
                        (entget (tblobjname "layer" nm))
                        (list
                            (cons 420
                                (apply 'LM:RGB->True 
                                    (mapcar
                                        'vlax-get-property 
                                        (list accm accm accm)
                                        '(red green blue)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )
    (vlax-release-object accm)
    (princ)
)

;; RGB -> True - Lee Mac 2011
;; Args: r,g,b - Red,Green,Blue values

(defun LM:RGB->True (r g b) 
    (+ 
       (lsh (fix r) 16)
       (lsh (fix g) 8)
       (fix b)
    )
)

 

Thanks Jonathan, it works for me.

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