Fill Colors

Valued Contributor
Valued Contributor

 

I am sure this is easy but I am trying to change the color of a fill (both Pattern Color and Solid Color) but I cannot get the Solid Color to change.

Has anyone any idea how to do this in code?

For Each objfill In objsheet.DrawingObjects

            'Get the Linear color

            ccolor = objfill.FillBackground

            'Sets the color

            If ccolor = seColorGreen Then

               objfill.FillBackground = seColorBlack

            End If

        Next

Many Thanks

 

Posted by: Allan Anderton
Post date: 3/29/2010 1:09:00 AM

3 REPLIES

RE: Fill Colors

Valued Contributor
Valued Contributor

Some notes here:

Not all the object have the "FillBackground" property. It is something that is only present in FillStyle object.

Your previous loop would only lead in errors.

Objects in your drawing that can be "filled" are only two (someone else can correct me if i'm wrong)

- Boundary2d: This is the typical "fill" effect in a closed shape (crosshatching or filled) It is an entity itself.

-Textboxes.

 

I guess that you are interested in the first group.

To search your sheet for boundaries you shouldn't go through "DrawingObjects" collection, but "Boundaries2D" collection. This is much faster.

Also you have to get the Style property which returns a BoundaryStyle2D object

Example:

For each b2d in objSheet.Boundaries2d

'Get linear color

ccolor=b2d.Style.LinearColor

'Get fill color

fcolor=b2d.Style.FillColor

'Set color would be the same thing.

b2d.Style.LinearColor=ccolor

b2d.Style.FillColor=fcolor

'Also if you defined a fill style should set fill and linear color in one shot.

b2d.Style.FillName="MyGreenStyle"

next

 

Posted by: Julian Guillo
Post date: 3/29/2010 2:44:58 AM

RE: Fill Colors

Valued Contributor
Valued Contributor

 

This did not work but I do have a style that if i can change should change the colors.

Does anyone have the VB code to do this for a fill style?

Thanks

 

Posted by: Allan Anderton
Post date: 3/29/2010 3:44:13 AM

RE: Fill Colors

Valued Contributor
Valued Contributor

 

I finally got the fill color to work as well now as i want.

Thanks

 

Posted by: Allan Anderton
Post date: 3/29/2010 5:58:16 AM