private void CreateConnection_Click(object sender, RoutedEventArgs e) { DtoDivision model = GetConnectionsModel(); if (model == null) { return; } bool hasValues = GetElementAssemblies(false); if (!hasValues) { MessageBoxHelper.ShowInformation("Please create the objects first.", _parentWindow); return; } string propertyName = "ConnectionChild-Element"; ProgressWindow.Text = "Create connections."; ProgressWindow.Show(); bool hideProgressWindow = true; try { DtoCsgTree csgTree = new DtoCsgTree { Color = (uint)Color.LightSteelBlue.ToArgb() }; csgTree.Elements.Add(new Path { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, 300, 6.5 } }, new Line { Point = new List <double> { 0, 300, 15.5 } }, } }); csgTree.Elements.Add(new OuterContour { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, -40 } }, new Line { Point = new List <double> { 290, -40 } }, new Line { Point = new List <double> { 290, -550 } }, new Line { Point = new List <double> { 0, -550 } }, new Line { Point = new List <double> { 0.0, -40 } }, } }); SteelPlate Slab = new SteelPlate { Name = "Slab", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = csgTree }; Slab.AddProperty(TableNames.tabAttribConstObjInstObj, propertyName, _bar0); DtoCsgTree rectangle = new DtoCsgTree { Color = (uint)Color.IndianRed.ToArgb() }; rectangle.Elements.Add(new Path { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 40, 300.0, 15.5 } }, new Line { Point = new List <double> { 550, 300.0, 15.5 } } } }); rectangle.Elements.Add(new OuterContour { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 20, 0.0 } }, new Line { Point = new List <double> { 0.0, 0.0 } }, new Line { Point = new List <double> { 0, 10 } }, new Line { Point = new List <double> { 20, 0.0 } } } }); Weld Weld_1 = new Weld { Name = "Weld_1", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = rectangle }; Weld_1.AddProperty(TableNames.tabAttribConstObjInstObj, propertyName, _bar0); Weld Weld_2 = new Weld { Name = "Weld_2", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = rectangle }; TmpMatrix matrix = new TmpMatrix { Values = new[] { 1, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, -1, 9, //-10 0.0, 0.0, 0.0, 1 } }; Weld_2.AddProperty(TableNames.tabAttribConstObjInstObj, propertyName, _bar0); Weld_2.AddProperty("element", "matrix", matrix); DtoCsgTree cabin = new DtoCsgTree { Color = (uint)Color.DarkBlue.ToArgb() }; cabin.Elements.Add(new Path { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, 300, 30 } }, new Line { Point = new List <double> { 0, 300, 40 } }, } }); cabin.Elements.Add(new OuterContour { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0.0, -10.0 } }, new Line { Point = new List <double> { 8.666, -5 } }, new Line { Point = new List <double> { 8.666, 5 } }, new Line { Point = new List <double> { 0.0, 10 } }, new Line { Point = new List <double> { -8.666, 5 } }, new Line { Point = new List <double> { -8.666, -5 } }, new Line { Point = new List <double> { 0.0, -10 } } } }); DtoCsgTree CircularTree = new DtoCsgTree { Color = (uint)Color.Gray.ToArgb() }; CircularTree.Elements.Add(new Path { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, 300, -20 } }, new Line { Point = new List <double> { 0, 300, 30 } } }, CrossSection = "RD8" }); ChildGeometryObject Cabin1 = new ChildGeometryObject { Name = "Cabin1", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = cabin }; TmpMatrix matrix1 = new TmpMatrix { Values = new[] { 1, 0.0, 0.0, 100.0, 0.0, 1, 0.0, 200.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 1 } }; Cabin1.AddProperty("element", "matrix", matrix1); ChildGeometryObject Circular1 = new ChildGeometryObject { Name = "Circular1", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = CircularTree }; Circular1.AddProperty("element", "matrix", matrix1); MechanicalFastener Screw_1 = new MechanicalFastener { Name = "Screw_1", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, }; Screw_1.Children = new List <DtObject> { Cabin1, Circular1 }; ChildGeometryObject Cabin2 = new ChildGeometryObject { Name = "Cabin2", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = cabin }; TmpMatrix matrix2 = new TmpMatrix { Values = new[] { 1, 0.0, 0.0, 500, 0.0, 1, 0.0, 100.0, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 1 } }; Cabin2.AddProperty("element", "matrix", matrix2); ChildGeometryObject Circular2 = new ChildGeometryObject { Name = "Circular2", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = CircularTree }; Circular2.AddProperty("element", "matrix", matrix2); MechanicalFastener Screw_2 = new MechanicalFastener { Name = "Screw_2", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, }; Screw_2.Children = new List <DtObject> { Cabin2, Circular2 }; ChildGeometryObject Cabin3 = new ChildGeometryObject { Name = "Cabin3", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = cabin }; TmpMatrix matrix3 = new TmpMatrix { Values = new[] { 1, 0.0, 0.0, 100, 0.0, 1, 0.0, 100, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 1 } }; Cabin3.AddProperty("element", "matrix", matrix3); ChildGeometryObject Circular_3 = new ChildGeometryObject { Name = "Circular_3", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = CircularTree }; Circular_3.AddProperty("element", "matrix", matrix3); MechanicalFastener Screw_3 = new MechanicalFastener { Name = "Screw_3", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, }; Screw_3.Children = new List <DtObject> { Cabin3, Circular_3 }; ChildGeometryObject Cabin4 = new ChildGeometryObject { Name = "Cabin4", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = cabin }; TmpMatrix matrix4 = new TmpMatrix { Values = new[] { 1, 0.0, 0.0, 500, 0.0, 1, 0.0, 200, 0.0, 0.0, 1, 0.0, 0.0, 0.0, 0.0, 1 } }; Cabin4.AddProperty("element", "matrix", matrix4); ChildGeometryObject Circular_4 = new ChildGeometryObject { Name = "Circular_4", Parent = model.TopologyDivisionId, Division = model.Id, CsgTree = CircularTree }; Circular_4.AddProperty("element", "matrix", matrix4); MechanicalFastener Screw_4 = new MechanicalFastener { Name = "Screw_4", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, }; Screw_4.Children = new List <DtObject> { Cabin4, Circular_4 }; DtoCsgTree Hole = new DtoCsgTree { Color = (uint)Color.Gray.ToArgb() }; Hole.Elements.Add(new Path { Rotation = 0, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, 300, -100 } }, new Line { Point = new List <double> { 0, 300, 200 } } }, CrossSection = "RD8" }); Opening Hole_1 = new Opening { Name = "Hole_1", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = Hole }; Hole_1.AddProperty("element", "matrix", matrix1); Opening Hole_2 = new Opening { Name = "Hole_2", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = Hole }; Hole_2.AddProperty("element", "matrix", matrix2); Opening Hole_3 = new Opening { Name = "Hole_3", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = Hole }; Hole_3.AddProperty("element", "matrix", matrix3); Opening Hole_4 = new Opening { Name = "Hole_4", Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = Hole }; Hole_4.AddProperty("element", "matrix", matrix4); DtoConnections connections = new DtoConnections { ConnectionElement = new ConnectionElement(), ElementIds = new List <Guid>() }; connections.ConnectionElement.Name = _connectionElementName; connections.ConnectionElement.Description = "Connection_Part_Of_Test"; connections.ElementIds.Add(_bar0.Id); connections.ElementIds.Add(_bar1.Id); connections.ConnectionElement.Children = new List <DtObject> { Slab, Weld_1, Weld_2, Screw_1, Screw_2, Screw_3, Screw_4, Hole_1, Hole_2, Hole_3, Hole_4 }; _savedDtoConnections = _integrationBase.ApiCore.DtoConnection.CreateConnection(_integrationBase.CurrentProject.Id, connections); if (_savedDtoConnections == null) { MessageBoxHelper.ShowInformation("DtoConnections could not be generated.", _parentWindow); } else { _savedDtoConnectionsId = _savedDtoConnections.Id; _integrationBase.ApiCore.Projects.ConvertGeometry(model.ProjectId); hideProgressWindow = false; NavigateToControl(); CreateConnection.IsEnabled = false; DeleteConnection.IsEnabled = true; } } finally { if (hideProgressWindow) { ProgressWindow.Hide(); } } }
public List <AssemblerContent> GetAssemblerInv() { List <AssemblerContent> assemblerContents = new List <AssemblerContent>(); assemblerContents.Add(new AssemblerContent() { componentName = "" + SteelPlate.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + ConstructionComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + InteriorPlate.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + SmallTube.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + MotorComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + ComputerComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + Display.ToString().Split('/')[1], amount = 0 }); foreach (var assembler in Assemblers) { // Output inventory List <MyInventoryItem> iTmp = new List <MyInventoryItem>(); assembler.GetInventory(1).GetItems(iTmp); foreach (var item in iTmp) { string name = item.Type.ToString().Split('/')[1]; var ac = assemblerContents.Where(y => y.componentName.Equals(name)).FirstOrDefault(); if (ac != null) { ac.amount += item.Amount.ToIntSafe(); } else { Message = "Unusuable component in assembler inventory. \nComponent: " + name; } } // Production Queue List <MyProductionItem> qTmp = new List <MyProductionItem>(); assembler.GetQueue(qTmp); foreach (var item in qTmp) { string name = item.BlueprintId.ToString().Split('/')[1]; var ac = assemblerContents.Where(y => y.componentName.Equals(name)).FirstOrDefault(); if (ac != null) { ac.amount += item.Amount.ToIntSafe(); } else { Message = "Unusuable component in assembler queue. \nComponent: " + name; } } } return(assemblerContents); }