C # Simple Method for retrieving the Visio Model Information,
A recent project requires the export of Visio drawings. Because it is a construction project, you need to set parameters for wall, door, room, and other information.
Take the wall as an example. Right-click the wall model and the following dialog box is displayed.
You need to set the wall length, wall thickness, and other column information.
Currently, C # has few examples in operating Visio, so it took a long time to see no useful posts. Until this afternoon, I found a post in Bing, which suddenly benefited me a lot. Original post address: http://mikeborozdin.com/post/reading-and-writing-visio-shape-information-with-c/
The procedure is as follows:
1. Open the developer mode of Visio
File -- option -- Advanced -- run in developer Mode
Ii. View model attributes
Select model -- Right-click to display ShapeSheet. All attributes of the model will appear under Visio.
Decline. You can see the attribute information of this model in Shape Data.
C # code operations
1. Open the wall model template
WALL_M.VSS is a wall model template. We recommend that you search for the template path by everything.
2. Create a model and set parameters
You can easily create a model by adding the model name with the document. Masters attribute. Where is the model name? In fact, it is very easy to find, that is, the model name of Visio. You can use Chinese characters.
You can set the parameters of a model in either of the following ways.
Most of the materials on the Internet use the first method. This method is not easy to remember, but the second method is very convenient, that is, the simple method described in this article.
Model name. Cells ["attribute name"]. Formula
Attribute names are the attributes seen in ShapeSheet. They are of the String type and can be directly set. After the setting is successful, the following figure is displayed.
3. Problems Encountered
Not all attributes are easy to use. I don't know where the current attribute is. One of them is the filling attribute.
FillForegnd is the filling property and the code is set
m_sp4.Cells["FillForegnd"].Formula = "RGB(0,0,0)";
You can view the parameters and the settings are successful.
And right-click the model and choose format-fill, as shown in figure
In fact, the settings have been successfully set, but the color of the model remains unchanged. This is embarrassing. However, if you use the basic model, which is the basic model of square or circle, you can see that the filling is black, so I don't know where the problem is.
DEMO