static void Main(string[] args) { DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4DesignTransfer); IfcBuilding building = new IfcBuilding(db, "IfcBuilding") { }; IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre) { }; //IfcBuildingStorey storey = new IfcBuildingStorey(building, "Ground Floor", 0); IfcMaterial masonryFinish = new IfcMaterial(db, "Masonry - Brick - Brown"); IfcMaterial masonry = new IfcMaterial(db, "Masonry"); IfcMaterialLayer layerFinish = new IfcMaterialLayer(masonryFinish, 110, "Finish"); IfcMaterialLayer airInfiltrationBarrier = new IfcMaterialLayer(db, 50, "Air Infiltration Barrier") { IsVentilated = IfcLogicalEnum.TRUE }; IfcMaterialLayer structure = new IfcMaterialLayer(masonry, 110, "Core"); string name = "Double Brick - 270"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(new List <IfcMaterialLayer>() { layerFinish, airInfiltrationBarrier, structure }, name); db.NextObjectRecord = 300; IfcWallType wallType = new IfcWallType(name, materialLayerSet, IfcWallTypeEnum.NOTDEFINED) { }; // todo implement rhinocommon overload IfcWallStandardCase wallStandardCase = new IfcWallStandardCase(building, wallType, new Line(0, 0, 0, 5000, 0, 0), 2000, 0, true, null) { }; }
protected override void GenerateInstance(IfcBuilding building) { DatabaseIfc db = building.Database; IfcMaterial masonryFinish = new IfcMaterial(db, "Masonry - Brick - Brown"); IfcMaterial masonry = new IfcMaterial(db, "Masonry"); IfcMaterialLayer layerFinish = new IfcMaterialLayer(masonryFinish, 110, "Finish"); IfcMaterialLayer airInfiltrationBarrier = new IfcMaterialLayer(db, 50, "Air Infiltration Barrier") { IsVentilated = IfcLogicalEnum.TRUE }; IfcMaterialLayer structure = new IfcMaterialLayer(masonry, 110, "Core"); string name = "Double Brick - 270"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(new List <IfcMaterialLayer>() { layerFinish, airInfiltrationBarrier, structure }, name); db.NextObjectRecord = 300; IfcWallType wallType = new IfcWallType(name, materialLayerSet, IfcWallTypeEnum.NOTDEFINED); IfcMaterialLayerSetUsage layerSetUsage = new IfcMaterialLayerSetUsage(materialLayerSet, IfcLayerSetDirectionEnum.AXIS2, IfcDirectionSenseEnum.POSITIVE, -materialLayerSet.MaterialLayers.Sum(x => x.LayerThickness) / 2.0); IfcWallStandardCase wallStandardCase = new IfcWallStandardCase(building, layerSetUsage, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 5000, 2000); db.Context.AddDeclared(wallType); //Unique ids assigned to generate constant IfcScript sample files, remove otherwise wallType.GlobalId = "2aG1gZj7PD2PztLOx2$IVX"; wallStandardCase.GlobalId = "0DWgwt6o1FOx7466fPk$jl"; materialLayerSet.Associates.GlobalId = "36U74BIPDD89cYkx9bkV$Y"; wallStandardCase.MaterialSelect.Associates.GlobalId = "1BYoVhjtLADPUZYzipA826"; }
protected override void GenerateData(STPModelData md, IfcBuilding building) { IfcMaterial masonryFinish = new IfcMaterial(md, "Masonry - Brick - Brown", "", ""); IfcMaterial masonry = new IfcMaterial(md, "Masonry", "", ""); IfcMaterialLayer layerFinish = new IfcMaterialLayer(md, masonryFinish, 110, false, "Finish", "", "", 0); IfcMaterialLayer airInfiltrationBarrier = new IfcMaterialLayer(md, null, 50, true, "Air Infiltration Barrier", "", "", 0); IfcMaterialLayer structure = new IfcMaterialLayer(md, masonry, 110, false, "Core", "", "", 0); string name = "Double Brick - 270"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(new List <IfcMaterialLayer>() { layerFinish, airInfiltrationBarrier, structure }, name, ""); materialLayerSet.Associates.GlobalId = "36U74BIPDD89cYkx9bkV$Y"; md.NextObjectRecord = 300; IfcWallType wallType = new IfcWallType(name, materialLayerSet, IfcWallTypeEnum.NOTDEFINED) { GlobalId = "2aG1gZj7PD2PztLOx2$IVX" }; wallType.ObjectTypeOf.GlobalId = "1$EkFElNT8TB_VUVG1FtMe"; IfcWallStandardCase wallStandardCase = new IfcWallStandardCase(building, wallType, new Line(0, 0, 0, 5000, 0, 0), 2000, 0, true, null) { GlobalId = "0DWgwt6o1FOx7466fPk$jl" }; wallStandardCase.MaterialSelect.Associates.GlobalId = "1BYoVhjtLADPUZYzipA826"; }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: _forLayerSet = (IfcMaterialLayerSet)(value.EntityVal); return; case 1: _layerSetDirection = (IfcLayerSetDirectionEnum)System.Enum.Parse(typeof(IfcLayerSetDirectionEnum), value.EnumVal, true); return; case 2: _directionSense = (IfcDirectionSenseEnum)System.Enum.Parse(typeof(IfcDirectionSenseEnum), value.EnumVal, true); return; case 3: _offsetFromReferenceLine = value.RealVal; return; case 4: _referenceExtent = value.RealVal; return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
internal static void GenerateData(STPModelData md, IfcBuilding building,bool openings) { IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", ""); int thickness = 200; IfcMaterialLayer materialLayer = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0); string name = thickness + "mm Concrete"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet( materialLayer, name, ""); materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq"; md.NextObjectRecord = 300; IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR) { GlobalId = "0RSW$KKbzCZ9QaSm3GoEan" }; slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0"; PolyCurve polycurve = new PolyCurve(); polycurve.Append(new Line(0, 0, 0, 1000, 0, 0)); polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0))); polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0)); polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0))); IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, slabType, polycurve, -200, true, null) { GlobalId = "1wAj$J2Az2V8wnBiVYd3bU" }; slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w"; if (openings) { IfcCircleProfileDef cpd = new IfcCircleProfileDef(md, "100DIA", 50); IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd,new IfcAxis2Placement3D(md,new Plane(new Point3d(100,300,-200),Vector3d.XAxis,Vector3d.YAxis)),new IfcDirection(md,0,0,1),thickness); IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas) { GlobalId = "15RSTHd8nFVQWMRE7og7sd", Name = "Opening" }; opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO"; IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, "RecessRectangle", 500, 1000); eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50); IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, eas, IfcOpeningElementTypeEnum.RECESS) { GlobalId = "0w93HZ19H2D99zbAVNb4o2", Name = "Recess" }; recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM"; } }
static void Main(string[] args) { DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4DesignTransfer); IfcBuilding building = new IfcBuilding(db, "IfcBuilding") { }; IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre) { }; //IfcBuildingStorey storey = new IfcBuildingStorey(building, "Ground Floor", 0); IfcMaterial masonryFinish = new IfcMaterial(db, "Masonry - Brick - Brown"); IfcMaterial masonry = new IfcMaterial(db, "Masonry"); IfcMaterialLayer layerFinish = new IfcMaterialLayer(masonryFinish, 110, "Finish"); IfcMaterialLayer airInfiltrationBarrier = new IfcMaterialLayer(db, 50, "Air Infiltration Barrier") { IsVentilated = IfcLogicalEnum.TRUE }; IfcMaterialLayer structure = new IfcMaterialLayer(masonry, 110, "Core"); string name = "Double Brick - 270"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(new List <IfcMaterialLayer>() { layerFinish, airInfiltrationBarrier, structure }, name); IfcMaterialLayerSetUsage materialLayerSetUsage = new IfcMaterialLayerSetUsage(materialLayerSet, IfcLayerSetDirectionEnum.AXIS2, IfcDirectionSenseEnum.POSITIVE, 0); db.NextObjectRecord = 300; IfcWallType wallType = new IfcWallType(name, materialLayerSet, IfcWallTypeEnum.NOTDEFINED) { }; IfcWallStandardCase wallStandardCase = new IfcWallStandardCase(building, materialLayerSetUsage, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 5000, 2000) { }; }
internal static void GenerateData(STPModelData md, IfcBuilding building, bool openings) { IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", ""); int thickness = 200; IfcMaterialLayer materialLayer = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0); string name = thickness + "mm Concrete"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(md, materialLayer, name, ""); materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq"; md.NextObjectRecord = 300; IfcSlabType slabType = new IfcSlabType(md, new IfcElemTypeParams("0RSW$KKbzCZ9QaSm3GoEan", name, "", "", ""), materialLayerSet, null, IfcSlabTypeEnum.FLOOR); slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0"; PolyCurve polycurve = new PolyCurve(); polycurve.Append(new Line(0, 0, 0, 1000, 0, 0)); polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0))); polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0)); polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0))); IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, new IfcElemParams("1wAj$J2Az2V8wnBiVYd3bU", "", "", "", ""), slabType, polycurve, -200, true, null); slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w"; if (openings) { IfcCircleProfileDef cpd = new IfcCircleProfileDef(md, IfcProfileTypeEnum.AREA, "100DIA", null, 50); IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(100, 300, -200), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), thickness); IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, new IfcElemParams("15RSTHd8nFVQWMRE7og7sd", "Opening", "", "", ""), null, eas); opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO"; IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, "RecessRectangle", null, 500, 1000); eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50); IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, new IfcElemParams("0w93HZ19H2D99zbAVNb4o2", "Recess", "", "", ""), eas, IfcOpeningElementTypeEnum.RECESS); recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM"; } }
private static List <MaterialLayer> ToMaterialLayers(this IfcMaterialLayerSet set) { var layers = new List <MaterialLayer>(); foreach (var s in set.MaterialLayers) { layers.Add(s.ToMaterialLayer()); } return(layers); }
/// <summary> /// Set Material set usage and creates it if it doesn't exist. /// </summary> /// <param name = "forLayerSet">Material layer set for the usage</param> /// <param name = "layerSetDirection">Direction of the material layer set in the usage</param> /// <param name = "directionSense">Sense of the direction of the usage</param> /// <param name = "offsetFromReferenceLine">Offset from the reference line of the element</param> public static void SetMaterialLayerSetUsage(this IfcRoot element, IfcMaterialLayerSet forLayerSet, IfcLayerSetDirectionEnum layerSetDirection, IfcDirectionSenseEnum directionSense, IfcLengthMeasure offsetFromReferenceLine) { IModel model = element.ModelOf; element.SetMaterialLayerSetUsage(model, forLayerSet, layerSetDirection, directionSense, offsetFromReferenceLine); }
/// <summary> /// Add the data to the IfcMaterialLayerSet object /// </summary> /// <param name="row">COBieAssemblyRow holding the data</param> private void AddMaterial(COBieAssemblyRow row) { //check we have a chance of creating the IfcMaterialLayerSet object if (ValidateString(row.ParentName)) // && (ValidateString(row.ChildNames)) { IfcMaterialLayerSet ifcMaterialLayerSet = null; IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = null; IfcRelAssociatesMaterial ifcRelAssociatesMaterial = null; IfcBuildingElementProxy ifcBuildingElementProxy = null; if ((LastIfcMaterialLayerSet != null) && IsContinuedMaterialRow(row)) //this row line is a continuation of objects from the line above { ifcMaterialLayerSet = LastIfcMaterialLayerSet; } else { ifcMaterialLayerSet = Model.FederatedInstances.Where <IfcMaterialLayerSet>(mls => mls.LayerSetName == row.ParentName).FirstOrDefault(); if (ifcMaterialLayerSet == null) { ifcMaterialLayerSet = Model.Instances.New <IfcMaterialLayerSet>(mls => { mls.LayerSetName = row.ParentName; }); } ifcMaterialLayerSetUsage = Model.FederatedInstances.Where <IfcMaterialLayerSetUsage>(mlsu => mlsu.ForLayerSet == ifcMaterialLayerSet).FirstOrDefault(); if (ifcMaterialLayerSetUsage == null) { ifcMaterialLayerSetUsage = Model.Instances.New <IfcMaterialLayerSetUsage>(mlsu => { mlsu.ForLayerSet = ifcMaterialLayerSet; }); } string placeholderText = "Place holder for material layer Set " + row.ParentName; ifcBuildingElementProxy = Model.FederatedInstances.Where <IfcBuildingElementProxy>(bep => bep.Name == placeholderText).FirstOrDefault(); if (ifcBuildingElementProxy == null) { ifcBuildingElementProxy = Model.Instances.New <IfcBuildingElementProxy>(bep => { bep.Name = placeholderText; }); } ifcRelAssociatesMaterial = Model.FederatedInstances.Where <IfcRelAssociatesMaterial>(ras => ((ras.RelatingMaterial as IfcMaterialLayerSetUsage) == ifcMaterialLayerSetUsage)).FirstOrDefault(); if (ifcRelAssociatesMaterial == null) { ifcRelAssociatesMaterial = Model.Instances.New <IfcRelAssociatesMaterial>(ras => { ras.RelatingMaterial = ifcMaterialLayerSetUsage; ras.RelatedObjects.Add(ifcBuildingElementProxy); }); //Add Created By, Created On and ExtSystem to Owner History. SetUserHistory(ifcRelAssociatesMaterial, row.ExtSystem, row.CreatedBy, row.CreatedOn); } } //add the child objects AddChildObjects(ifcMaterialLayerSet, row.ChildNames); LastIfcMaterialLayerSet = ifcMaterialLayerSet; } }
protected override void GenerateData(STPModelData md, IfcBuilding building) { IfcMaterial masonryFinish = new IfcMaterial(md, "Masonry - Brick - Brown", "", ""); IfcMaterial masonry = new IfcMaterial(md, "Masonry", "", ""); IfcMaterialLayer layerFinish = new IfcMaterialLayer(md, masonryFinish, 110, false, "Finish", "", "", 0); IfcMaterialLayer airInfiltrationBarrier = new IfcMaterialLayer(md, null, 50, true, "Air Infiltration Barrier", "", "", 0); IfcMaterialLayer structure = new IfcMaterialLayer(md, masonry, 110, false, "Core", "", "", 0); string name = "Double Brick - 270"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet( new List<IfcMaterialLayer>() { layerFinish, airInfiltrationBarrier, structure }, name, ""); materialLayerSet.Associates.GlobalId = "36U74BIPDD89cYkx9bkV$Y"; md.NextObjectRecord = 300; IfcWallType wallType = new IfcWallType(name, materialLayerSet, IfcWallTypeEnum.NOTDEFINED) { GlobalId = "2aG1gZj7PD2PztLOx2$IVX" }; wallType.ObjectTypeOf.GlobalId = "1$EkFElNT8TB_VUVG1FtMe"; IfcWallStandardCase wallStandardCase = new IfcWallStandardCase(building, wallType, new Line(0, 0, 0, 5000, 0, 0), 2000, 0, true, null) { GlobalId = "0DWgwt6o1FOx7466fPk$jl" }; wallStandardCase.MaterialSelect.Associates.GlobalId = "1BYoVhjtLADPUZYzipA826"; }
/// <summary> /// Set Material set usage parameters and creates it if it doesn't exist. /// </summary> /// <param name = "model">Model of the element</param> /// <param name = "forLayerSet">Material layer set for the usage</param> /// <param name = "layerSetDirection">Direction of the material layer set in the usage</param> /// <param name = "directionSense">Sense of the direction of the usage</param> /// <param name = "offsetFromReferenceLine">Offset from the reference line of the element</param> public static void SetMaterialLayerSetUsage(this IfcRoot element, IModel model, IfcMaterialLayerSet forLayerSet, IfcLayerSetDirectionEnum layerSetDirection, IfcDirectionSenseEnum directionSense, IfcLengthMeasure offsetFromReferenceLine) { //if some input is not correct, material layer set usage is not created or changed if (element == null || forLayerSet == null) { return; } IfcMaterialLayerSetUsage materialUsage = element.GetOrCreateLayerSetUsage(model); materialUsage.ForLayerSet = forLayerSet; materialUsage.LayerSetDirection = layerSetDirection; materialUsage.DirectionSense = directionSense; materialUsage.OffsetFromReferenceLine = offsetFromReferenceLine; }
/// <summary> /// Add the child objects to the IfcMaterialLayerSet /// </summary> /// <param name="ifcMaterialLayerSet">IfcMaterialLayerSet object</param> /// <param name="childNames">list of child object names separated by " : ", NOT case sensitive</param> private bool AddChildObjects(IfcMaterialLayerSet ifcMaterialLayerSet, string childNames) { bool returnValue = false; List <string> splitChildNames = SplitString(childNames, ':'); foreach (string item in splitChildNames) { string name = item; double?thickness = GetLayerThickness(name); name = GetMaterialName(name).ToLower().Trim(); IfcMaterialLayer ifcMaterialLayer = null; IEnumerable <IfcMaterialLayer> ifcMaterialLayers = IfcMaterialLayers.Where(ml => (ml.Material.Name != null) && (ml.Material.Name.ToString().ToLower().Trim() == name)); if ((ifcMaterialLayers.Any()) && (ifcMaterialLayers.Count() > 1) && (thickness != null) ) { ifcMaterialLayer = ifcMaterialLayers.Where(ml => ml.LayerThickness == thickness).FirstOrDefault(); } else { ifcMaterialLayer = ifcMaterialLayers.FirstOrDefault(); } if (ifcMaterialLayer != null) { if (!ifcMaterialLayerSet.MaterialLayers.Contains(ifcMaterialLayer)) { ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer); } returnValue = true; } } return(returnValue); }
/// <summary> /// Get the IfcRelAssociatesMaterial object from the passed IfcMaterialLayerSet /// </summary> /// <param name="ifcMaterialLayerSet">IfcMaterialLayerSet object</param> /// <returns>IfcOwnerHistory object or null if none found</returns> protected IfcOwnerHistory GetMaterialOwnerHistory(IfcMaterialLayerSet ifcMaterialLayerSet) { if (_ifcRelAssociatesMaterials == null) { _ifcRelAssociatesMaterials = Model.FederatedInstances.OfType <IfcRelAssociatesMaterial>().ToList(); _ifcMaterialLayerSetUsages = Model.FederatedInstances.OfType <IfcMaterialLayerSetUsage>().ToList(); } var ifcMaterialLayerSetUsage = _ifcMaterialLayerSetUsages.FirstOrDefault(mlsu => mlsu.ForLayerSet == ifcMaterialLayerSet); IfcRelAssociatesMaterial ifcRelAssociatesMaterial = null; if (ifcMaterialLayerSetUsage != null) { ifcRelAssociatesMaterial = _ifcRelAssociatesMaterials.FirstOrDefault(ram => (ram.RelatingMaterial is IfcMaterialLayerSetUsage) && ((IfcMaterialLayerSetUsage)ram.RelatingMaterial == ifcMaterialLayerSetUsage)); } if (ifcRelAssociatesMaterial == null) { ifcRelAssociatesMaterial = _ifcRelAssociatesMaterials.FirstOrDefault(ram => (ram.RelatingMaterial is IfcMaterialLayerSet) && ((IfcMaterialLayerSet)ram.RelatingMaterial == ifcMaterialLayerSet)); } if (ifcRelAssociatesMaterial == null) { ifcRelAssociatesMaterial = _ifcRelAssociatesMaterials.FirstOrDefault(ram => ifcMaterialLayerSet.MaterialLayers.Contains(ram.RelatingMaterial)); } if (ifcRelAssociatesMaterial != null) { return(ifcRelAssociatesMaterial.OwnerHistory); } else { return(null); } }
public static void loadProperties(IfcEntity ifcEntity, IfcProduct ifcProduct) { ifcEntity.ColorMethod = colorMethodType.byEntity; #region Identification ifcEntity.Identification.Add("Model", "nome del file"); ifcEntity.Identification.Add("Name", ifcProduct.Name); ifcEntity.Identification.Add("Type", ifcProduct.ObjectType); ifcEntity.Identification.Add("GUID", ifcProduct.GlobalId); ifcEntity.Identification.Add("KeyWord", ifcProduct.KeyWord); #endregion if (ifcProduct is IfcElement) { IfcElement ifcElement = (IfcElement)ifcProduct; #region Material if (ifcElement.MaterialSelect != null) { if (ifcElement.MaterialSelect is IfcMaterialLayerSetUsage) { IfcMaterialLayerSetUsage mlsu = (IfcMaterialLayerSetUsage)ifcElement.MaterialSelect; //foreach(IfcMaterialLayer ml in mlsu.ForLayerSet.MaterialLayers) IfcMaterialLayerSet mls = mlsu.ForLayerSet; for (int i = 0; i < mls.MaterialLayers.Count; i++) { ifcEntity.Material.Add(i + " " + mls.MaterialLayers[i].Material.Name, mls.MaterialLayers[i].LayerThickness); IfcMaterial ifcMaterial = mls.MaterialLayers[i].Material; if (ifcMaterial.HasRepresentation != null) { IfcMaterialDefinitionRepresentation imdr = ifcMaterial.HasRepresentation; foreach (IfcStyledRepresentation isr in imdr.Representations) { foreach (IfcStyledItem isi in isr.Items) { foreach (IfcPresentationStyleAssignment isas in isi.Styles) // se c'e' presentatio style direttamente { foreach (IfcPresentationStyle ips in isas.Styles) { if (ips is IfcSurfaceStyle) { IfcSurfaceStyle iss = (IfcSurfaceStyle)ips; foreach (var item in iss.Styles) { // vedere IFcSurfaceStyleElementSelect if (item is IfcSurfaceStyleRendering) { IfcSurfaceStyleRendering issr = (IfcSurfaceStyleRendering)item; int alpha = Convert.ToInt32((1 - issr.Transparency) * 255); ifcEntity.Color = Color.FromArgb(alpha, issr.SurfaceColour.Colour); ifcEntity.Identification.Add(i + "C" + mls.MaterialLayers[i].Material.Name, issr.SurfaceColour.Colour.ToString()); } } } else if (ips is IfcCurveStyle) { //ddgfdg } } } //IfcStyledItem ifcStyledItem = reprItem.mStyledByItem; //IfcStyleAssignmentSelect sas = (IfcPresentationStyleAssignment)ifcStyledItem.Styles[0]; //IfcSurfaceStyle ss = (IfcSurfaceStyle)sas.Styles[0]; //IfcSurfaceStyleRendering ssr = (IfcSurfaceStyleRendering)ss.Styles[0]; //color = ssr.SurfaceColour.Colour; } } } } } } } #endregion if (ifcEntity.Color == Color.Black) { Color color; if (defaultColor.TryGetValue(ifcProduct.KeyWord, out color)) { ifcEntity.Color = color; } //else //Debug.Write(ifcElement.KeyWord + " default color not set\n"); } }
internal static void GenerateInstance(IfcBuilding building, bool openings) { DatabaseIfc db = building.Database; IfcMaterial concrete = new IfcMaterial(db, "Concrete") { Category = "Concrete" }; int thickness = 200; IfcMaterialLayer materialLayer = new IfcMaterialLayer(concrete, thickness, "Core"); string name = thickness + "mm Concrete"; IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(materialLayer, name); db.NextObjectRecord = 300; IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR); db.Context.AddDeclared(slabType); List <Coord2d> points = new List <Coord2d>() { new Coord2d(0, 0), new Coord2d(1000, 0), new Coord2d(1400, 2000), new Coord2d(1000, 4000), new Coord2d(0, 4000), new Coord2d(-400, 2000) }; List <IfcSegmentIndexSelect> segments = new List <IfcSegmentIndexSelect>(); segments.Add(new IfcLineIndex(1, 2)); segments.Add(new IfcArcIndex(2, 3, 4)); segments.Add(new IfcLineIndex(4, 5)); segments.Add(new IfcArcIndex(5, 6, 1)); IfcBoundedCurve boundedCurve = IfcBoundedCurve.Generate(db, points, segments); IfcMaterialLayerSetUsage layerSetUsage = new IfcMaterialLayerSetUsage(materialLayerSet, IfcLayerSetDirectionEnum.AXIS3, IfcDirectionSenseEnum.NEGATIVE, 0); IfcSlab slabStandardCase = new IfcSlabStandardCase(building, layerSetUsage, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcArbitraryClosedProfileDef("Slab Perimeter", boundedCurve)) { RelatingType = slabType }; slabStandardCase.RelatingType = slabType; if (openings) { IfcCircleProfileDef cpd = new IfcCircleProfileDef(db, "100DIA", 50); IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 100, 300, -200)), new IfcDirection(db, 0, 0, 1), thickness); IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas) { Name = "Opening" }; IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(db, "RecessRectangle", 500, 1000); eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 500, 1000, -50)), new IfcDirection(db, 0, 0, 1), 50); IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(eas))) { Name = "Recess", PredefinedType = IfcOpeningElementTypeEnum.RECESS }; //Unique ids assigned to generate constant IfcScript sample files, remove otherwise opening.GlobalId = "15RSTHd8nFVQWMRE7og7sd"; opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO"; recess.GlobalId = "0w93HZ19H2D99zbAVNb4o2"; recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM"; } //Unique ids assigned to generate constant IfcScript sample files, remove otherwise slabType.GlobalId = "0RSW$KKbzCZ9QaSm3GoEan"; slabStandardCase.GlobalId = "1wAj$J2Az2V8wnBiVYd3bU"; materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq"; slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0"; slabStandardCase.MaterialSelect.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w"; }
/// <summary> /// Set Material set usage with typical values and creates it if it doesn't exist. /// LayerSetDirection = IfcLayerSetDirectionEnum.AXIS1 /// DirectionSense = IfcDirectionSenseEnum.POSITIVE /// OffsetFromReferenceLine = 0 /// </summary> /// <param name = "forLayerSet">Material layer set for the usage</param> public static void SetTypicalMaterialLayerSetUsage(this IfcWall wall, IfcMaterialLayerSet forLayerSet) { wall.SetMaterialLayerSetUsage(forLayerSet, IfcLayerSetDirectionEnum.AXIS1, IfcDirectionSenseEnum.POSITIVE, 0); }
static IfcMaterial extractMaterial(IfcMaterialSelect materialSelect) //To be enabled in opensource Library { IfcMaterial material = materialSelect as IfcMaterial; if (material != null) { return(material); } IfcMaterialProfile profile = materialSelect as IfcMaterialProfile; if (profile != null) { return(profile.Material); } IfcMaterialProfileSet profileSet = materialSelect as IfcMaterialProfileSet; if (profileSet == null) { IfcMaterialProfileSetUsage profileUsage = materialSelect as IfcMaterialProfileSetUsage; if (profileUsage != null) { profileSet = profileUsage.ForProfileSet; } } if (profileSet != null) { return(profileSet.PrimaryMaterial); } IfcMaterialLayer layer = materialSelect as IfcMaterialLayer; if (layer != null) { return(layer.Material); } IfcMaterialLayerSet layerSet = materialSelect as IfcMaterialLayerSet; if (layerSet != null) { return(layerSet.PrimaryMaterial); } IfcMaterialLayerSetUsage layerSetUsage = materialSelect as IfcMaterialLayerSetUsage; if (layerSetUsage != null) { return(layerSetUsage.PrimaryMaterial); } IfcMaterialList list = materialSelect as IfcMaterialList; if (list != null) { return(list.PrimaryMaterial); } IfcMaterialConstituent constituent = materialSelect as IfcMaterialConstituent; if (constituent != null) { return(constituent.PrimaryMaterial); } IfcMaterialConstituentSet constituentSet = materialSelect as IfcMaterialConstituentSet; if (constituentSet != null) { return(constituentSet.PrimaryMaterial); } return(null); }
private static void AdjustExtrusion(XbimModel model, IfcExtrudedAreaSolid body, HndzStructuralElement genericProducthndz, IfcProduct genericProductIfc) { IfcCartesianPoint axisOrigin = model.Instances.New <IfcCartesianPoint>(); axisOrigin.SetXYZ(0, 0, 0); IfcCartesianPoint elementStartPoint = model.Instances.New <IfcCartesianPoint>(); elementStartPoint.SetXYZ(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y, genericProducthndz.ExtrusionLine.baseNode.Point.Z); //insert at arbitrary position//****************Need Revision body.Depth = genericProducthndz.ExtrusionLine.RhinoLine.Length; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //parameters to insert the geometry in the model body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = axisOrigin; //body.Position.RefDirection = model.Instances.New<IfcDirection>(); //body.Position.RefDirection.SetXYZ(1, 0, 0); //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); shape.ContextOfItems = model.IfcProject.ModelContext(); shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add(shape); genericProductIfc.Representation = rep; //now place the wall into the model #region ProfileVectorDir. Vector3d perpendicularVector = new Vector3d(genericProducthndz.Profile.OrientationInPlane.X, genericProducthndz.Profile.OrientationInPlane.Y, 0); Plane extrusionPlane; bool aa = genericProducthndz.ExtrusionLine.RhinoLine.TryGetPlane(out extrusionPlane); if (aa) { perpendicularVector = extrusionPlane.ZAxis; } // Vector3d elementDirection = genericProducthndz.ExtrusionLine.RhinoLine.Direction; //Plane profilePlane = new Plane(genericProducthndz.ExtrusionLine.baseNode.Point, elementDirection); // Vector3d profileXdirection = profilePlane.XAxis; #endregion IfcLocalPlacement lp = model.Instances.New <IfcLocalPlacement>(); IfcAxis2Placement3D ax3D = model.Instances.New <IfcAxis2Placement3D>(); ax3D.Location = elementStartPoint; ax3D.RefDirection = model.Instances.New <IfcDirection>(); ax3D.RefDirection.SetXYZ(perpendicularVector.X, perpendicularVector.Y, perpendicularVector.Z); //Y-Axis //ax3D.RefDirection.SetXYZ(0, 1, 0); //Y-Axis ax3D.Axis = model.Instances.New <IfcDirection>(); ax3D.Axis.SetXYZ(genericProducthndz.ExtrusionLine.RhinoLine.Direction.X, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Y, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Z); //Z-Axis //XbimVector3D X_Dir = new XbimVector3D(extrusionPlane.XAxis.X, extrusionPlane.XAxis.Y, extrusionPlane.XAxis.Z); //XbimVector3D Y_Dir = new XbimVector3D(extrusionPlane.YAxis.X, extrusionPlane.YAxis.Y, extrusionPlane.YAxis.Z); //XbimVector3D Z_Dir = new XbimVector3D(extrusionPlane.ZAxis.X, extrusionPlane.ZAxis.Y, extrusionPlane.ZAxis.Z); //ax3D.P.Insert(0,X_Dir); //ax3D.P.Insert(1,Y_Dir); //ax3D.P.Insert(2,Z_Dir); lp.RelativePlacement = ax3D; genericProductIfc.ObjectPlacement = lp; // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>(); IfcMaterialLayerSet ifcMaterialLayerSet = model.Instances.New <IfcMaterialLayerSet>(); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(); ifcMaterialLayer.LayerThickness = 10; ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer); ifcMaterialLayerSetUsage.ForLayerSet = ifcMaterialLayerSet; ifcMaterialLayerSetUsage.LayerSetDirection = IfcLayerSetDirectionEnum.AXIS2; ifcMaterialLayerSetUsage.DirectionSense = IfcDirectionSenseEnum.NEGATIVE; ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150; // Add material to wall IfcMaterial material = model.Instances.New <IfcMaterial>(); material.Name = "STEEL"; IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>(); ifcRelAssociatesMaterial.RelatingMaterial = material; ifcRelAssociatesMaterial.RelatedObjects.Add(genericProductIfc); ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage; // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>(); ifcPresentationLayerAssignment.Name = "HANDZteel Assignment"; ifcPresentationLayerAssignment.AssignedItems.Add(shape); // linear segment as IfcPolyline with two points is required for IfcWall IfcPolyline ifcPolyline = model.Instances.New <IfcPolyline>(); IfcCartesianPoint startPoint = model.Instances.New <IfcCartesianPoint>(); startPoint.SetXY(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y); IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>(); endPoint.SetXY(genericProducthndz.ExtrusionLine.EndNode.Point.X, genericProducthndz.ExtrusionLine.EndNode.Point.Y); ifcPolyline.Points.Add(startPoint); ifcPolyline.Points.Add(endPoint); IfcShapeRepresentation shape2D = model.Instances.New <IfcShapeRepresentation>(); shape2D.ContextOfItems = model.IfcProject.ModelContext(); shape2D.RepresentationIdentifier = "Axis"; shape2D.RepresentationType = "Curve2D"; shape2D.Items.Add(ifcPolyline); rep.Representations.Add(shape2D); }
/// <summary> /// This creates a wall and it's geometry, many geometric representations are possible and extruded rectangular footprint is chosen as this is commonly used for standard case walls /// </summary> /// <param name="model"></param> /// <param name="length">Length of the rectangular footprint</param> /// <param name="width">Width of the rectangular footprint (width of the wall)</param> /// <param name="height">Height to extrude the wall, extrusion is vertical</param> /// <returns></returns> private IfcWallStandardCase CreateWall(XbimModel model, double length, double width, double height) { // //begin a transaction using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Wall")) { IfcWallStandardCase wall = model.Instances.New <IfcWallStandardCase>(); wall.Name = "A Standard rectangular wall"; // required parameters for IfcWall wall.OwnerHistory.OwningUser = model.DefaultOwningUser; wall.OwnerHistory.OwningApplication = model.DefaultOwningApplication; //represent wall as a rectangular profile IfcRectangleProfileDef rectProf = model.Instances.New <IfcRectangleProfileDef>(); rectProf.ProfileType = IfcProfileTypeEnum.AREA; rectProf.XDim = width; rectProf.YDim = length; IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>(); insertPoint.SetXY(0, 400); //insert at arbitrary position rectProf.Position = model.Instances.New <IfcAxis2Placement2D>(); rectProf.Position.Location = insertPoint; //model as a swept area solid IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = height; body.SweptArea = rectProf; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //parameters to insert the geometry in the model IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>(); origin.SetXYZ(0, 0, 0); body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = origin; //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); shape.ContextOfItems = model.IfcProject.ModelContext(); shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add_Reversible(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add_Reversible(shape); wall.Representation = rep; //now place the wall into the model IfcLocalPlacement lp = model.Instances.New <IfcLocalPlacement>(); IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>(); ax3d.Location = origin; ax3d.RefDirection = model.Instances.New <IfcDirection>(); ax3d.RefDirection.SetXYZ(0, 1, 0); ax3d.Axis = model.Instances.New <IfcDirection>(); ax3d.Axis.SetXYZ(0, 0, 1); lp.RelativePlacement = ax3d; wall.ObjectPlacement = lp; // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>(); IfcMaterialLayerSet ifcMaterialLayerSet = model.Instances.New <IfcMaterialLayerSet>(); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(); ifcMaterialLayer.LayerThickness = 10; ifcMaterialLayerSet.MaterialLayers.Add_Reversible(ifcMaterialLayer); ifcMaterialLayerSetUsage.ForLayerSet = ifcMaterialLayerSet; ifcMaterialLayerSetUsage.LayerSetDirection = IfcLayerSetDirectionEnum.AXIS2; ifcMaterialLayerSetUsage.DirectionSense = IfcDirectionSenseEnum.NEGATIVE; ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150; // Add material to wall IfcMaterial material = model.Instances.New <IfcMaterial>(); material.Name = "some material"; IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>(); ifcRelAssociatesMaterial.RelatingMaterial = material; ifcRelAssociatesMaterial.RelatedObjects.Add_Reversible(wall); ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage; // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>(); ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment"; ifcPresentationLayerAssignment.AssignedItems.Add(shape); // linear segment as IfcPolyline with two points is required for IfcWall IfcPolyline ifcPolyline = model.Instances.New <IfcPolyline>(); IfcCartesianPoint startPoint = model.Instances.New <IfcCartesianPoint>(); startPoint.SetXY(0, 0); IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>(); endPoint.SetXY(4000, 0); ifcPolyline.Points.Add_Reversible(startPoint); ifcPolyline.Points.Add_Reversible(endPoint); IfcShapeRepresentation shape2d = model.Instances.New <IfcShapeRepresentation>(); shape2d.ContextOfItems = model.IfcProject.ModelContext(); shape2d.RepresentationIdentifier = "Axis"; shape2d.RepresentationType = "Curve2D"; shape2d.Items.Add_Reversible(ifcPolyline); rep.Representations.Add_Reversible(shape2d); //validate write any errors to the console and commit if ok, otherwise abort if (model.Validate(txn.Modified(), Console.Out) == 0) { txn.Commit(); return(wall); } } return(null); }