Getting Shape Colors in Visio

R

Rich

I'm working in C#, framework v3.5. I've got a reference set to the Visio
11.0 Type Library. I need to be able to extract information about several
hundred shapes in a document. These shapes have about a dozen different
background fill colors.

From the SDK and some other blogs, etc. that been reading, it seems like the
following code should work...

Document doc1 = appVisio.ActiveDocument;
Page page = doc1.Pages[1];
foreach (Shape shape in page.Shapes)
{
Cell cell =
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillBkgnd);
Console.WriteLine("Shape - ID: {0}\tColor: {1}",
shape.ID, cell.get_ResultStr(VisUnitCodes.visUnitsColor));

//aoother option: should yield the same result...
cell = shape.get_CellsU("FillBkgnd");
Console.WriteLine("Shape - ID: {0}\tColor: {1}",
shape.ID, cell.get_ResultStr(VisUnitCodes.visUnitsColor));
}

Code compiles cleanly and runs successfully. But all color values are
displayed as: "RGB(255, 255, 255)", which seemingly means whites.

Anybody know what I need to do?
Thanks in advance.
 
P

Paul Herber

I'm working in C#, framework v3.5. I've got a reference set to the Visio
11.0 Type Library. I need to be able to extract information about several
hundred shapes in a document. These shapes have about a dozen different
background fill colors.

From the SDK and some other blogs, etc. that been reading, it seems like the
following code should work...

Document doc1 = appVisio.ActiveDocument;
Page page = doc1.Pages[1];
foreach (Shape shape in page.Shapes)
{
Cell cell =
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillBkgnd);

Are you sure it's not the FillForegnd that you need?
 
D

David Parker

Actually, if FillPattern = 1, then you need FillForegnd, else you need
FillBkgnd aswell
Also, if the shape is a group shape, then you may need to get the Fills from
one or more of the sub-shapes
Further more, if the shape belongs to a single layer, and that layer has a
color assigned, then you may need to get the layer color!

Paul Herber said:
I'm working in C#, framework v3.5. I've got a reference set to the Visio
11.0 Type Library. I need to be able to extract information about several
hundred shapes in a document. These shapes have about a dozen different
background fill colors.

From the SDK and some other blogs, etc. that been reading, it seems like
the
following code should work...

Document doc1 = appVisio.ActiveDocument;
Page page = doc1.Pages[1];
foreach (Shape shape in page.Shapes)
{
Cell cell =
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillBkgnd);

Are you sure it's not the FillForegnd that you need?
 
S

sbmack7

Actually, if FillPattern = 1, then you need FillForegnd, else you need
FillBkgnd aswell
Also, if the shape is a group shape, then you may need to get the Fills from
one or more of the sub-shapes
Further more, if the shape belongs to a single layer, and that layer has a
color assigned, then you may need to get the layer color!




I'm working in C#, framework v3.5.  I've got a reference set to the Visio
11.0 Type Library.  I need to be able to extract information about several
hundred shapes in a document.  These shapes have about a dozen different
background fill colors.
From the SDK and some other blogs, etc. that been reading, it seems like
the
following code should work...
Document doc1 = appVisio.ActiveDocument;
Page page = doc1.Pages[1];
foreach (Shape shape in page.Shapes)
{
      Cell cell =
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
             (short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillBkgnd);
Are you sure it's not the FillForegnd that you need?

Here's what you should do. You drop 29 bucks and buy Paul Herber's
very clever Visio SuperUtilities add-in. (Or even download it for the
free trial.) Then you run the Shapes on Page report to extract out
all of the individual Shape info on the Page. Then you save that to a
text file. Then you parse out the Shape info that you need from the
text file. Then you are done.

BTW, it could be that the 12 or so categories of Shapes of interest
have Shape Names with prefixes that map back their Masters. So check
the Document Stencil to see what those are. Knowing that would make
it easier to ignore the other Shape junk on the page.

SteveM
 
R

Rich

Paul...

Yup, it looks like FillForegnd is the deal. Thanks!

--
Richard Laird, MCSD.NET


Paul Herber said:
I'm working in C#, framework v3.5. I've got a reference set to the Visio
11.0 Type Library. I need to be able to extract information about several
hundred shapes in a document. These shapes have about a dozen different
background fill colors.

From the SDK and some other blogs, etc. that been reading, it seems like the
following code should work...

Document doc1 = appVisio.ActiveDocument;
Page page = doc1.Pages[1];
foreach (Shape shape in page.Shapes)
{
Cell cell =
shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowFill,
(short)VisCellIndices.visFillBkgnd);

Are you sure it's not the FillForegnd that you need?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top