Hi Support.
We are considering licensing aspose.cad in our product to convert IFC files into DXF files.
One thing we need to do is separate the IFC data per storey, either one storey per DXF output file, or at least one layer per storey.
Is this possible?
Thanks,
Dan.
@dlesage
Hi Dan,
Yes, it is possible to separate IFC data by storey when converting to DXF files using Aspose.CAD. You can achieve this by utilizing the IfcBuildingStorey
class, which allows you to access the storey information from the IFC file.
Here’s a clear approach you can follow:
- Load the IFC file: Use Aspose.CAD to load your IFC file.
- Extract Storey Information: Iterate through the elements in the IFC file and filter them based on the
IfcBuildingStorey
entities.
- Create DXF Files: For each storey, create a new DXF file and add the relevant elements to it.
Here’s a minimal code example to get you started:
import com.aspose.cad.fileformats.ifc.ifc2x3.entities.IfcBuildingStorey;
import com.aspose.cad.Image;
import com.aspose.cad.fileformats.dxf.DxfOptions;
public void convertIfcToDxfByStorey(String ifcFilePath) {
// Load the IFC file
List<IfcBuildingStorey> storeys = loadIfcFile(ifcFilePath);
for (IfcBuildingStorey storey : storeys) {
// Create a new DXF file for each storey
String dxfFilePath = "Storey_" + storey.getElevation() + ".dxf";
DxfOptions options = new DxfOptions();
// Add storey elements to the DXF file
addElementsToDxf(storey, dxfFilePath, options);
}
}
Make sure to replace the placeholder methods with your actual implementation for loading the IFC file and adding elements to the DXF.
If you have any further questions or need additional assistance, please feel free to reach out. I’m here to help!
@dlesage,
Hi,
we need to test the feasibility of this, please attach some test file so we can inspect how data are stored there.
I knew about the Storeys property of the IfcImage, my question had more to do with how to implement that “addElementsToDxf” method.
My ultra-simple code was (in C#, but differences are minor):
private void Convert(object sender, EventArgs e)
{
using var ofd = new OpenFileDialog();
ofd.Filter = "ifc files (*.ifc)|*.ifc";
if (ofd.ShowDialog() == DialogResult.OK)
{
var path = ofd.FileName;
var outPath = path.Replace("ifc", "dxf");
using var ifcImage = (IfcImage)Aspose.CAD.Image.Load(path);
var dxfOptions = new DxfOptions();
ifcImage.Save(outPath, dxfOptions);
}
}
And this works a charm, but it spits out a single-layer dxf file containing all storeys.
I guess what I was hoping for was more of a framework where there might be a way to register a callback method that would get called for each ifc element before they are added to the exported file, allowing me to filter out unwanted elements.
@dlesage,
The editing of drawing before export is typically performed with the modifying of Entities collection, but we don’t have this implemented for IfcImage. We have logged CADNET-10205 issue to make this collection editable, so it will be possible to filter it before export.
Thanks. We will keep looking for solutions.
1 Like