Git Product home page Git Product logo

Comments (8)

CBenghi avatar CBenghi commented on June 9, 2024

The logic for cascading the deletion of elements is quite complicated to manage.
I think your best approach for reducing files is to build a new ones copying the elements of interest.
Does this seam to be an acceptable approach to your case? If so ping us again here.
There's no strong place where the community meets other than here. We'll have to work on this.
Best,
Claudio

from xbimessentials.

Jero9999 avatar Jero9999 commented on June 9, 2024

Thanks for the reply. I thought that might be the answer. I know about it being complicated to manage. That's pretty much why I was hoping you guys had already done it.
I agree with the copying relevant bits into a new model. I actually tried it using the XBimModel.InsertCopy() but I kept getting Assert errors. It looks like it is designed to do what I want though. Any suggestions?

_Model.CreateFrom(ifcFilename, xbimDbFilename, null, true, true);
var outputModel = new XbimModel();

using (var transaction = outputModel.BeginTransaction("add to representation"))
{
    outputModel.InsertCopy(_Model.IfcProject, transaction);
    outputModel.Validate(transaction.Modified(), Console.Out);
    transaction.Commit();
}

from xbimessentials.

CBenghi avatar CBenghi commented on June 9, 2024

Apologies for the long wait, i'll be testing this in the next couple of days and come back to you.

from xbimessentials.

SteveLockley avatar SteveLockley commented on June 9, 2024

Work has commenced to migrate samples. See the develop branch for the latest state, now we support Ifc4 the remainder will be migrated over, any help greatly appreciated

from xbimessentials.

martin1cerny avatar martin1cerny commented on June 9, 2024

Shall we close this issue?

from xbimessentials.

Jero9999 avatar Jero9999 commented on June 9, 2024

Yup. No longer an issue

From: Martin Černý [mailto:[email protected]]
Sent: Wednesday, 16 March 2016 3:55 a.m.
To: xBimTeam/XbimEssentials [email protected]
Cc: jero [email protected]
Subject: Re: [XbimEssentials] Deleting / Removing stuff from the xbim model (#15)

Shall we close this issue?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#15 (comment)

from xbimessentials.

jojobs avatar jojobs commented on June 9, 2024

Hi Steve, Martin. Claudio,

I have similar problem, I want to filter walls and create the Spatial view.

I have used the following code, but it is not populating the tree (Only project number appears on the tree). Could you please help?

private void OpenIfcFile(object s, DoWorkEventArgs args)
{
var worker = s as BackgroundWorker;
var ifcFilename = args.Argument as string;

        var model = new XbimModel();
        var modelCopy = new XbimModel();
        try
        {
            _temporaryXbimFileName = Path.GetTempFileName();
            SetOpenedModelFileName(ifcFilename);             

            if (worker != null)
            {
                model.CreateFrom(ifcFilename, _temporaryXbimFileName, worker.ReportProgress, true);
                string tempFileName = "";
                modelCopy = XbimModel.CreateModel(tempFileName);

                modelCopy.AutoAddOwnerHistory = false;
                using (var txn = modelCopy.BeginTransaction())
                {
                    var copied = new XbimInstanceHandleMap(model, modelCopy);
                    //modelCopy.InsertCopy(model.IfcProject, txn);
                    foreach (var item in model.Instances)
                    {
                        var ifctype = item.IfcType();
                        if (ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCPROJECT || 
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCBUILDING ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCBUILDINGSTOREY ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCSITE ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCWALLSTANDARDCASE )
                        {
                            modelCopy.InsertCopy(item, copied, txn, false);
                        }                        
                    }

                    txn.Commit();
                }

                var context = new Xbim3DModelContext(modelCopy);//upgrade to new geometry represenation, uses the default 3D model
                context.CreateContext(geomStorageType: XbimGeometryType.PolyhedronBinary,  progDelegate: worker.ReportProgress,  adjustWCS: false);

                if (worker.CancellationPending) //if a cancellation has been requested then don't open the resulting file
                {
                    try
                    {
                        model.Close();
                        if (File.Exists(_temporaryXbimFileName))
                            File.Delete(_temporaryXbimFileName); //tidy up;
                        _temporaryXbimFileName = null;
                        SetOpenedModelFileName(null);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message, ex);
                    }
                    return;
                }
            }
            args.Result = modelCopy;

        }
        catch (Exception ex)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Error reading " + ifcFilename);
            var indent = "\t";
            while (ex != null)
            {
                sb.AppendLine(indent + ex.Message);
                ex = ex.InnerException;
                indent += "\t";
            }

            args.Result = new Exception(sb.ToString());
        }
    }

from xbimessentials.

andyward avatar andyward commented on June 9, 2024

Answered on #57

from xbimessentials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.