Change color in a block

Discussion in 'AutoCAD' started by benji48, Jan 24, 2005.

  1. benji48

    benji48 Guest

    Help!! I have hundreds of electrical symbols that have certain
    entities (but not all) on color 2. I'm searching for a routine that will change all entities with color 2 in a block to another color once block is inserted in drawing. The reason is I am trying to use the same symbol for different clients, but one client uses color 2 while another client might use color 4. I don't wont to double up on symbols and manually change them for different clients. Any suggestions would be greatly appreciated
     
    benji48, Jan 24, 2005
    #1
  2. benji48

    Rob Taylor Guest

    benji48,

    The code below can be used just after inserting a block into a drawing.

    like this
    (command "_.insert" blkname pt x_scale y_scale z_scale rotation)
    (ChangeBlkCol 2 7) ;BlkColOld BlkColNew
    ; this will change all entity within the block that are colour 2 to colour 7.
    Entities that are bylayer are not effected. if you use 0 the entity will be
    change to bylayer.

    Hope this helps ;)



    <code>
    (defun ChangeBlkCol (BlkColOld BlkColNew / ent elist obj entType BlkName)
    (setq elist nil ent nil)
    (setq obj (entget (entlast))
    (setq entType (cdr (assoc 0 obj)))
    (if (= entType "INSERT")
    (progn
    (setq BlkName (cdr (assoc 2 obj)))
    (setq ent (tblobjname "BLOCK" BlkName))
    (while ent
    (setq elist (entget ent '("*")))
    (if (= (cdr (assoc 62 elist)) BlkColOld)
    (progn
    (setq obj (subst (cons 62 BlkColNew) (assoc 62 elist) elist))
    (entmod obj)
    )
    )
    (setq ent (entnext ent))
    );while
    )
    )
    );defun
    <code>
     
    Rob Taylor, Jan 24, 2005
    #2
  3. benji48

    GaryDF Guest

    error: malformed list on input

    Gary
     
    GaryDF, Jan 24, 2005
    #3
  4. IMO, this is what layers are for.

    One way to make this simple:

    Keep the components that make up the symbol
    on layer zero, then place them on a layer which
    you can easily change the color of depending on
    the client.
     
    Jason Piercey, Jan 24, 2005
    #4
  5. benji48

    Rob Taylor Guest

    (setq obj (entget (entlast))

    should be
    (setq obj (entget (entlast)))
     
    Rob Taylor, Jan 24, 2005
    #5
  6. benji48

    Rob Taylor Guest

    he wants multiple colours in one block on one layer

    sometimes not everything can be bylayer :)
     
    Rob Taylor, Jan 24, 2005
    #6
  7. Sure it can, make more layers :)
     
    Jason Piercey, Jan 24, 2005
    #7
  8. benji48

    OLD-CADaver Guest

    Which is the "right" solution. Colors and linetypes other than BYLAYER kill the part's use in XREF's.
     
    OLD-CADaver, Jan 24, 2005
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.