XCabCalculateEnclosureTotalWeightAction
Calculates the total weight of a cabinet and writes it to the "Total weight" property (#36108 - FUNCTION3D_CABINET_TOTALWEIGHT)
"All cabinets" mode:
XCabCalculateEnclosureTotalWeightAction /DatabaseId:28
XCabCalculateEnclosureTotalWeightAction /ProjectName:C:\Projects\EPLAN\EPLAN_Sample_Project.elk
"One cabinet" mode: A Cabinet object selected in GUI is passed by the context.
// Create special calling context
StorableObjectContext context = new StorableObjectContext();
// Get selected cabinet from GUI
SelectionSet selectionSet = new SelectionSet();
StorableObject[] storableObjects = selectionSet.Selection;
if (storableObjects.Length > 0)
{
Cabinet selectedCabinet = (Cabinet)Array.Find(storableObjects, storableObject = > storableObject.TypeIdentifier == 179); // 179: TYPEID_DMCABINET
// Set selected cabinet to context
context.StorableObject = selectedCabinet;
// Execute Action
if (new CommandLineInterpreter().Execute("XCabCalculateEnclosureTotalWeightAction", context))
{
// Get cabinet weight from context
string weight = "";
context.GetParameter("CabinetTotalWeight", ref weight);
System.Windows.Forms.MessageBox.Show("Total weight of cabinet '" + selectedCabinet.Name + "': " + weight);
}
}