🌶️ Modeling Practice Drawings 69

At the time of writing, due to a singularity, we need to set the radius as 19 units instead of 20.

// Sketch 1
var sk1 = new devDept.Geometry.ConstraintSolver.Sketch();

// Add origin point
SketchPoint origin1 = sk1.AddOrigin();

// Lines
var l1 = sk1.AddLine(-20, -60, -20, -100);
var l2 = sk1.AddLine(-20, -100, 20, -100);
var l3 = sk1.AddLine(20, -100, 20, -60);

// Mid point
var p1 = sk1.AddPoint(20, -100);
sk1.AddConstraintMidPoint(p1, l2); 

// Arcs 
var a1 = sk1.AddArc(new Point2D(20, -45),
                    new Point2D(30, -40),
                    new Point2D(10, -60));
var a2 = sk1.AddArc(new Point2D(0, 30),
                    new Point2D(30, -40),
                    new Point2D(-30, -40));
var a3 = sk1.AddArc(new Point2D(-20, -45),
                    new Point2D(-10, -60),
                    new Point2D(-30, -40));

// Hor/Ver constraints
sk1.AddConstraintVertical(l1);
sk1.AddConstraintHorizontal(l2);
sk1.AddConstraintVertical(l3);
sk1.AddConstraintVertical(p1, origin1);

// Join constraints
sk1.AddConstraintJoin(l1, l2);
sk1.AddConstraintJoin(l2, l3);
sk1.AddConstraintJoin(l3, a1);
sk1.AddConstraintJoin(a1, a2);
sk1.AddConstraintJoin(a2, a3);
sk1.AddConstraintJoin(a3, l1);
sk1.AddConstraintJoin(a2.Center, origin1);

// Tangency between arcs and linear segments
sk1.AddConstraintTangent(l1, a3);
sk1.AddConstraintTangent(l3, a1);
sk1.AddConstraintTangent(a1, a2);
sk1.AddConstraintTangent(a2, a3);

// Fix radius
sk1.AddConstraintRadius(a2, 75);

// Fix lenghts
sk1.AddConstraintLength(l1, 35);
sk1.AddConstraintLength(l2, 40);
sk1.AddConstraintEqualLength(l1, l3);
sk1.AddConstraintDistance(p1, a2.Center, 135);

/*SketchEntity se1 = new SketchEntity(sk1);
design1.Entities.Add(se1);*/
  
// Create a Brep
Brep ext1 = sk1.ExtrudeAsBrep(new Interval(-20, 20))[0];
design1.Entities.Add(ext1, Color.PaleVioletRed);

// Add Fillet
const double radius = 19.9;

foreach (var edge in ext1.Edges)
{
    if (Utility.IsLine(edge.Curve) &&
        Vector3D.AreParallel(((Line)edge.Curve).Tangent, Vector3D.AxisY) &&
        edge.Curve.StartPoint.Z > 0)
    {
        ext1.Fillet(edge, radius);
        break;
    }
}

foreach (var edge in ext1.Edges)
{
    if (Utility.IsLine(edge.Curve) &&
        Vector3D.AreParallel(((Line)edge.Curve).Tangent, Vector3D.AxisY) &&
        edge.Curve.StartPoint.Z < 0)
    {
        ext1.Fillet(edge, radius);
        break;
    }
}

/*design1.Entities.Regen();*/


// Sketch 2
var sk2 = new devDept.Geometry.ConstraintSolver.Sketch(Plane.YZ);

// Add origin point
SketchPoint origin2 = sk2.AddOrigin();

// Lines
var l4 = sk2.AddLine(0, 20, 55, 20);
var l5 = sk2.AddLine(0, 20, 0, 40);

// Arcs 
var a4 = sk2.AddArc(new Point3D(0, 0, 0),
                    new Point3D(55, 20, 0),
                    new Point3D(0, 40, 0));

// Hor/Ver constraints
sk2.AddConstraintVertical(l5);
sk2.AddConstraintHorizontal(l4);
sk2.AddConstraintVertical(l4.StartPoint, origin2);
sk2.AddConstraintVertical(a4.Center, origin2);

// Join constraints
sk2.AddConstraintJoin(l4, l5);
sk2.AddConstraintJoin(l4, a4);
sk2.AddConstraintJoin(l5, a4);

// Fix radius
sk2.AddConstraintRadius(a4, 100);

// Fix lenghts
sk2.AddConstraintLength(l4, 55);
sk2.AddConstraintDistance(l4.StartPoint, origin2, 20);

/*SketchEntity se2 = new SketchEntity(sk2);
design1.Entities.Add(se2);*/

ext1.RevolveAdd(sk2, Utility.DegToRad(360), Vector3D.AxisZ, new Point3D(0,0,20));

/*design1.Entities.Regen();*/


// sketch 3
var sk3 = new devDept.Geometry.ConstraintSolver.Sketch();

// Add origin point 
SketchPoint origin3 = sk3.AddOrigin();

// Ref circle
var cir1 = sk3.AddCircle(10, 10, 40, true, true);

// Lines
var l6 = sk3.AddLine(20, -45, 20, -20);
var l7 = sk3.AddLine(-20, -45, -20, -20);

// Arcs 
var a5 = sk3.AddArc(new Point3D(0, -40, 0),
                    new Point3D(25, -20, 0),
                    new Point3D(-25, -20, 0));
var a6 = sk3.AddArc(new Point3D(0, 0, 0),
                    new Point3D(-25, -45, 0),
                    new Point3D(25, -45, 0));

// Hor/Ver constraints.
sk3.AddConstraintVertical(l6);
sk3.AddConstraintVertical(l7);
sk3.AddConstraintVertical(a5.Center, origin3);

// Join constraints
sk3.AddConstraintJoin(a5, l6);
sk3.AddConstraintJoin(l6, a6);
sk3.AddConstraintJoin(a6, l7);
sk3.AddConstraintJoin(l7, a5);
sk3.AddConstraintPointOn(a5.Center, cir1);
sk3.AddConstraintJoin(cir1.Center, origin3);

// Fix radius        
sk3.AddConstraintRadius(a5, 10);
sk3.AddConstraintRadius(a6, 45);

/*SketchEntity se3 = new SketchEntity(sk3);
design1.Entities.Add(se3);*/

// Holes
for (int i = 0; i < 4; i++)
{
    ext1.ExtrudeRemove(sk3, new Interval(-20, 40));
    ext1.Rotate(Utility.DegToRad(90), Vector3D.AxisZ);
}

design1.Entities.Regen();

image (2).png

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section