Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Window to Existing Opening #11

Open
FrieBIM91 opened this issue May 14, 2018 · 3 comments
Open

Add new Window to Existing Opening #11

FrieBIM91 opened this issue May 14, 2018 · 3 comments
Labels

Comments

@FrieBIM91
Copy link

@martin1cerny
I am to trying to add a new Standard Window to an existing Opening.

I was able to add a new Wall,Opening and Window to an existing Ifc file already.
But then I had some troubles by adding a new Window to an existing Opening.
I tried following approaches:

  1. Retrieving the dimensions from opening and pass them to the new wall:
    -Geometric representation and spatial hierachy was allright, but placement wasnt accurate.

  2. Mapping Window and Opening via IfcMappedItem
    -Did some research on that and it is not recommended to use this concept

So could somebody provide an example of how to add a new window to an exiting opening?
If not, what is the best approach to solve that issue?

According to the parametric approach of Ifc I guess it is not necessary to retrieve any values (e.g. Dimension, insertpoint), but "only" to set the correct semantic and geometric relations right?

Thanks a lot for your help

@martin1cerny
Copy link
Member

You might need to consider local placement and its spatial relations. My recommendation would be to study IFC documentation and existing files.

@FrieBIM91
Copy link
Author

I could achieve some progress but I still have some problems with this issue.

Basically, I have two scenarios:

  1. Scenario: I designed a wall and an opening in Revit2019 -> export as IFC2x3 -> add standalone IfcWindow from another IfcFile (https://www.nationalbimlibrary.com/en-ca/generic/double-window-system-with-a-side-hung-light-and-fixed-light-with-opening-transom/?lo=en-CA) by Code -> open the IFC file in Revit (Picture 1.2)
    xbimopeningcreated_inrevit_ifcwindowaddedbycode
    Picture 1.1 (Xbim Xplorer)
    openingcreated_inrevit_ifcwindowaddedbycode
    Picture 1.2 (Revit2019)

Problem: I created the opening according to the dimensions of the Window and then added the IfcWindow with the Insert Copy() Function. The import is fine, but I still have a small gap between Window and Wall in the Xbim Xplorer (Picture 1.1). For placing the window I referenced the Position of the Opening Body, which was created through an ExtrudedAreaSolid. When I open the IFC file in Revit (Picture 1.2), the gap is closed automatically.

  1. Scenario: I designed a wall in Revit2019 -> export as IFC2x3 -> add Opening by Code -> open the IFC file in Revit (Picture 2.2)
    xbimcreateoopeningbycode
    Picture 2.1 (Xbim Xplorer)
    xbimcreateoopeningbycode_inrevit
    Picutre 2.2 (Revit2019)

Problem: When I create the Opening by Code (see function CreateOpeningAgnostic) it works in the XBim Xplorer (pic 2.1) but in Revit the Opening disappears (pic 2.2).

So do u have any further hints what could be wrong by creating the opening and placing the window properly in it?

Any help would be highly appreciated!
Thanks a lot!

   private static IIfcOpeningElement CreateOpeningAgnostic(IfcStore model, Xbim.Ifc4.Interfaces.IIfcWall wall, double width, double height, double depth, double[] insertPoint)
    {
        //Creation helper class for new entities.
        var create = new Create(model);
        
        //Begin a transaction.
        using (var txn = model.BeginTransaction("Create Opening"))
        {
            var opening = create.OpeningElement(o =>
            {
                o.Name = "A Standard Opening Element";
                o.ObjectType = "Opening";
                o.PredefinedType = IfcOpeningElementTypeEnum.OPENING;
                
            });

            //Semantic conneticon IIfcWall and IIfcOpeningElement
            var relVoidsElement = create.RelVoidsElement(relVoid =>
            {
                relVoid.RelatingBuildingElement = wall;
                relVoid.RelatedOpeningElement = opening;
            });

            //Represent Opening as an Extruded Area Solid
            //Define Rectangle face for Opening
            var rectProf = create.RectangleProfileDef(re => re.ProfileType = IfcProfileTypeEnum.AREA);
            rectProf.XDim = width;
            rectProf.YDim = depth;

            //model as a swept area solid
            var body = create.ExtrudedAreaSolid(b =>
            {
                b.Depth = height;
                b.SweptArea = rectProf;
                b.ExtrudedDirection = create.Direction(d =>
                {
                    d.DirectionRatios.Add(0); //=X
                    d.DirectionRatios.Add(0);//=Y
                    d.DirectionRatios.Add(1);//=Z
                });
            });

            //parameters to insert the geometry in the model
            //opening is placed via IfcLocalPlacement, so its placed relative to the Coordinatesystem of the
            //corresponding wall, not placed in WCS.
            var origin = create.CartesianPoint(c =>
            {
                c.Coordinates.Add(insertPoint[0]); //X
                c.Coordinates.Add(insertPoint[1]);//Y
                c.Coordinates.Add(insertPoint[2]);//Z
            });

            body.Position = create.Axis2Placement3D(axis3D =>
            {
                axis3D.Location = origin;
            });

            //Read the GeometricSubcontext from the current model
            var modelContext = model.Instances.OfType<IIfcGeometricRepresentationContext>().FirstOrDefault().HasSubContexts.First();

            //Create a Definition shape to hold the geometry
            var shape = create.ShapeRepresentation(sh =>
            {
                sh.ContextOfItems = modelContext;
                sh.ContextOfItems.ContextIdentifier = "Body";
                sh.RepresentationType = "SweptSolid";
                sh.RepresentationIdentifier = "Body";
                sh.Items.Add(body);
            });

            //Create a Product Definition and add the model geometry to the opening
            var rep = create.ProductDefinitionShape(re =>
            {
                re.Representations.Add(shape);
            });
            opening.Representation = rep;

            //place the opening into the model
            var lp = create.LocalPlacement(l =>
            {
                l.PlacementRelTo = wall.ObjectPlacement;
                l.RelativePlacement = body.Position;
            });
            opening.ObjectPlacement = lp;

            txn.Commit();
            return opening;
        }
    }

@jacsmi7937
Copy link

Did you ever get this fixed? I am trying to add an opening to a wall now and I am having issues. please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants