+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Forum Newbie
    Discipline
    Architectural
    Using
    AutoCAD 2016
    Join Date
    Sep 2017
    Posts
    9

    Default Change color (RGB) of objects in a selection set

    Registered forum members do not see this ad.

    Hello together,

    I thought I have a simple task to perform, but unfortunately it turned out to be more difficult than I expected:

    I have in my lisp a code to select all elements in a drawing using (setq tbe (ssget "_X")), what I want to do now is to change the color of the selectionset to have a certain color. This color is defined by the RGB code 102,204,255.

    Unfortunately I was not able to find the important hint to solve it by my own

    Thank you for your help,
    Ament

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    802

    Default

    Try this:
    Code:
    (defun c:foo (/ s)
      (if (setq s (ssget ":L"))
        (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
          (entmod (append (entget e) '((420 . 6737151))))
        )
      )
      (princ)
    )

  3. #3
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    622

    Default

    recent thread ?
    by grrr & M.R
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  4. #4
    Forum Newbie
    Discipline
    Architectural
    Using
    AutoCAD 2016
    Join Date
    Sep 2017
    Posts
    9

    Default

    Hi nahhphuc, unfortunately I'm a beginner in LISP and not able to identify the relevant code in the threat you mentioned Could you give me the hint?

  5. #5
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    622

    Default

    http://www.lee-mac.com/runlisp.html

    you can try copy the entire code by Ronjonp @ post#2 (shorter)
    paste to command line

    to invoke type,
    command : foo

    or
    (c:foo)
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,421

    Default

    Back then, when I was learning about grread: Grread + RGB (featuring the help of two giants).

  7. #7
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,400

    Default

    Registered forum members do not see this ad.

    To convert the rgb use lee-mac function

    Code:
    ;; RGB -> True  -  Lee Mac
    ;; Args: r,g,b - [int] Red, Green, Blue values
    (defun LM:RGB->True ( r g b )
        (logior (lsh (fix r) 16) (lsh (fix g) 8) (fix b))
    )
     
    ;(setq rgb (LM:RGB->True R G B))
    (setq rgb (LM:RGB->True 102 204 255))
    ;6737151
    A man who never made mistakes never made anything

Similar Threads

  1. Multiple selection to change color
    By Romero in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 21st Nov 2016, 10:36 am
  2. Replies: 15
    Last Post: 16th Jul 2013, 05:20 pm
  3. Lisp to change all objects with a certain color to another color
    By mikeSIEMENS in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 15th Jan 2010, 04:59 pm
  4. How To Change and Objects Color With Vla????
    By BLOACH85 in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 3rd Mar 2009, 06:01 pm
  5. can't change color of objects
    By moose321 in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 24th Oct 2007, 04:31 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts