In the case of a picture switch, the others are about the same.
Use Twaver to make switch Model 1, where each port is a separate object. Specific twaver operating procedures see URL: Http://twaver.servasoft.com/doc in the Operation Guide.
Export the good model to a JSON-formatted file. The following is an example of a simple parse of a JSON file using the switch shown in Figure one. Two shows a simple structure of the exported JSON file for the diagram switch.
First, the exported JSON file is a JSON object containing two arrays of primitives (primitive) and assembles (assembly), and Primitives (original) contains 16 objects. Note that 0~16 these numbers simply indicate the order in which the drawing was dragged, not its OID. The OID of each object is contained within each object. For example 0 is only represented by the entire large called Switch body, and from 1~16 represents each Port object.
Continue to expand the object named "0", as shown in 3. The fields in the object are specified in table I.
Table I:
Object |
Field |
Describe |
|
Id (str) |
Represents the ID of the object, generated randomly by the Twaver tool itself, is unique |
Scale (obj) |
X, Y, Z (str) |
Represents the scale of the object, which is 1 by default |
POS (obj) |
X, Y, Z (str) |
Represents the center coordinate position of the object, which is 0 by default |
Rot (obj) |
X, Y, Z (str) |
The angle that represents the rotation of the object |
Size (obj) |
X, Y, Z (str) |
Represents size |
|
ClassName (str) |
Represents the object name of the object, not unique |
Ambient (arr) |
(str) |
Six polygons represent six parameters representing the lighting environment for each polygon |
Color (arr) |
(str) |
Represents the color of each polygon |
DT (ARR) |
(str) |
Represents the map path for each polygon |
Transparent (arr) |
(Boolean) |
Indicates whether each polygon is transparent and defaults to False |
Types (arr) |
(str) |
Default is Phong |
Visible (ARR) |
(Boolean) |
Indicates whether the visual, by default, is true. Contrary to transparent. |
Opacity (arr) |
(Num) |
Sets the transparency level for an element. The default is 1. |
FlipX (arr) |
(Boolean) |
Indicates the x-axis direction reversal, which defaults to false. |
FlipY (arr) |
(Boolean) |
Represents the y-axis direction reversal, which defaults to false. |
Specularstrength (arr) |
(str) |
Represents the specular strength. The default is 1 |
Polygonoffset (arr) |
(Boolean) |
Whether to set the polygon offset parameter, false by default |
Polygonoffsetfactor (arr) |
(str) |
Represents the polygon offset factor. You need to set Polygonoffset to true. |
Polygonoffsetunits (arr) |
(str) |
Represents the Polygon offset unit. You need to set Polygonoffset to true. |
|
Scalevalue (str) |
Scale value |
|
OID (str) |
Custom object ID for easy programmatic use |
The other object properties are basically similar to table one, with no significant changes.
The following describes the objects in the assembles (assembly) array. The array refers to the grouping of objects in the previous array. As shown in 4.
The array contains an object "0", the switch body mentioned above, which can be uniquely identified by comparing the first field (ID) of the object to the ID in the previous array. "Children" represents other objects that are assembled on the object, as shown in 5. 0~16 these objects are "0" children, the property "Ishost" of the figure "0" object =true that it is the host, and all other objects are assembled on top of the object; Pos represents the location of the object. For non-host class objects, such as Object "1", its properties include ' id ', ' oid ' and ' pos ' fields. The other objects are the same. Continue the description of the field "Assemblesize" object in Figure 4 represents the group
Twaver Mono-desiner exported JSON file parsing