How to Work with 2D Profiles in .NET
How to Work with 2D Profiles in .NET
This article shows how to define 2D cross-section profiles and sweep or revolve them into 3D solids using Aspose.3D for .NET.
Step 1 — Install the Package
dotnet add package Aspose.3D.Converter --version 1.0.0Step 2 — Create a Parameterized Profile
Use built-in shapes such as RectangleShape or CircleShape for standard cross-sections:
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Profiles;
var scene = new Scene();
// Rectangle profile: 2 units wide, 1 unit tall
var rectProfile = new RectangleShape();
rectProfile.XDim = 2.0;
rectProfile.YDim = 1.0;
// Extrude 5 units along Z
var beam = new LinearExtrusion(rectProfile, 5.0);
beam.Slices = 10;
scene.RootNode.CreateChildNode("beam", beam);Step 3 — Create a Parameterized L-shaped Profile
LShape produces an L-section beam from dimensional properties:
using Aspose.ThreeD.Profiles;
// L-shaped cross-section structural beam
var lProfile = new LShape();
lProfile.Width = 0.1;
lProfile.Depth = 0.2;
lProfile.Thickness = 0.01;
var lBeam = new LinearExtrusion(lProfile, 4.0);
scene.RootNode.CreateChildNode("l_beam", lBeam);Step 4 — Create a Mirrored Profile
MirroredProfile produces a symmetric cross-section by mirroring a base profile:
using Aspose.ThreeD.Profiles;
// Base profile to mirror
var baseProfile = new RectangleShape();
baseProfile.XDim = 0.5;
baseProfile.YDim = 1.0;
// Mirror to get a symmetric beam flange
var mirrored = new MirroredProfile(baseProfile);
var iBeam = new LinearExtrusion(mirrored, 3.0);
scene.RootNode.CreateChildNode("i_beam", iBeam);Step 5 — Revolve a Profile into a Solid
RevolvedAreaSolid rotates a profile around an axis to produce a rotationally symmetric solid. Set Shape and AngleEnd on the instance:
var circleProfile = new CircleShape { Radius = 0.5 };
var revolved = new RevolvedAreaSolid();
revolved.Shape = circleProfile;
revolved.AngleEnd = Math.PI * 2; // full revolution
scene.RootNode.CreateChildNode("sphere", revolved);Step 6 — Save the Scene
scene.Save("profiles.gltf", FileFormat.GLTF2);
Console.WriteLine("Saved: profiles.gltf");Troubleshooting
| Symptom | Likely Cause | Fix |
|---|---|---|
| Extrusion has no visible geometry | Profile edges are collinear or zero-area | Verify Edges form a valid closed polygon |
| Mirrored result is not symmetric | Wrong MirrorAxis value | Use MirrorAxis.X or MirrorAxis.Y as appropriate |
| Revolved solid is hollow or flat | Sweep angle is 0 or profile is open | Use a closed profile and set angle to Math.PI * 2 for full revolution |
Related Resources
- Working with Profiles — developer guide with full API details
- Working with Scene Entities — attach extruded solids to scene nodes