Hi,
i have an existing VSDX document. In Visio in the shapesheet data i can see six User-defined Cells of a shape. The values of four of these User-defined Cells are displayed in black font and the other two in blue font.
I can read the two user properties (with blue font) with:
The other four with: foreach (Aspose.Diagram.User userPop in ShapeObject.InheritUsers) ....
Now i want to change the value of some user properties.
For the real user properties it works by doing the following: ShapeObject.Users.Cast<Aspose.Diagram.User>().Where(user => user.Name == "PropName").FirstOrDefault().Value.Val = "NewValue";
But if i want to change a value of a inheritusers properties like this: ShapeObject.InheritUsers.Cast<Aspose.Diagram.User>().Where(user => user.Name == "PropName").FirstOrDefault().Value.Val = "NewValue";
It doesn’t work. No error is displayed but the value of the property has not been changed.
To change the value of inherited user properties in a VSDX document using Aspose.Diagram, you need to understand that inherited properties are not directly modifiable in the same way as user-defined properties. Instead, you typically need to modify the source shape or the master shape from which the inherited properties are derived.
Here’s a general approach to achieve this:
Identify the Source Shape: Determine which shape the inherited properties are coming from. This is usually a master shape or a shape that has the properties defined.
Modify the Source Shape: Once you have identified the source shape, you can modify the user properties of that shape. This will automatically update the inherited properties in all shapes that reference it.
Here’s an example of how you might implement this:
// Load the VSDX diagram
Diagram diagram = new Diagram("path_to_your_document.vsdx");
// Get the page by name
Page page = diagram.Pages.GetPage("Page-3");
// Iterate through shapes on the page
foreach (Aspose.Diagram.Shape shape in page.Shapes)
{
// Check if the shape has inherited properties
if (shape.InheritUsers.Count > 0)
{
// Find the source shape (this may require additional logic based on your diagram structure)
Aspose.Diagram.Shape sourceShape = /* logic to get the source shape */;
// Modify the user property in the source shape
var userProp = sourceShape.Users.Cast<Aspose.Diagram.User>()
.FirstOrDefault(user => user.Name == "PropName");
if (userProp != null)
{
userProp.Value.Val = "NewValue"; // Update the value
}
}
}
// Save the modified diagram
diagram.Save("path_to_save_modified_document.vsdx", SaveFileFormat.VSDX);
In this example, you need to replace the logic to get the sourceShape with the appropriate method to identify the shape that contains the original user-defined properties. Once you modify the properties of the source shape, the changes will reflect in all shapes that inherit those properties.
If you need further assistance or specific examples, feel free to ask!
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.