private void btAddSolution_Click(object sender, EventArgs e) { try { // get selected box BoxProperties boxProperties = SelectedBox; // get selected pallet PalletProperties palletProperties = SelectedPallet; // get selected caseOptimSolution CaseOptimSolution sol = SelectedSolution; CaseOptimArrangement arrangement = sol.CaseDefinition.Arrangement; // build new case name string name = string.Format("{0}_{1}*{2}*{3}_{4}{5}" , boxProperties.Name , arrangement._iLength , arrangement._iWidth , arrangement._iHeight , sol.CaseDefinition.Dim0 , sol.CaseDefinition.Dim1); // build new case description string description = string.Format("Case generated by case optimization for box {0} and pallet {1}" , boxProperties.Name , palletProperties.Name); // add new case CaseOfBoxesProperties caseProperties = _document.CreateNewCaseOfBoxes( name, description , boxProperties , sol.CaseDefinition , BuildCaseOptimConstraintSet()); // set color caseProperties.SetColor(Color.Chocolate); // add new pallet analysis string analysisName = string.Format("OptimAnalysis{0}_{1}*{2}*{3}_{4}{5}" , boxProperties.Name , boxProperties.Name , arrangement._iLength , arrangement._iWidth , arrangement._iHeight , sol.CaseDefinition.Dim0 , sol.CaseDefinition.Dim1); string analysisDescription = string.Format("Pallet analysis generated by case optimisation for box {0} and pallet {1}" , boxProperties.Name , palletProperties.Name); List <CasePalletSolution> palletSolutionList = new List <CasePalletSolution>(); palletSolutionList.Add(sol.PalletSolution); CasePalletAnalysis analysis = _document.CreateNewCasePalletAnalysis( analysisName , analysisDescription , caseProperties , palletProperties , null, null , null, null, null , BuildPalletConstraintSet() , palletSolutionList); } catch (Exception ex) { _log.Error(ex.ToString()); } }
private bool GenerateProject(out Document doc, out CasePalletAnalysis analysis, out CasePalletSolution casePalletSolution) { doc = null; analysis = null; casePalletSolution = null; try { // build solution doc = new Document( _boxName, string.Format(Properties.Resources.ID_OPTDOCUMENTDESCRIPTION, _boxName), string.Empty, DateTime.Now, null); // box BoxProperties boxProperties = doc.CreateNewBox(SelectedBox); // pallet PalletProperties palletProperties = doc.CreateNewPallet(SelectedPallet); // get selected caseOptimSolution CaseOptimSolution sol = SelectedSolution; PackArrangement arrangement = sol.CaseDefinition.Arrangement; // build new case name string arrangName = string.Format("{0}_{1}x{2}x{3}_{4}{5}" , boxProperties.Name , arrangement._iLength , arrangement._iWidth , arrangement._iHeight , sol.CaseDefinition.Dim0 , sol.CaseDefinition.Dim1); // build new case description string description = string.Format( Properties.Resources.ID_OPTCASEDESCRIPTION , boxProperties.Name , palletProperties.Name); // add new case CaseOfBoxesProperties caseProperties = doc.CreateNewCaseOfBoxes( arrangName, description , boxProperties , sol.CaseDefinition , BuildCaseOptimConstraintSet()); // set color caseProperties.SetColor(Color.Chocolate); // add new pallet analysis string analysisName = string.Format( Properties.Resources.ID_OPTANALYSISNAME , boxProperties.Name , boxProperties.Name , arrangement._iLength , arrangement._iWidth , arrangement._iHeight , sol.CaseDefinition.Dim0 , sol.CaseDefinition.Dim1); string analysisDescription = string.Format( Properties.Resources.ID_OPTANALYSISDESCRIPTION , boxProperties.Name , palletProperties.Name); List <CasePalletSolution> palletSolutionList = new List <CasePalletSolution>(); palletSolutionList.Add(sol.PalletSolution); analysis = doc.CreateNewCasePalletAnalysis( analysisName , analysisDescription , caseProperties , palletProperties , null , null , null , null , null , BuildPalletConstraintSet() , palletSolutionList); } catch (Exception ex) { _log.Error(ex.ToString()); return(false); } return(true); }