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(); } } }
private void CreateObjects_Click(object sender, RoutedEventArgs e) { DtoDivision model = GetConnectionsModel(); if (model == null) { return; } bool hasValues = GetElementAssemblies(false); if (hasValues) { MessageBoxHelper.ShowInformation("ElementAssemblies are already created.", _parentWindow); return; } ProgressWindow.Text = "Create objects."; ProgressWindow.Show(); bool hideProgressWindow = true; try { // Create a horizontal steel column by using Path with reference to IPE600. DtoCsgTree csg = new DtoCsgTree { Color = (uint)Color.Gray.ToArgb() }; csg.Elements.Add(new Path { Rotation = Math.PI / 2, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0, 0, 0 } }, new Line { Point = new List <double> { 1500, 0, 0 } } }, CrossSection = "IPE600" }); ElementAssembly bar0 = new ElementAssembly { Name = _bar0Name, Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = csg }; // Test string jsonString = JsonConvert.SerializeObject(bar0); // Post object to Bimplus. _bar0 = _integrationBase.ApiCore.DtObjects.PostObject(bar0) as ElementAssembly; DtoCsgTree csg2 = new DtoCsgTree { Color = (uint)Color.Gray.ToArgb() }; csg2.Elements.Add(new Path { Rotation = Math.PI / 2, OffsetY = -300, Geometry = new List <CsgGeoElement> { new StartPolygon { Point = new List <double> { 0.0, 310, 0 } }, new Line { Point = new List <double> { 0.0, 1810, 0 } } }, CrossSection = "IPE600" }); ElementAssembly bar1 = new ElementAssembly { Name = _bar1Name, Parent = model.TopologyDivisionId, Division = model.Id, LogParentID = _integrationBase.CurrentProject.Id, CsgTree = csg2 }; // Test jsonString = JsonConvert.SerializeObject(bar1); // Post object to Bimplus. _bar1 = _integrationBase.ApiCore.DtObjects.PostObject(bar1) as ElementAssembly; if (_bar0 == null || _bar1 == null) { MessageBoxHelper.ShowInformation("Not all objects could be created.", _parentWindow); } else { _integrationBase.ApiCore.Projects.ConvertGeometry(model.ProjectId); hideProgressWindow = false; NavigateToControl(); DeleteModelAndObject.IsEnabled = true; } } finally { if (hideProgressWindow) { ProgressWindow.Hide(); } } }