IfcSurfaceOfLinearExtrusion problem
GoTryCatch opened this issue · 7 comments
Hi! Please explain why extrusion does not work through IfcSurfaceOfLinearExtrusion? I need simple cylindrical surface , without solid (IfcExtrudedAreaSolid - it works)
Simple test code...
static void Main(string[] args)
{
var db = new DatabaseIfc(ModelView.Ifc4DesignTransfer);
var site = new IfcSite(db, "Simple Site");
var project = new IfcProject(site, "Simple Project", IfcUnitAssignment.Length.Metre) { };
var building = new IfcBuilding(site, "Simple Building") { };
var buildingStorey = new IfcBuildingStorey(building, "Simple Storey", 0);
var material = new IfcMaterial(db, "Steel");
var relAssMaterial = new IfcRelAssociatesMaterial(material);
var geometricRepresentationContext = new IfcGeometricRepresentationContext(3, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)));
IfcEllipseProfileDef ellipseProfileDef = new IfcEllipseProfileDef(db, "Ellipse", 10, 10);
IfcSurfaceOfLinearExtrusion extrusion = new IfcSurfaceOfLinearExtrusion(ellipseProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 10); // Why this not work?
//IfcExtrudedAreaSolid extrusion = new IfcExtrudedAreaSolid(ellipseProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 10); // This Code works good
IfcProductDefinitionShape rep = new IfcProductDefinitionShape(new List<IfcShapeRepresentation>() { new IfcShapeRepresentation(extrusion) });
IfcBuildingElementProxy buildingElementProxy = new IfcBuildingElementProxy(buildingStorey, new IfcLocalPlacement(new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), rep);
db.WriteFile("C:\\cylindrical.ifc");
}
Can you clarify when you say it doesn't work? For me, it compiles, writes a file and I can see the surface in the GG rhino ifc importer. Ellipse profiles might not be supported in other implementations.
Two notes, you should nominate the profile type to be a curve for use in a surface,
ellipseProfileDef.ProfileType = IfcProfileTypeEnum.CURVE;
Also, there is a circle profile if the x and y dimensions are the same (as input as 10 in your sample code).
Seems BimVision doesn't support SurfaceOfLinearExtrusion (ellipse profile does work for extruded area solid as you noted).
I wish the viewers would do more to log any problems they encounter (either noting a problem in the IFC file, or an ifc concept not supported). I suggest you contact them and ask them for confirmation. SurfaceOfLinearExtrusion is included in design transfer view MVD .
would you recommend an IFC viewer to open my file and show the surface? (Maybe I'm doing something wrong in the code)
a small example of how it works, maybe someone will need
static void Main(string[] args)
{
var db = new DatabaseIfc(ModelView.Ifc4DesignTransfer);
var site = new IfcSite(db, "Simple Site");
var project = new IfcProject(site, "Simple Project", IfcUnitAssignment.Length.Metre) { };
var building = new IfcBuilding(site, "Simple Building") { };
var buildingStorey = new IfcBuildingStorey(building, "Simple Storey", 0);
var material = new IfcMaterial(db, "Steel");
var relAssMaterial = new IfcRelAssociatesMaterial(material);
var geometricRepresentationContext = new IfcGeometricRepresentationContext(3, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)));
IfcRectangleProfileDef rect = new IfcRectangleProfileDef(db, "Rect", 40, 40);
IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(rect, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0 )), new IfcDirection(db, 0, 0, 1), 50);
IfcSurfaceOfLinearExtrusion surfaceLinearExtrusion = new IfcSurfaceOfLinearExtrusion(extrudedAreaSolid.SweptArea, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 50);
IfcLine line1 = new IfcLine(new IfcCartesianPoint(db, -20, 20, 0), new IfcVector(new IfcDirection(db, 0, 0, 1), 0));
IfcTrimmedCurve trimmedLine1 = new IfcTrimmedCurve(line1, new IfcTrimmingSelect(0), new IfcTrimmingSelect(20), true, IfcTrimmingPreference.PARAMETER);
IfcLine line2 = new IfcLine(new IfcCartesianPoint(db, -20, 20, 20), new IfcVector(new IfcDirection(db, 1, 0, 0), 0));
IfcTrimmedCurve trimmedLine2 = new IfcTrimmedCurve(line2, new IfcTrimmingSelect(0), new IfcTrimmingSelect(40), true, IfcTrimmingPreference.PARAMETER);
IfcLine line3 = new IfcLine(new IfcCartesianPoint(db, 20, 20, 20), new IfcVector(new IfcDirection(db, 0, 0, -1), 0));
IfcTrimmedCurve trimmedLine3 = new IfcTrimmedCurve(line3, new IfcTrimmingSelect(0), new IfcTrimmingSelect(20), true, IfcTrimmingPreference.PARAMETER);
IfcLine line4 = new IfcLine(new IfcCartesianPoint(db, 20, 20, 0), new IfcVector(new IfcDirection(db, -1, 0, 0), 0));
IfcTrimmedCurve trimmedLine4 = new IfcTrimmedCurve(line4, new IfcTrimmingSelect(0), new IfcTrimmingSelect(40), true, IfcTrimmingPreference.PARAMETER);
var segments = new List<IfcCompositeCurveSegment>();
segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedLine1));
segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedLine2));
segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedLine3));
segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedLine4));
IfcCompositeCurve segmentsCurve = new IfcCompositeCurve(segments);
List<IfcFaceBound> bounds = new List<IfcFaceBound>();
IfcEdgeCurve edgeCurve = new IfcEdgeCurve(new IfcVertexPoint(new IfcCartesianPoint(db,0,0,0)), new IfcVertexPoint(new IfcCartesianPoint(db, 0,0,0)), segmentsCurve, true);
bounds.Add(new IfcFaceBound(new IfcEdgeLoop(new IfcOrientedEdge(edgeCurve, true)), true));
IfcFaceSurface faceSurface = new IfcFaceSurface(bounds, surfaceLinearExtrusion, true);
IfcFacetedBrep brep = new IfcFacetedBrep(new IfcClosedShell(new List<IfcFace> { faceSurface }));
IfcProductDefinitionShape rep = new IfcProductDefinitionShape(new List<IfcShapeRepresentation>() { new IfcShapeRepresentation(brep),new IfcShapeRepresentation(segmentsCurve) });
IfcBuildingElementProxy buildingElementProxy = new IfcBuildingElementProxy(buildingStorey, new IfcLocalPlacement(new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), rep);
db.WriteFile("C:\\Brep.ifc");
}
As you're using IFC4, I'd suggest looking at IfcIndexedPolyCurve for polylines (or polycurves with arc segments) as a simpler alternative to composite curve, https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/link/ifcindexedpolycurve.htm
Interesting, I will keep in mind! Thanks!