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

Copy/paste error suspected in DistributionPort creation process. #51

Closed
Scarmentado opened this issue Oct 17, 2018 · 1 comment
Closed

Copy/paste error suspected in DistributionPort creation process. #51

Scarmentado opened this issue Oct 17, 2018 · 1 comment

Comments

@Scarmentado
Copy link

@Scarmentado Scarmentado commented Oct 17, 2018

In ConnectorExporter.AddConnection method there is two calls to AddNestedMembership method, the first for the In port, the second for the Out port. But in both calls the inElementIFCHandle is used as parameter.
So the two ports are nested to the same object.

Look at the if (isIFC4AndAbove) condition:

         // ----------------------- In Port ----------------------
         {
            string guid = GUIDUtil.CreateGUID();
            IFCFlowDirection flowDir = (isBiDirectional) ? IFCFlowDirection.SourceAndSink : IFCFlowDirection.Sink;

            IFCAnyHandle localPlacement = CreateLocalPlacementForConnector(exporterIFC, connector, inElementIFCHandle, flowDir);
            string portName = "InPort_" + inElement.Id;
            string portType = "Flow";   // Assigned as Port.Description
            portIn = IFCInstanceExporter.CreateDistributionPort(exporterIFC, null, guid, ownerHistory, localPlacement, null, flowDir);
            IFCAnyHandleUtil.OverrideNameAttribute(portIn, portName);
            IFCAnyHandleUtil.SetAttribute(portIn, "Description", portType);

            // Attach the port to the element
            guid = GUIDUtil.CreateGUID();
            string connectionName = inElement.Id + "|" + guid;
            IFCAnyHandle connectorIn = null;

            // Port connection is changed in IFC4 to use IfcRelNests for static connection. IfcRelConnectsPortToElement is used for a dynamic connection and it is restricted to IfcDistributionElement
            // The following code collects the ports that are nested to the object to be assigned later
            if (isIFC4AndAbove)
               AddNestedMembership(inElementIFCHandle, portIn);
            else
               connectorIn = IFCInstanceExporter.CreateRelConnectsPortToElement(ifcFile, guid, ownerHistory, connectionName, portType, portIn, inElementIFCHandle);
         }

         // ----------------------- Out Port----------------------
         {
            string guid = GUIDUtil.CreateGUID();
            IFCFlowDirection flowDir = (isBiDirectional) ? IFCFlowDirection.SourceAndSink : IFCFlowDirection.Source;

            IFCAnyHandle localPlacement = CreateLocalPlacementForConnector(exporterIFC, connected, outElementIFCHandle, flowDir);
            string portName = "OutPort_" + outElement.Id;
            string portType = "Flow";   // Assigned as Port.Description

            portOut = IFCInstanceExporter.CreateDistributionPort(exporterIFC, null, guid, ownerHistory, localPlacement, null, flowDir);
            IFCAnyHandleUtil.OverrideNameAttribute(portOut, portName);
            IFCAnyHandleUtil.SetAttribute(portOut, "Description", portType);

            // Attach the port to the element
            guid = GUIDUtil.CreateGUID();
            string connectionName = outElement.Id + "|" + guid;
            IFCAnyHandle connectorOut = null;

            // Port connection is changed in IFC4 to use IfcRelNests for static connection. IfcRelConnectsPortToElement is used for a dynamic connection and it is restricted to IfcDistributionElement
            // The following code collects the ports that are nested to the object to be assigned later
            if (isIFC4AndAbove)
               AddNestedMembership(inElementIFCHandle, portOut);
            else
               connectorOut = IFCInstanceExporter.CreateRelConnectsPortToElement(ifcFile, guid, ownerHistory, connectionName, portType, portOut, outElementIFCHandle);
         }

I will make a pull request for that.

@Scarmentado

This comment has been minimized.

Copy link
Author

@Scarmentado Scarmentado commented Oct 19, 2018

Thank you

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.