En este video se explica el procedimiento para obtener el tiempo total de maquinado en Delmia CAM.
Se adjunta la macro que hay que agregar en Microsoft VSTA.
public static void Macro_GetTime()
{
// Get Activity Container from editor of the session
INFITF.Editor editor = CATIA.ActiveEditor;
if (editor == null) { MessageBox.Show("Editor null"); return; }
string manufacturingFactoriesType = "CATMfgManufacturingFactories";
ManufacturingFactories factories = editor.GetItem(ref manufacturingFactoriesType) as ManufacturingFactories;
if (factories == null) { MessageBox.Show("ManufacturingFactories null"); return; }
ManufacturingContainer activityContainer = factories.GetManufacturingActivityFactory();
if (activityContainer == null) { MessageBox.Show("ManufacturingContainer null"); return; }
// init
double vTime = 0; // Computed Time for each activity
// Loop on Part Operations
foreach (ManufacturingPartOperation partOperation in activityContainer.GetPartOperations())
{
// Loop on manufacturing program
foreach (ManufacturingProgram mfgProgram in partOperation.GetPrograms())
{
// Loop on manufacturing activity
foreach (ManufacturingActivity mfgActivity in mfgProgram.GetOperations())
{
// if necessary to filter by type of activity
//PROCESSITF.Activity baseActivity = (PROCESSITF.Activity)mfgActivity;
//if (baseActivity != null && "ToolChange" == baseActivity.Type)
// Get Machining Time of the activity
ManufacturingActivityParameters mfgActivityParam = (ManufacturingActivityParameters)mfgActivity;
if (mfgActivityParam != null)
{
Parameter param = mfgActivityParam.FindElement("CCT");
String strValue = "";
if (param != null) strValue = param.ValueAsString();
int strLgth = strValue.Length;
if (strLgth > 0)
{
strValue = strValue.Remove(strLgth - 1); // Remove the unit, here the s of second
vTime += double.Parse(strValue);
}
}
}
}
}
// Display Time
double tTime = vTime / 60.0;
int mTime = (int) tTime;
tTime = vTime - (mTime * 60.0);
int sTime = (int) tTime;
MessageBox.Show("Total time : " + mTime.ToString() + " min " + sTime.ToString() + " s ");
} // --------------------------------------------