Jump to content

Changing color of circles in Blocks only


Recommended Posts

Posted

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 ?

 

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

Posted
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 ?

 

(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:

 

#

#

 

 

Try something like this

 

 

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

:)

Posted

Another way to check would be:

 

(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)
           )
       )
   )
)

Posted

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.

Posted
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

Posted
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 :)

Posted
Thats right, learned that the hard way too :)

 

At least you'll never forget it now :wink:

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