Get shape prop by name

Hello,

I’d like to get call the shape property by name

Similar to how you can get the value of a cell in a table by doing row[“collumnName”]
I am trying to do the same thing with shape props.
The only way I know of to call a specific property by ID. I’d like to call it by Label.

ex of Calling by ID.
string test = shape.Props.GetProp(12).Label.Value.ToString();
I want to do:
string test2 = shape.Props.GetPropByLabel(“ShapeDateTime”).ToString();
But no function GetPropByLabel or anything similar currently exists.

is there any way to do this?

Hi Charlas,


Thank you for contacting support. We have logged this feature request as DIAGRAMNET-50215 in our issue tracking system. We’ll let you know once an update is available.

Could you supply an example code of changing the text and date on one of the first fishbone in the attached document that reads"Submit Taskbooks to PARMS and Receive Project Funding (A-12) "



To explain what I am doing, we have a set of visio template documents, and we need to update the text, color, and date fields based on data in the database on each one of the fishbones. One of the props is called FishboneID that we use for uniqueness to tie the data and document together. The prop names are all the same on each document, but the ID’s appear to change from one document to another. There are too many documents to remake, so what is the best way to get the correct Props ID for the selected document and then set the props?

Hi Charles,

Thank you for your inquiry. We're working over your query and will get back to you soon.

Hi Charles,

Please refer to the following help topics:

We hope, this helps. Please feel free to reply us in case of any confusion or questions.

I have looked at those and am still unable to figure it out.

Could you please write out a few lines of code as an example to update the text mentioned above?

Hi, Charles


Thank you for the inquiry. We’ve noticed the problem of retrieving the text of the fishbone shapes. We’ve logged an investigation under ticket id DIAGRAMNET-50218 in our issue tracking system. We’ll let you know once any update is available in this regard. We’re sorry for the inconvenience you faced.

Hi, Charles


Thank you for being patient. We have a good news for you that the issue id DIAGRAMNET-50215 has now been resolved. If there is no issue in the QA phase, then its fix will be included in the next version of Aspose.Diagram for .NET 4.4.0. Its release date is not final yet. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMNET-50215) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Could you supply an example to show the correct syntax on how to do something like this:

string test2 = shape.Props.GetPropbyLabel(“ShapeDateTime”).ToString();

it appears the documentation was not updated.
Thanks

Hi Charles,


Thank you for your inquiry. There is an overloaded method GetProp. It takes name string as parameter. e.g. shape.Props.GetProp(name)

Please feel free to reply us in case of any confusion or questions.

[quote user=“imran.rafique”]Hi Charles,


Thank you for your inquiry. There is an overloaded method GetProp. It takes name string as parameter. e.g. shape.Props.GetProp(name)

Please feel free to reply us in case of any confusion or questions.

[/quote]
I am still having some trouble.

I currently have the working loop as follows:

foreach (Aspose.Diagram.Shape shape in diagram.Pages[0].Shapes){
foreach (Prop prop in shape.Props){
if (prop.Label.Value.ToString() == “Start”){
string start = prop.Value.Val.ToString();
}}}

I am trying to get rid of the second foreach and if loops so that my code looks like this.
foreach (Aspose.Diagram.Shape shape in diagram.Pages[0].Shapes){
string start = shape.Props.GetProp(“Start”).Value.Val.ToString();
}

This does not appear to work. How would I go about doing this correctly?

Hi Charles,

Thank you for your inquiry. We have updated our help topic there: Reading Visio Shape Data#ReadingVisioShapeData-ByName

It works perfect on our side. Please make sure that you are passing a correct property name and as a result property object is not null. In case, it does not help, then please share the source Visio drawing and sample code with us. We’ll check and guide you accordingly.

Hi Charles,


Thank you for being patient. From the specifics of ticket id DIAGRAMNET-50218, please use the following source code below:

[.NET]
Diagram diagram = new Diagram(@“C:\temp\Diagram.vdx”);
foreach (Aspose.Diagram.Shape shape in diagram.Pages[0].Shapes)
{
if (shape.Type == TypeValue.Group)
{
foreach (Shape s in shape.Shapes)
{
if (s.ID == 1260)
{
s.Text.Value.Clear();
s.Text.Value.Add(new Txt(“hello”));
Console.WriteLine(s.Text.Value.Text);
Console.WriteLine(s.ID);
}
}
}
}

We hope, this helps. Please feel free to reply us in case of any confusion or questions.

[quote user=“imran.rafique”]Hi Charles,


Thank you for being patient. From the specifics of ticket id DIAGRAMNET-50218, please use the following source code below:

[.NET]
Diagram diagram = new Diagram(@“C:\temp\Diagram.vdx”);
foreach (Aspose.Diagram.Shape shape in diagram.Pages[0].Shapes)
{
if (shape.Type == TypeValue.Group)
{
foreach (Shape s in shape.Shapes)
{
if (s.ID == 1260)
{
s.Text.Value.Clear();
s.Text.Value.Add(new Txt(“hello”));
Console.WriteLine(s.Text.Value.Text);
Console.WriteLine(s.ID);
}
}
}
}

We hope, this helps. Please feel free to reply us in case of any confusion or questions.

[/quote]

Thanks for the example, What does the line "if (shape.Type == TypeValue.Group)" accomplish? What does this filter out?

Hi Charles,


Thank you for the inquiry. We can group many shapes together so that they can be transformed as one unit and then set the attributes for the entire group. This filter is only to treat group shapes.

Please feel free to reply us in case of any confusion or questions.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.

Hello- I am trying to loop through all the shapedata found in a shape’s ShapeSheet on Visio. As i understand it, i should be able to see this data by calling shape.data and looping through that data. However I am only seeing SOME of the properties found there. Additionally, Prop.Name returns the LABEL. Prop.Pompt is not returning what I have in that cell. Help?

@susanktuvell

Thanks for contacting support.

Would you please share a sample Diagram file along with complete code snippet. We will test the scenario in our environment and address it accordingly.

Aspose_Test.zip (159.7 KB)

Here is the code:

While looking through all the shapes…

foreach (Prop prop in shape.Props)
{
file.Write(“Prop.” + prop.Name);
file.Write(prop.Label.Value);
file.Write(prop.Prompt.Value);
file.Write(prop.Type.Value.ToString());
file.Write(prop.Value.Val);
file.Write(prop.Format.Value);
}

I am writing to a file, but that should not matter. I am not seeing all of the props in the list of shape.Props. In the attached screen shot for example, I do not see Prop.ResType when looping through that shape. I also notice that when I AM on a prop, prop.Name is actually what is in the LABEL column. so I am having trouble getting what I want (such as the full name Prop.ResType for example).