After clicking OK, a new module i.e. code window opens.
Type this line at the very top (press Ctrl+Home) of the module:
This imports the InteropServices namespace into the project whose Marshal class has a method called GetActiveObject which allows the program to connect to a running instance of Solid Edge as seen in the Sub Main.
Inside the Module, declare variables for various Solid Edge objects as below:
Here, Model can be seen as the solid object that is created in the Part. The surface area is calculated for this model.
The oVariables collection stores all variables in the Part document which can be seen by right-clicking in the Part document anywhere in the graphics area and selecting Variables... from the context menu that appears.
This program adds a variable called AreaInDecimeter to this list of variables.
In the Sub Main, the GetActiveObject method of the Marshal class connects to a running instance of Solid Edge. Run this macro preferably from a button on the ribbon inside Solid Edge so there should be no problem accessing Solid Edge.
The currently open document is accessed into oDoc and no check is in place to ensure its Part document and not a Draft or assembly documents that is currently open.
Also all variables from the current document are stored into oVariables.
Next the ComputePhysicalProperties is called on the model and all required arguments are passed.
The most important being the Surface Area which is multiplied by 100 to get the area in decimeters.
Note: Solid Edge always stores the area internally in square meters irrespective of the document units. |
Hence it is safe to multiply the area calculated by 100 to get the area in decimeters.
This value is then added to the Variable Table:
Note that:
1. The value is added as a scalar.
2. The variable is Exposed.
In case the value of the Area in Decimeter is not displayed properly for e.g. it is seen as all zeroes, etc. you need to change the scalar precision under Advanced units to the highest possible.
The variable is exposed, so it can be used in a Draft callout as below:
Also, note in SE ST 6 and it perhaps may also exist in pre-ST 6, the Physical Properties when included from the Variable Table Filter, add a variable for surface Area which can also be used to calculate the decimeter area.
The downside of this approach would be the area calculated is in document units and extra API needs to be used to first determine the document unit and then convert it appropriately to decimeters. This necessitates maintaining a full table for every possible document unit to meters.
That's all for the coding part. For usage and download of the program and its source code, continue to Part 3...
Index of all Solid Edge Tips, Tutorials and Videos...
No comments:
Post a Comment