+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default Changing color of circles in Blocks only

    Registered forum members do not see this ad.

    hello .

    I wonder why these codes are changing all circles in my dwg to color 1 and not only these in blocks , although that I included them within the Block definition only ?

    Code:
     (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object))))
          (vlax-for o blocks
            (if (wcmatch (vla-get-objectname o) "AcDbCircle")
                   (vla-put-color o 1))
             )
           )
      (vla-regen M:cad acActiveViewport)
    Thanks in Advance.

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,090

    Default

    Quote Originally Posted by Michaels View Post
    hello .

    I wonder why these codes are changing all circles in my dwg to color 1 and not only these in blocks , although that I included them within the Block definition only ?

    Code:
     (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object))))
          (vlax-for o blocks
            (if (wcmatch (vla-get-objectname o) "AcDbCircle")
                   (vla-put-color o 1))
             )
           )
      (vla-regen M:cad acActiveViewport)
    Thanks in Advance.
    This is included in the process:

    #<VLA-OBJECT IAcadPaperSpace2 20a13134> <----- all objects on paperspace
    #<VLA-OBJECT IAcadModelSpace2 20a16d34> <------all objects on modelspace


    Try something like this


    Code:
     
    (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object))))
    (if (not (wcmatch (vla-get-name blocks) "*Paper*,*Model*"))
    (vlax-for o blocks
    (if (wcmatch (vla-get-objectname o) "AcDbCircle")
    (vla-put-color o 1))
    )
    )
    )

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,709

    Default

    Another way to check would be:

    Code:
    (vlax-for block
        (vla-get-blocks
            (vla-get-activedocument
                (vlax-get-acad-object)
            )
        )
        (if
            (and
                (eq :vlax-false (vla-get-isLayout block))
                (eq :vlax-false (vla-get-isXref block))
            )
            (vlax-for obj block
                (if (eq "AcDbCircle" (vla-get-objectname obj))
                    (vla-put-color obj 1)
                )
            )
        )
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  4. #4
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default

    So nice , Thank you pBe and Lee .

    So I should have excluded the paper and Model spaces while trying to change the entities in block's definitions only. Right ?

    Appreciated.

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,709

    Default

    Quote Originally Posted by Michaels View Post
    So I should have excluded the paper and Model spaces while trying to change the entities in block's definitions only. Right ?
    Correct (I would also exclude Xrefs too).

    The ModelSpace/PaperSpace objects are also included in the Blocks collection, containing all the objects in Model space and Paper space respectively, hence by iterating through these block definitions you are iterating through all the objects in Model and Paper space.

    Lee
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,090

    Default

    Quote Originally Posted by Lee Mac View Post
    Correct (I would also exclude Xrefs too).

    The ModelSpace/PaperSpace objects are also included in the Blocks collection, containing all the objects in Model space and Paper space respectively, hence by iterating through these block definitions you are iterating through all the objects in Model and Paper space.

    Lee
    Thats right, learned that the hard way too

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,709

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by pBe View Post
    Thats right, learned that the hard way too
    At least you'll never forget it now
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Dynamic Blocks - Circles (Rebar)
    By Sparky in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 19th Apr 2010, 03:40 pm
  2. Changing Screen Color
    By Paul Sweet in forum AutoCAD General
    Replies: 7
    Last Post: 4th Jul 2008, 10:07 am
  3. changing dimension color
    By Brian in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 31st Oct 2007, 05:32 pm
  4. Changing the color of an object?
    By RMS in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 30th May 2007, 12:51 am
  5. changing color in color control (layer )
    By ionica in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 10th Oct 2005, 07:45 pm

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