internal static void GenerateInstance(IfcBuilding building, bool assembly) { DatabaseIfc db = building.Database; IfcDocumentReference documentReference = new IfcDocumentReference(db) { Name = "MyReinforcementCode", Identification = "MyCodeISO3766" }; IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(db.Project, documentReference) { GlobalId = "1R7R97$uLAAv4wci$KGwn8" }; IfcMaterial material = new IfcMaterial(db, "ReinforcingSteel"); List <Tuple <double, double, double> > points = new List <Tuple <double, double, double> >() { new Tuple <double, double, double>(-69.0, 0.0, -122.0), new Tuple <double, double, double>(-69.0, 0.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 0.0, -31.0), new Tuple <double, double, double>(21.0, 0.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 0.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 0.00000000000000089, -321.0), new Tuple <double, double, double>(54.9939785957165, 1.21791490472034, -354.941125496954), new Tuple <double, double, double>(21.1804517666074, 4.15822158551252, -369.0), new Tuple <double, double, double>(-20.6616529376114, 7.79666547283599, -369.0), new Tuple <double, double, double>(-54.4751797667207, 10.7369721536282, -354.941125496954), new Tuple <double, double, double>(-68.4812011710042, 11.9548870583485, -321.0), new Tuple <double, double, double>(-69.0, 12.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 12.0, -31.0), new Tuple <double, double, double>(21.0, 12.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 12.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 12.0, -122.0), }; IfcBoundedCurve directrix = null; if (db.Release == ReleaseVersion.IFC2x3) { directrix = new IfcPolyline(db, points); } else { 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, 7)); segments.Add(new IfcLineIndex(7, 8)); segments.Add(new IfcArcIndex(8, 9, 10)); segments.Add(new IfcLineIndex(10, 11)); segments.Add(new IfcArcIndex(11, 12, 13)); segments.Add(new IfcLineIndex(13, 14)); segments.Add(new IfcArcIndex(14, 15, 16)); segments.Add(new IfcLineIndex(16, 17)); segments.Add(new IfcArcIndex(17, 18, 19)); segments.Add(new IfcLineIndex(19, 20)); directrix = new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, points), segments); } double barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4; IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter / 2.0); IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid); string shapeCode = ""; //Todo IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(db, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null) { GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material }; reinforcingBarType.RepresentationMaps.Add(representationMap); db.Context.AddDeclared(reinforcingBarType); if (assembly) { IfcMaterial concrete = new IfcMaterial(db, "Concrete") { Category = "Concrete" }; string name = "400x200RC"; IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, name, 200, 400); IfcMaterialProfile materialProfile = new IfcMaterialProfile(name, concrete, rectangleProfileDef); IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM); db.Context.AddDeclared(beamType); IfcMaterialProfileSet materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet; IfcBeam beam = new IfcBeam(building, new IfcLocalPlacement(building.Placement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), null) { Description = "Reinforced Beam" }; IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(beam, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.TOPMID), new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 0, 1, 0), new IfcDirection(db, -1, 0, 0)), 5000) { GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut", RelatingType = beamType }; IfcElementAssembly elementAssembly = new IfcElementAssembly(beam, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT); List <string> ids = new List <string>() { "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW" }; int jcounter = 0; for (int icounter = 25; icounter < 5000; icounter += 150) { IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new IfcCartesianTransformationOperator3D(db) { LocalOrigin = new IfcCartesianPoint(db, 0, icounter, 0) }); //Unique ids assigned to generate constant IfcScript sample files, remove otherwise element.GlobalId = ids[jcounter++]; } //Unique ids assigned to generate constant IfcScript sample files, remove otherwise beam.GlobalId = "1_KSmTR8T8bO37iRs24GkM"; beamType.GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q"; beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg"; beamType.MaterialSelect.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9"; beamStandardCase.MaterialSelect.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY"; elementAssembly.GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h"; elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU"; beam.IsDecomposedBy[0].GlobalId = "1b1SnKocD0WRevlg8Aqhj5"; } else { IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db)); //Unique ids assigned to generate constant IfcScript sample files, remove otherwise element.GlobalId = "0WUveBtSTDbunNjDLsuRn$"; } //Unique ids assigned to generate constant IfcScript sample files, remove otherwise reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j"; reinforcingBarType.MaterialSelect.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6"; }
internal static DatabaseIfc Generate(ModelView mdv, string path) { DatabaseIfc db = new DatabaseIfc(true, mdv); //IfcGeometricRepresentationContext //IfcCartesianPoint //IfcAxis2Placement3D //IfcDirection //IfcAxis2Placement2D //IfcSIUnit //IfcLocalPlacement IfcSite site = new IfcSite(db, "TestSite"); //IfcPerson NOT RV //IfcOrganization NOT RV //IfcPersonAndOrganization NOT RV //IfcOwnerHistory NOT RV //fcApplication NOT RV // IfcProjectLibrary NOT RV Can't have multiple context IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre) { }; //IfcUnitAssignment //IfcRelAggregates IfcBuilding building = new IfcBuilding(site, "TestBuilding") { }; IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 3000); IfcSpace space = new IfcSpace(buildingStorey, null, null) { Name = "TestSpace" }; space.RelatingType = new IfcSpaceType(db, "TestSpaceType", IfcSpaceTypeEnum.INTERNAL); IfcZone zone = new IfcZone(buildingStorey, "TestZone", "TestZoneLongName", new List <IfcSpace>() { space }); IfcLocalPlacement localPlacement = buildingStorey.Placement as IfcLocalPlacement; IfcMaterial material = new IfcMaterial(db, "TestMaterial") { Description = "TestDescription", Category = "TestCategory" }; IfcMaterialProperties materialProperties = new IfcMaterialProperties("TestMaterialProperties", material); materialProperties.AddProperty(new IfcPropertySingleValue(db, "MassDensity", new IfcMassDensityMeasure(1))); IfcSurfaceStyleShading surfaceStyleShading = new IfcSurfaceStyleShading(new IfcColourRgb(db, 1, 0, 0) { Name = "Red" }); IfcSurfaceStyle surfaceStyle = new IfcSurfaceStyle(surfaceStyleShading, null, null, null, null); IfcMaterialDefinitionRepresentation materialDefinitionRepresentation = new IfcMaterialDefinitionRepresentation(new IfcStyledRepresentation(new IfcStyledItem(surfaceStyle) { Name = "TestStyledItem" }), material); IfcIndexedPolyCurve indexedPolyCurve = IPE200Curve(db); IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", indexedPolyCurve); IfcMaterialProfile materialProfile = new IfcMaterialProfile("TestMaterialProfile", material, arbitraryClosedProfileDef); IfcMaterialProfileSet materialProfileSet = new IfcMaterialProfileSet("TestMaterialProfileSet", materialProfile); IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 1, 0, 0), new IfcDirection(db, 0, 1, 0)), new IfcDirection(db, 0, 0, 1), 5000); IfcBeamType beamType = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM); beamType.MaterialSelect = materialProfileSet; IfcBeam beam = new IfcBeam(buildingStorey, new IfcLocalPlacement(localPlacement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 2000, 0)) { RefDirection = new IfcDirection(db, 0, 1, 0) }), new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid))); //IfcGeometricRepresentationSubContext beam.RelatingType = beamType; //IfcRelDefinesByType // if(mdv != ModelView.Ifc4Reference) // IfcActorRole NOT RV //IfcActuator //IfcActuatorType //IfcAdvancedBrep NOT RV //IfcAdvancedFace NOT RV //IfcAirTerminal //IfcAirTerminalBox //IfcAirTerminalBoxType //IfcAirTerminalType //IfcAirToAirHeatRecovery //IfcAirToAirHeatRecoveryType //IfcAlarm //IfcAlarmType //IfcArbitraryOpenProfileDef //IfcArbitraryProfileDefWithVoids //IfcAsymmetricIShapeProfileDef NOT RV //IfcAudioVisualAppliance //IfcAudioVisualApplianceType //IfcAxis1Placement //IfcBeamStandardCase NOT RV //IfcBlock NOT RV //IfcBoiler //IfcBoilerType //IfcBooleanClippingResult NOT RV //IfcBooleanResult NOT RV //IfcBSplineCurveWithKnots NOT RV //IfcBSplineSurface NOT RV //IfcBSplineSurfaceWithKnots NOT RV //IfcBuildingElementPart //IfcBuildingElementPartType //IfcBuildingElementProxy //IfcBuildingElementProxyType //IfcBuildingSystem //IfcBurner //IfcBurnerType //IfcCableCarrierFitting //IfcCableCarrierFittingType //IfcCableCarrierSegment //IfcCableCarrierSegmentType //IfcCableFitting //IfcCableFittingType //IfcCableSegment //IfcCableSegmentType //IfcCartesianPointList2D //IfcCartesianPointList3D //IfcCartesianTransformationOperator2D //IfcCartesianTransformationOperator2DnonUniform //IfcCartesianTransformationOperator3D //IfcCartesianTransformationOperator3DnonUniform //IfcCenterLineProfileDef //IfcChiller //IfcChillerType //IfcChimney //IfcChimneyType //IfcCircle //IfcCircleHollowProfileDef NOT RV //IfcCircleProfileDef NOT RV //IfcCivilElement //IfcCivilElementType //IfcClassification //IfcClassificationReference //IfcClosedShell //IfcCoil //IfcCoilType //IfcColourRgbList //IfcColourSpecification //IfcColumn //IfcColumnStandardCase NOT RV //IfcColumnType //IfcCommunicationsAppliance //IfcCommunicationsApplianceType //IfcComplexProperty //IfcCompositeProfileDef NOT RV //IfcCompressor //IfcCompressorType //IfcCondenser //IfcCondenserType //IfcConnectedFaceSet NOT RV //IfcConnectionCurveGeometry NOT RV //IfcConnectionVolumeGeometry NOT RV //IfcController //IfcControllerType //IfcConversionBasedUnit //IfcConversionBasedUnitWithOffset //IfcCooledBeam //IfcCooledBeamType //IfcCoolingTower //IfcCoolingTowerType //IfcCovering //IfcCoveringType //IfcCsgSolid NOT RV //IfcCShapeProfileDef NOT RV //IfcCurtainWall //IfcCurtainWallType //IfcCurveStyle //IfcCurveStyleFont //IfcCurveStyleFontPattern //IfcDamper //IfcDamperType //IfcDerivedProfileDef NOT RV //IfcDerivedUnit //IfcDerivedUnitElement //IfcDimensionalExponents //IfcDiscreteAccessory //IfcDiscreteAccessoryType //IfcDistributionChamberElement //IfcDistributionChamberElementType //IfcDistributionCircuit //IfcDistributionControlElement //IfcDistributionControlElementType //IfcDistributionElement //IfcDistributionElementType //IfcDistributionFlowElement //IfcDistributionFlowElementType //IfcDistributionPort //IfcDistributionSystem //IfcDocumentReference //IfcDoor //IfcDoorLiningProperties //IfcDoorPanelProperties //IfcDoorStandardCase NOT RV //IfcDoorType //IfcDuctFitting //IfcDuctFittingType //IfcDuctSegment //IfcDuctSegmentType //IfcDuctSilencer //IfcDuctSilencerType //IfcEdge NOT RV //IfcEdgeCurve NOT RV //IfcEdgeLoop NOT RV //IfcElectricAppliance //IfcElectricApplianceType //IfcElectricDistributionBoard //IfcElectricDistributionBoardType //IfcElectricFlowStorageDevice //IfcElectricFlowStorageDeviceType //IfcElectricGenerator //IfcElectricGeneratorType //IfcElectricMotor //IfcElectricMotorType //IfcElectricTimeControl //IfcElectricTimeControlType //IfcElementAssembly //IfcElementAssemblyType //IfcElementComponent //IfcElementComponentType //IfcElementQuantity //IfcEllipseProfileDef NOT RV //IfcEnergyConversionDevice //IfcEnergyConversionDeviceType //IfcEngine //IfcEngineType //IfcEvaporativeCooler //IfcEvaporativeCoolerType //IfcEvaporator //IfcEvaporatorType //IfcExtendedProperties //IfcExternalInformation //IfcExternalReference //IfcExtrudedAreaSolidTapered NOT RV //IfcFace NOT RV //IfcFaceBasedSurfaceModel NOT RV //IfcFaceBound NOT RV //IfcFaceOuterBound NOT RV //IfcFaceSurface NOT RV //IfcFacetedBrep NOT RV //IfcFan //IfcFanType //IfcFastener //IfcFastenerType //IfcFeatureElement //IfcFeatureElementAddition NOT RV //IfcFeatureElementSubtraction //IfcFillAreaStyle //IfcFillAreaStyleHatching //IfcFilter //IfcFilterType //IfcFireSuppressionTerminal //IfcFireSuppressionTerminalType //IfcFixedReferenceSweptAreaSolid NOT RV //IfcFlowController //IfcFlowControllerType //IfcFlowFitting //IfcFlowFittingType //IfcFlowInstrument //IfcFlowInstrumentType //IfcFlowMeter //IfcFlowMeterType //IfcFlowMovingDevice //IfcFlowMovingDeviceType //IfcFlowSegment //IfcFlowSegmentType //IfcFlowStorageDevice //IfcFlowStorageDeviceType //IfcFlowTerminal //IfcFlowTerminalType //IfcFlowTreatmentDevice //IfcFlowTreatmentDeviceType //IfcFooting //IfcFootingType //IfcFurnishingElement //IfcFurnishingElementType //IfcFurniture //IfcFurnitureType //IfcGeographicElement //IfcGeographicElementType //IfcGeometricCurveSet //IfcGeometricSet //IfcGrid //IfcGridAxis //IfcGridPlacement NOT RV //IfcGroup //IfcHalfSpaceSolid NOT RV //IfcHeatExchanger //IfcHeatExchangerType //IfcHumidifier //IfcHumidifierType //IfcIndexedColourMap //IfcIndexedTextureMap //IfcIndexedTriangleTextureMap //IfcInterceptor //IfcInterceptorType //IfcIShapeProfileDef //IfcJunctionBox //IfcJunctionBoxType //IfcLamp //IfcLampType //IfcLibraryInformation NOT RV //IfcLibraryReference NOT RV //IfcLightFixture //IfcLightFixtureType //IfcLine //IfcLoop NOT RV //IfcLShapeProfileDef NOT RV //IfcMapConversion //IfcMappedItem //IfcMaterialConstituent //IfcMaterialConstituentSet //IfcMaterialLayer //IfcMaterialLayerSet //IfcMaterialLayerSetUsage NOT RV //IfcMaterialLayerWithOffsets NOT RV //IfcMaterialProfileSetUsage NOT RV //IfcMaterialProfileSetUsageTapering NOT RV //IfcMaterialProfileWithOffsets NOT RV //IfcMaterialUsageDefinition NOT RV //IfcMeasureWithUnit //IfcMechanicalFastener //IfcMechanicalFastenerType //IfcMedicalDevice //IfcMedicalDeviceType //IfcMember //IfcMemberStandardCase NOT RV //IfcMemberType //IfcMonetaryUnit //IfcMotorConnection //IfcMotorConnectionType //IfcNamedUnit //IfcOpeningElement //IfcOpeningStandardCase NOT RV //IfcOpenShell NOT RV //IfcOrientedEdge NOT RV //IfcOutlet //IfcOutletType //IfcPcurve NOT RV //IfcPhysicalComplexQuantity //IfcPhysicalQuantity //IfcPhysicalSimpleQuantity //IfcPile //IfcPileType //IfcPipeFitting //IfcPipeFittingType //IfcPipeSegment //IfcPipeSegmentType //IfcPlane NOT RV //IfcPlate //IfcPlateStandardCase NOT RV //IfcPlateType //IfcPoint //IfcPolygonalBoundedHalfSpace NOT RV //IfcPolyline NOT RV //IfcPolyLoop NOT RV //IfcPort //IfcPostalAddress //IfcPreDefinedPropertySet //IfcPresentationItem //IfcPresentationLayerAssignment //IfcPresentationStyle //IfcPresentationStyleAssignment //IfcProductDefinitionShape //IfcProductRepresentation //IfcProfileDef //IfcProfileProperties //IfcProjectedCRS //IfcProjectionElement NOT RV //IfcProperty //IfcPropertyAbstraction //IfcPropertyBoundedValue //IfcPropertyDefinition //IfcPropertyEnumeratedValue //IfcPropertyEnumeration //IfcPropertyListValue //IfcPropertySet //IfcPropertySetTemplate NOT RV //IfcPropertyTableValue //IfcPropertyTemplate NOT RV //IfcPropertyTemplateDefinition NOT RV //IfcProtectiveDevice //IfcProtectiveDeviceTrippingUnit //IfcProtectiveDeviceTrippingUnitType //IfcProtectiveDeviceType //IfcPump //IfcPumpType //IfcQuantityArea //IfcQuantityCount //IfcQuantityLength //IfcQuantitySet //IfcQuantityTime //IfcQuantityVolume //IfcQuantityWeight //IfcRailing //IfcRailingType //IfcRamp //IfcRampFlight //IfcRampFlightType //IfcRampType //IfcRectangleHollowProfileDef NOT RV //IfcRectangleProfileDef NOT RV //IfcRectangularPyramid NOT RV //IfcReinforcingBar //IfcReinforcingBarType //IfcReinforcingElement //IfcReinforcingElementType //IfcReinforcingMesh //IfcReinforcingMeshType //IfcRelAssignsToGroup //IfcRelAssociatesClassification //IfcRelAssociatesDocument //IfcRelAssociatesLibrary NOT RV //IfcRelAssociatesMaterial //IfcRelConnectsElements NOT RV //IfcRelConnectsPathElements NOT RV //IfcRelConnectsPorts //IfcRelConnectsWithRealizingElements NOT RV //IfcRelContainedInSpatialStructure //IfcRelCoversBldgElements //IfcRelDeclares //IfcRelDefinesByProperties //IfcRelFillsElement //IfcRelFlowControlElements NOT RV //IfcRelInterferesElements NOT RV //IfcRelNests //IfcRelProjectsElement NOT RV //IfcRelServicesBuildings //IfcRelVoidsElement //IfcRepresentation //IfcRepresentationContext //IfcRepresentationItem //IfcRepresentationMap //IfcRevolvedAreaSolid //IfcRevolvedAreaSolidTapered NOT RV //IfcRightCircularCone NOT RV //IfcRightCircularCylinder NOT RV //IfcRoof //IfcRoofType //IfcRoundedRectangleProfileDef NOT RV //IfcSanitaryTerminal //IfcSanitaryTerminalType //IfcSensor //IfcSensorType //IfcShadingDevice //IfcShadingDeviceType //IfcShapeRepresentation //IfcShellBasedSurfaceModel NOT RV //IfcSimplePropertyTemplate NOT RV //IfcSlab //IfcSlabElementedCase NOT RV //IfcSlabStandardCase NOT RV //IfcSlabType //IfcSolarDevice //IfcSolarDeviceType //IfcSpaceHeater //IfcSpaceHeaterType //IfcSpatialZone //IfcSpatialZoneType //IfcSphere NOT RV //IfcStackTerminal //IfcStackTerminalType //IfcStair //IfcStairFlight //IfcStairFlightType //IfcStairType //IfcStyleModel //IfcSurface NOT RV //IfcSurfaceCurveSweptAreaSolid NOT RV //IfcSurfaceOfLinearExtrusion NOT RV //IfcSurfaceOfRevolution NOT RV //IfcSurfaceStyleRendering //IfcSurfaceStyleWithTextures surfaceStyleWithTextures = new IfcSurfaceStyleWithTextures(new IfcImageTexture(db,true,true,"")); //IfcSweptDiskSolid //IfcSwitchingDevice //IfcSwitchingDeviceType //IfcSystemFurnitureElement //IfcSystemFurnitureElementType //IfcTank //IfcTankType //IfcTelecomAddress NOT RV //IfcTendon //IfcTendonAnchor //IfcTendonAnchorType //IfcTendonType //IfcTessellatedFaceSet //IfcTessellatedItem //IfcTextureCoordinate //IfcTextureVertexList //IfcTransformer //IfcTransformerType //IfcTransportElement //IfcTransportElementType //IfcTriangulatedFaceSet //IfcTrimmedCurve //IfcTShapeProfileDef NOT RV //IfcTubeBundle //IfcTubeBundleType //IfcUnitaryControlElement //IfcUnitaryControlElementType //IfcUnitaryEquipment //IfcUnitaryEquipmentType //IfcUShapeProfileDef NOT RV //IfcValve //IfcValveType //IfcVector //IfcVertex NOT RV //IfcVertexPoint NOT RV //IfcVibrationIsolator //IfcVibrationIsolatorType //IfcVirtualGridIntersection NOT RV //IfcWall //IfcWallElementedCase NOT RV //IfcWallStandardCase NOT RV //IfcWallType //IfcWasteTerminal //IfcWasteTerminalType //IfcWindow //IfcWindowLiningProperties //IfcWindowPanelProperties //IfcWindowStandardCase NOT RV //IfcWindowType //IfcZShapeProfileDef NOT RV db.WriteFile(Path.Combine(path, mdv.ToString() + ".ifc")); return(db); }
public static int Main(string[] args) { var returnMessage = (int)ExitCode.Success; var outputElements = new List <JsonIfcElement>(); var pathSource = string.Empty; var pathDest = string.Empty; var activeComptactJson = true; var readVersion = false; var activeFullJson = false; //var SCALE = 1.0; var context = new JsonConversionContext(); JsonProjectIfcElement newProject = null; try { foreach (string arg in args) { if (arg.ToLower().Trim() == "--version") { readVersion = true; } if (arg.ToLower().Trim() == "--indented") { activeComptactJson = false; } if (arg.ToLower().Trim() == "--full") { activeFullJson = true; } if (arg.Substring(0, 2) != "--" && pathSource != string.Empty && pathDest == string.Empty) { pathDest = arg; } if (arg.Substring(0, 2) != "--" && pathSource == string.Empty) { pathSource = arg; } } if (readVersion) { var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Console.WriteLine($"1. ConvertIfc2Json : {version}{Environment.NewLine}(.Net version {typeof(string).Assembly.ImageRuntimeVersion})"); return(returnMessage); } if (File.Exists(pathSource)) { if (pathDest == string.Empty) { pathDest = pathSource + ".json"; } var db = new DatabaseIfc(); IfcProject project; var projectId = ""; var sites = new List <IfcSite>(); var buildings = new List <IfcBuilding>(); try { db = new DatabaseIfc(pathSource); project = db.Project; sites = project.Extract <IfcSite>(); // IFC Project try { if (project.GlobalId != null) { // REVIEW ne semble pas servir //foreach (var unit in project.UnitsInContext.Units) //{ // var u = project.UnitsInContext.Extract<IfcSIUnit>(); // // Console.WriteLine("2." + unit.StepClassName); //} // Computing the json conversion scale from current Geogym project context.SCALE = project.GetJsonConversionScale(); projectId = project.GlobalId; } outputElements.Add(newProject = new JsonProjectIfcElement(project)); } catch (Exception ex) { Console.WriteLine("3. Element read error " + ex.Message); returnMessage = (int)ExitCode.UnknownError; } } catch (Exception ex) { Console.WriteLine("31. Write file : " + ex.Message); returnMessage = (int)ExitCode.InvalidFile; } // IFC Site foreach (var site in sites) { try { if (site.GlobalId != null) { var newSite = new JsonSiteIfcElement(site, newProject, context); outputElements.Add(newSite); // IFC Building buildings = site.Extract <IfcBuilding>(); foreach (var building in buildings) { var newBuildind = new JsonBuildingIfcElement(building, newSite, context); // REVIEW shouldn't create this unused instance if global id is null if (building.GlobalId != null) { outputElements.Add(newBuildind); } // IFC Building Storey // Levels var buildingStoreys = building.Extract <IfcBuildingStorey>(); foreach (var buildingStorey in buildingStoreys) { var storeyElement = new JsonStoreyIfcElement(buildingStorey, newBuildind, context); outputElements.Add(storeyElement); // IFC Space // Rooms var spaces = buildingStorey.Extract <IfcSpace>(); // Check IfcProduct Ids var productsIds = new List <string>(); var productCounter = 0; // IfcProduct var products = buildingStorey.Extract <IfcProduct>(); foreach (var product in products) { try { if (product.GlobalId != null) { var newElementProd = new JsonProductIfcElement(product, storeyElement, context); var spaceCounter = 0; // Link to the Space foreach (var space in spaces) { try { // REVIEW = LatestOrDefault // IfcSpace if (space.GlobalId == product.GlobalId) { try { newElementProd.userData.name = space.LongName; } catch (NotSupportedException exEncode) { newElementProd.userData.name = space.Name; Console.WriteLine("15. Space Name read error (id: " + space.GlobalId + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding; } catch (System.Exception ex) { Console.WriteLine("29. Space Name LongName read error" + ex.Message); } newElementProd.userData.pset.Add("number", space.Name); // Create boundary geoGeometry geom = new geoGeometry(); IList <IList <IList <double> > > coords = new List <IList <IList <double> > >(); Dictionary <string, string> props = new Dictionary <string, string>(); string height = "0.0"; string elevation = "0.0"; // Representation if (space.Representation.Representations.Count > 0) { foreach (IfcRepresentationItem item in space.Representation.Representations[0].Items) { try { if (item.StepClassName == "IfcExtrudedAreaSolid") { IfcExtrudedAreaSolid areaSolid = item as IfcExtrudedAreaSolid; IfcAxis2Placement3D pos = areaSolid.Position; Point3D loc = new Point3D(pos.Location.Coordinates[0], pos.Location.Coordinates[1], pos.Location.Coordinates[2]); height = (areaSolid.Depth / context.SCALE).ToString(); elevation = (buildingStorey.Elevation / context.SCALE).ToString(); if (areaSolid.SweptArea.StepClassName == "IfcArbitraryClosedProfileDef") { // Polyline IfcArbitraryClosedProfileDef arbitraryClosedProfiles = areaSolid.SweptArea as IfcArbitraryClosedProfileDef; IList <IList <double> > polyExt = new List <IList <double> >(); if (arbitraryClosedProfiles.OuterCurve.StepClassName == "IfcIndexedPolyCurve") { IfcIndexedPolyCurve outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve; IfcCartesianPointList2D points = outerCurve.Points as IfcCartesianPointList2D; foreach (double[] pts in points.CoordList) { if (pts.Length >= 2) { try { IList <double> xy = new List <double>(); xy.Add(pts[0] / context.SCALE); xy.Add(pts[1] / context.SCALE); polyExt.Add(xy); } catch (System.Exception exTransf) { Console.WriteLine("6." + exTransf.Message); } } } } else { List <IfcPolyline> poly = arbitraryClosedProfiles.OuterCurve.Extract <IfcPolyline>(); if (poly.Count > 0 && poly[0].Points.Count > 0) { foreach (IfcCartesianPoint pt in poly[0].Points) { if (pt.Coordinates.Count >= 2) { try { IList <double> xy = new List <double>(); xy.Add(pt.Coordinates[0] / context.SCALE); xy.Add(pt.Coordinates[1] / context.SCALE); polyExt.Add(xy); } catch (System.Exception exTransf) { Console.WriteLine("7. " + exTransf.Message); } } } } } coords.Add(polyExt); props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE); if (pos.RefDirection != null) { props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]); } if (pos.Axis != null) { props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]); } } else if (areaSolid.SweptArea.StepClassName == "IfcRectangleProfileDef") // Rectangle { List <IfcRectangleProfileDef> rectangleProfile = areaSolid.SweptArea.Extract <IfcRectangleProfileDef>(); if (rectangleProfile.Count > 0) { if (rectangleProfile[0].XDim > 0.0000001 && rectangleProfile[0].YDim > 0.0000001) { if (rectangleProfile[0].Position.Location.Coordinates.Count >= 2) { try { Point3D lm = new Point3D(0, 0, 0); double XDim = rectangleProfile[0].XDim / 2; double YDim = rectangleProfile[0].YDim / 2; // Left-Bottom IList <double> lb = new List <double>(); Point3D lbP = new Point3D(lm.X - XDim, lm.Y - YDim, lm.Z); lb.Add(lbP.X / context.SCALE); lb.Add(lbP.Y / context.SCALE); // right-Bottom IList <double> rb = new List <double>(); Point3D rbP = new Point3D(lm.X + XDim, lm.Y - YDim, lm.Z); rb.Add(rbP.X / context.SCALE); rb.Add(rbP.Y / context.SCALE); // right-top IList <double> rt = new List <double>(); Point3D rtP = new Point3D(lm.X + XDim, lm.Y + YDim, lm.Z); rt.Add(rtP.X / context.SCALE); rt.Add(rtP.Y / context.SCALE); // left-top IList <double> lt = new List <double>(); Point3D ltP = new Point3D(lm.X - XDim, lm.Y + YDim, lm.Z); lt.Add(ltP.X / context.SCALE); lt.Add(ltP.Y / context.SCALE); IList <IList <double> > polyExt = new List <IList <double> >(); polyExt.Add(lb); polyExt.Add(rb); polyExt.Add(rt); polyExt.Add(lt); polyExt.Add(lb); coords.Add(polyExt); props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE); if (pos.RefDirection != null) { props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]); } if (pos.Axis != null) { props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]); } } catch (System.Exception exMatrixTransf) { Console.WriteLine("8. " + exMatrixTransf.Message); } } } } } else if (areaSolid.SweptArea.StepClassName == "IfcArbitraryProfileDefWithVoids") // { // OuterCurve [IfcCurve] IfcArbitraryProfileDefWithVoids arbitraryProfileDefWithVoids = areaSolid.SweptArea as IfcArbitraryProfileDefWithVoids; IfcArbitraryClosedProfileDef arbitraryClosedProfiles = areaSolid.SweptArea as IfcArbitraryClosedProfileDef; IList <IList <double> > polyExt = new List <IList <double> >(); if (arbitraryProfileDefWithVoids.OuterCurve.StepClassName == "IfcIndexedPolyCurve") { IfcIndexedPolyCurve outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve; IfcCartesianPointList2D points = outerCurve.Points as IfcCartesianPointList2D; foreach (double[] pts in points.CoordList) { if (pts.Length >= 2) { try { IList <double> xy = new List <double>(); xy.Add(pts[0] / context.SCALE); xy.Add(pts[1] / context.SCALE); polyExt.Add(xy); } catch (System.Exception exTransf) { Console.WriteLine("9. " + exTransf.Message); } } } } else { List <IfcPolyline> poly = arbitraryProfileDefWithVoids.OuterCurve.Extract <IfcPolyline>(); foreach (IfcCartesianPoint pt in poly[0].Points) { if (pt.Coordinates.Count >= 2) { try { IList <double> xy = new List <double>(); Point3D p = new Point3D(pt.Coordinates[0], pt.Coordinates[1], 0); xy.Add(p.X / context.SCALE); xy.Add(p.Y / context.SCALE); polyExt.Add(xy); } catch (System.Exception exTransf) { Console.WriteLine("10. " + exTransf.Message); } } } } coords.Add(polyExt); props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE); if (pos.RefDirection != null) { props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]); } if (pos.Axis != null) { props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]); } } } else if (item.StepClassName == "IfcFacetedBrep-XXX") // TODO : Fix export 3D Object { // https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/schema/ifcgeometricmodelresource/lexical/ifcfacetedbrep.htm List <IfcFacetedBrep> facetedBreps = item.Extract <IfcFacetedBrep>(); if (facetedBreps.Count > 0) { IfcFacetedBrep facetedBrep = facetedBreps[0]; elevation = (buildingStorey.Elevation / context.SCALE).ToString(); if (facetedBrep.Outer.StepClassName == "IfcClosedShell") { if (facetedBrep.Outer.CfsFaces.Count > 0) // { // CfsFaces[].Bounds[IfcFaceBound].Bound.Polgon[IfcCartesianPoint].Coordinates[3] // OuterCurve [IfcCurve] foreach (IfcFace cfsFace in facetedBrep.Outer.CfsFaces) { foreach (IfcFaceBound faceBound in cfsFace.Bounds) { IList <IList <double> > polyExt = new List <IList <double> >(); if (faceBound.Bound.StepClassName == "IfcPolyLoop") { IfcPolyLoop polyLoop = faceBound.Bound as IfcPolyLoop; foreach (IfcCartesianPoint pt in polyLoop.Polygon) { IList <double> xy = new List <double>(); xy.Add(pt.Coordinates[0] / context.SCALE); //+ loc.X); xy.Add(pt.Coordinates[1] / context.SCALE); // + loc.Y); xy.Add(pt.Coordinates[2] / context.SCALE); // + loc.YZ; polyExt.Add(xy); } } // ERREUR OBJET 3D // TODO : Fix export 3D Object // coords.Add(polyExt); } } } } } } } catch (System.Exception exRepresentationItem) { Console.WriteLine("11. Element read error exRepresentationItem" + exRepresentationItem.Message); returnMessage = (int)ExitCode.UnknownError; } } } if (coords.Count == 0) { // Console.WriteLine("12. " + coords.Count); } props.Add("height", height); props.Add("elevation", elevation); geom.type = "Polygon"; geom.coordinates = coords; newElementProd.boundary = new geoFeature(); newElementProd.boundary.type = "Feature"; newElementProd.boundary.id = null; newElementProd.boundary.properties = props; newElementProd.boundary.geometry = geom; } var builingElements = space.Extract <IfcBuildingElementProxy>(); // IFC Elements foreach (var bElement in builingElements) { IfcRelContainedInSpatialStructure productIds = bElement.ContainedInStructure; foreach (IfcProduct pId in productIds.RelatedElements) { try { if (pId.GlobalId == product.GlobalId) { newElementProd.userData.spaceId = space.GlobalId; } } catch (System.Exception ex) { Console.WriteLine("13. Element read error" + ex.Message); returnMessage = (int)ExitCode.UnknownError; } } } } catch (Exception ex) { Console.WriteLine("16. Element read error" + ex.Message); returnMessage = (int)ExitCode.UnknownError; } spaceCounter += 1; } // Add to list productsIds.Add(newElementProd.id); if (newElementProd.userData.type != "IfcBuildingStorey") { outputElements.Add(newElementProd); } else { // Console.WriteLine("14. Error IfcBuildingStorey"); } } } catch (NotSupportedException exEncode) { Console.WriteLine("28. Name read error (product counter: " + productCounter + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding; } catch (Exception ex) { Console.WriteLine("29. Element read error" + ex.Message); returnMessage = (int)ExitCode.UnknownError; } productCounter += 1; } // IFC Elements var elements = buildingStorey.Extract <IfcBuildingElementProxy>(); foreach (IfcBuildingElementProxy element in elements .Where(element => element.GlobalId != null && !productsIds.Contains(element.GlobalId))) { try { // Add to list outputElements.Add(new JsonBuildingElementProxyIfcElement(element, storeyElement, context)); } catch (Exception ex) { Console.WriteLine("17. Element read error" + ex.Message); returnMessage = (int)ExitCode.UnknownError; } } } } } } catch (Exception ex) { Console.WriteLine("18. Element read error" + ex.Message); returnMessage = (int)ExitCode.UnknownError; } } // Json Settings Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }; if (activeComptactJson) { if (activeFullJson) { // Original File string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(db.JSON(), Newtonsoft.Json.Formatting.None, jsonSettings); File.WriteAllText(pathDest, jsonFormat); } else { string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.None, jsonSettings); File.WriteAllText(pathDest, jsonFormat); } } else { if (activeFullJson) { // Original File db.WriteFile(pathDest); } else { string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.Indented, jsonSettings); File.WriteAllText(pathDest, jsonFormat); } } } else { returnMessage = (int)ExitCode.InvalidFilename; } } catch (Exception ioEx) { Console.WriteLine("19. " + ioEx.Message); returnMessage = (int)ExitCode.InvalidFile; } Console.WriteLine("20. " + pathDest); return(returnMessage); }