private bool GetElementAssemblies(bool showNotFoundMessage)
        {
            bool hasDuplicateValues = false;

            if (_bar0 == null || _bar1 == null)
            {
                List <ElementAssembly> elementAssemblies =
                    _integrationBase.ApiCore.DtObjects.GetObjects <ElementAssembly>(_integrationBase.CurrentProject.Id, ObjectRequestProperties.Pset | ObjectRequestProperties.InternalValues);

                foreach (ElementAssembly elementAssembly in elementAssemblies)
                {
                    if (elementAssembly.GetDtObjectName() == _bar0Name)
                    {
                        if (_bar0 == null)
                        {
                            _bar0 = elementAssembly;
                        }
                        else
                        {
                            hasDuplicateValues = true;
                            break;
                        }
                    }
                    if (elementAssembly.GetDtObjectName() == _bar1Name)
                    {
                        if (_bar1 == null)
                        {
                            _bar1 = elementAssembly;
                        }
                        else
                        {
                            hasDuplicateValues = true;
                            break;
                        }
                    }
                }
            }

            if (hasDuplicateValues)
            {
                _bar0 = null; _bar1 = null;

                string message = "Multiple objects with the same name were found.";
                MessageBoxHelper.ShowInformation(message, _parentWindow);
            }
            else if (_bar0 == null || _bar1 == null)
            {
                if (showNotFoundMessage)
                {
                    MessageBoxHelper.ShowInformation("ElementAssemblies were not found.", _parentWindow);
                }
            }

            return(_bar0 != null && _bar1 != null);
        }
        private void DeleteModelAndObject_Click(object sender, RoutedEventArgs e)
        {
            bool hasValues = GetElementAssemblies(false);

            if (hasValues)
            {
                GetConnectionsModel(false);

                if (_savedDtoConnectionsId != null && _savedDtoConnectionsId != Guid.Empty)
                {
                    bool deleted = _integrationBase.ApiCore.DtoConnection.DeleteConnections((Guid)_savedDtoConnectionsId);
                    if (deleted)
                    {
                        _savedDtoConnections       = null;
                        _savedDtoConnectionsId     = null;
                        DeleteConnection.IsEnabled = false;
                    }
                }

                bool bar0Deleted = _integrationBase.ApiCore.DtObjects.DeleteObject(_bar0.Id);
                if (bar0Deleted)
                {
                    _bar0 = null;
                }

                bool bar1Deleted = _integrationBase.ApiCore.DtObjects.DeleteObject(_bar1.Id);
                if (bar1Deleted)
                {
                    _bar1 = null;
                }

                if (!bar0Deleted || !bar1Deleted)
                {
                    MessageBoxHelper.ShowInformation("Not all ElementAssemblies could be deleted.", _parentWindow);
                }

                if (_model != null)
                {
                    bool modelDeleted = _integrationBase.ApiCore.Divisions.DeleteDtoDivision(_model.Id);
                    if (modelDeleted)
                    {
                        _model = null;
                    }

                    DeleteConnection.IsEnabled     = false;
                    DeleteModelAndObject.IsEnabled = false;
                }
            }

            NavigateToControl();
        }
        private bool SearchElements(Guid topologyDivisionId)
        {
            List <ElementAssembly> assemblies = _integrationBase.ApiCore.DtObjects.GetObjects <ElementAssembly>(topologyDivisionId, ObjectRequestProperties.InternalValues);

            if (assemblies?.Count > 1)
            {
                _bar0 = assemblies.Find(x => x.Name == _bar0Name);
                _bar1 = assemblies.Find(x => x.Name == _bar1Name);
            }
            else
            {
                _bar0 = null;
                _bar1 = null;
            }

            _savedDtoConnectionsId = _integrationBase.ApiCore.DtObjects.GetObjects <ProjectConnection>(_integrationBase.CurrentProject.Id, ObjectRequestProperties.InternalValues)
                                     ?.Find(x => x.Name == _connectionElementName)?.Id;

            return(_bar0 != null && _bar1 != null);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string filepath = "loai.ifc";

            using (var model = IfcStore.Create(Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel))
            {
                model.SaveAs(string.Format(filepath));
            }
            string section  = "PL150*5";
            string section2 = "PL200*5";
            string section3 = "PL180*5";

            ModelInfo    mymodel   = new ModelInfo("project1", "site1", "building1", filepath);
            TeklaElement myelement = new TeklaElement(section, mymodel);

            myelement.Create();
            TeklaElement myelement2 = new TeklaElement(section2, mymodel);

            myelement2.Create();

            TeklaElement myelement3 = new TeklaElement(section3, mymodel);

            myelement3.Create();

            ElementAssembly elementAssembly = new ElementAssembly(mymodel);

            elementAssembly.MyElements.Add(myelement);
            elementAssembly.MyElements.Add(myelement2);
            elementAssembly.MyElements.Add(myelement3);

            elementAssembly.Create();

            string filename = "D:\\iti\\courses\\BIM\\bim I project\\TeklaIFCMapper\\TeklaIFCMapper\\TeklaIFCMapper\\bin\\Debug";

            using (var stepmpdel = IfcStore.Open($"{filename}\\{filepath}"))
            {
                //save as xml
                stepmpdel.SaveAs($"{filename}\\loai.ifcxml");
            }
        }
        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();
                }
            }
        }
Esempio n. 6
0
 protected void AddBeam(ElementAssembly beam, OpenModel openModel)
 {
 }