Creating an Extrusion Programatically
I want to create an extrusion 120mm x 40mm x 2345.56mm

i was able to build a simple cube but i cant control the length of the extrusion, extrusion vector acts oddly i can step it up 1 unit at a time but if i do big changes i see the length changing in odd lengths

private void CreateExtrudedModel()
            Vector3D extrudeVector=new Vector3D(0,1, 0); // Length and Direction Of Extrusion
            Vector3D shapeYVector3D= new Vector3D(1, 0, 0); //Extrusion Vector
            Vector3D modelOffset = new Vector3D(0, 0, 0); //Offset in Coordinate Space X , Y Z

            Point Point1 = new Point(0,0);
            Point Point2 = new Point(0,10);
            Point Point3 = new Point(10,10);
            Point Point4 = new Point(10,0);

            List<Point> centeredShapePositions = new List<Point>() { Point1, Point2, Point3, Point4 };
                MeshGeometry3D extrudedMesh = Mesh3DFactory.CreateExtrudedMeshGeometry(centeredShapePositions,
            catch (Exception ex)
                MessageBox.Show("Error extruding shape:\r\n" + ex.Message);

        private void CreateGeometryModel(MeshGeometry3D meshGeometry3D)
            GeometryModel3D ShownMode = new GeometryModel3D();
            ShownMode.Material = this._standardMaterial;
            ShownMode.Geometry = meshGeometry3D;
so i found this methd, but some of our stuff is non orthagonal how do i create a box from a given point along a vector 

Point3D CenterPosition = new Point3D(0,20,0);
                Size3D CubeSize = new Size3D(140, 40, 5000); //width x heigth x length
                BoxMesh3D BoxMesh3D = new BoxMesh3D(CenterPosition, CubeSize, 5, 5, 5);
Hm, what do you mean by "extrusion vector acts oddly i can step it up 1 unit at a time but if i do big changes i see the length changing in odd lengths"?

If you set the extrudeVector to new Vector3D(0,123.456, 0), then the created mesh will have SizeX: 10.00, SizeY: 123.456, SizeZ: 10.00. This is correct.

Note that if you rotate the extrudeVector, then you also need to rotate the shapeYVector3D. Those two vectors define 2 axes for the extruded mesh (the third axis can be calculated with doing a vector cross product between those two vectors).

The BoxMesh3D and BoxVisual3D will always create an axis-aligned box. You can apply a transformation to them to rotate them.

If you want to create a box from a start 3D position to an end 3D position, you can also use the TubeLineMesh3D and TubeLineVisual3D - by default this will create a cylinder but you can set the Segments to 4 and this will create a 4 sided cylinder - a box.
Andrej Benedik
Thanks for the reply, how do a do an axis to axis transformation or apply a transformation matrix
To apply a transformation you need to set the Transform property. You can set it to a TranslateTransform3D, ScaleTransform3D, RotateTransform3D, MatrixTransform3D or Transform3DGroup.

Search the internet for more information or check the "Basic WPF 3D objects tutorial" sample that comes with the Ab3d.PowerToys samples project.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)