Ejemplo n.º 1
0
        private static IFCAnyHandle CopyRailingHandle(ExporterIFC exporterIFC, Element elem, ElementId catId, IFCAnyHandle origLocalPlacement,
                                                      IFCAnyHandle origRailing)
        {
            IFCFile file = exporterIFC.GetFile();

            IFCAnyHandle origRailingObjectPlacement = IFCAnyHandleUtil.GetInstanceAttribute(origRailing, "ObjectPlacement");
            IFCAnyHandle railingRelativePlacement   = IFCAnyHandleUtil.GetInstanceAttribute(origRailingObjectPlacement, "RelativePlacement");
            IFCAnyHandle parentRelativePlacement    = IFCAnyHandleUtil.GetInstanceAttribute(origLocalPlacement, "RelativePlacement");

            IFCAnyHandle newRelativePlacement = null;
            IFCAnyHandle parentRelativeOrig   = IFCAnyHandleUtil.GetInstanceAttribute(parentRelativePlacement, "Location");

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(parentRelativeOrig))
            {
                IList <double> parentVec           = IFCAnyHandleUtil.GetCoordinates(parentRelativeOrig);
                IFCAnyHandle   railingRelativeOrig = IFCAnyHandleUtil.GetInstanceAttribute(railingRelativePlacement, "Location");
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(railingRelativeOrig))
                {
                    IList <double> railingVec = IFCAnyHandleUtil.GetCoordinates(railingRelativeOrig);

                    IList <double> newMeasure = new List <double>();
                    newMeasure.Add(railingVec[0] - parentVec[0]);
                    newMeasure.Add(railingVec[1] - parentVec[1]);
                    newMeasure.Add(railingVec[2]);

                    IFCAnyHandle locPtHnd = ExporterUtil.CreateCartesianPoint(file, newMeasure);
                    newRelativePlacement = IFCInstanceExporter.CreateAxis2Placement3D(file, locPtHnd, null, null);
                }
                else
                {
                    IList <double> railingMeasure = new List <double>();
                    railingMeasure.Add(-parentVec[0]);
                    railingMeasure.Add(-parentVec[1]);
                    railingMeasure.Add(0.0);
                    IFCAnyHandle locPtHnd = ExporterUtil.CreateCartesianPoint(file, railingMeasure);
                    newRelativePlacement = IFCInstanceExporter.CreateAxis2Placement3D(file, locPtHnd, null, null);
                }
            }

            IFCAnyHandle newLocalPlacement = IFCInstanceExporter.CreateLocalPlacement(file, origLocalPlacement, newRelativePlacement);
            IFCAnyHandle origRailingRep    = IFCAnyHandleUtil.GetInstanceAttribute(origRailing, "Representation");
            IFCAnyHandle newProdRep        = ExporterUtil.CopyProductDefinitionShape(exporterIFC, elem, catId, origRailingRep);

            string         ifcEnumTypeAsString = IFCAnyHandleUtil.GetEnumerationAttribute(origRailing, "PredefinedType");
            IFCRailingType railingType         = GetIFCRailingTypeFromString(ifcEnumTypeAsString);

            string       copyGUID         = GUIDUtil.CreateGUID();
            IFCAnyHandle copyOwnerHistory = IFCAnyHandleUtil.GetInstanceAttribute(origRailing, "OwnerHistory");
            string       copyName         = IFCAnyHandleUtil.GetStringAttribute(origRailing, "Name");
            string       copyDescription  = IFCAnyHandleUtil.GetStringAttribute(origRailing, "Description");
            string       copyObjectType   = IFCAnyHandleUtil.GetStringAttribute(origRailing, "ObjectType");
            string       copyElemId       = IFCAnyHandleUtil.GetStringAttribute(origRailing, "Tag");

            return(IFCInstanceExporter.CreateRailing(file, copyGUID, copyOwnerHistory, copyName, copyDescription, copyObjectType,
                                                     newLocalPlacement, newProdRep,
                                                     copyElemId, railingType));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a handle representing an IfcRailing and assigns it to the file.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="guid">The GUID for the entity.</param>
        /// <param name="ownerHistory">The IfcOwnerHistory.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="objectType">The object type.</param>
        /// <param name="objectPlacement">The local placement.</param>
        /// <param name="representation">The geometric representation of the entity, in the IfcProductRepresentation.</param>
        /// <param name="elementTag">The tag for the identifier of the element.</param>
        /// <param name="predefinedType">The railing type.</param>
        /// <returns>The handle.</returns>
        public static IFCAnyHandle CreateRailing(IFCFile file, string guid, IFCAnyHandle ownerHistory,
            string name, string description, string objectType, IFCAnyHandle objectPlacement,
            IFCAnyHandle representation, string elementTag, IFCRailingType predefinedType)
        {
            ValidateElement(guid, ownerHistory, name, description, objectType, objectPlacement, representation, elementTag);

            IFCAnyHandle railing = CreateInstance(file, IFCEntityType.IfcRailing);
            IFCAnyHandleUtil.SetAttribute(railing, "PredefinedType", predefinedType);
            SetElement(railing, guid, ownerHistory, name, description, objectType, objectPlacement, representation, elementTag);
            return railing;
        }
        /// <summary>
        /// Creates an IfcRailingType, and assigns it to the file.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="guid">The GUID.</param>
        /// <param name="ownerHistory">The owner history.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="applicableOccurrence">The attribute optionally defines the data type of the occurrence object.</param>
        /// <param name="propertySets">The property set(s) associated with the type.</param>
        /// <param name="representationMaps">The mapped geometries associated with the type.</param>
        /// <param name="elementTag">The tag that represents the entity.</param>
        /// <param name="elementType">The type name.</param>
        /// <param name="predefinedType">The predefined types.</param>
        /// <returns>The handle.</returns>
        public static IFCAnyHandle CreateRailingType(IFCFile file, string guid, IFCAnyHandle ownerHistory, string name,
            string description, string applicableOccurrence, HashSet<IFCAnyHandle> propertySets,
            IList<IFCAnyHandle> representationMaps, string elementTag, string elementType, IFCRailingType predefinedType)
        {
            ValidateElementType(guid, ownerHistory, name, description, applicableOccurrence, propertySets,
                representationMaps, elementTag, elementType);

            IFCAnyHandle railingType = CreateInstance(file, IFCEntityType.IfcRailingType);
            IFCAnyHandleUtil.SetAttribute(railingType, "PredefinedType", predefinedType);
            SetElementType(railingType, guid, ownerHistory, name, description, applicableOccurrence, propertySets,
                representationMaps, elementTag, elementType);
            return railingType;
        }