Hole Feature Naming

Sam_Ettinger
Sam_Ettinger Member Posts: 4 ✭
edited July 2019 in FeatureScript
Is it possible to create a hole feature that names the feature the same as the tap information or clearance information? For example if a hole feature creates a tapped hole for a M3x0.5 screw, the feature would be called M3x0.5, and if the hole feature creates a clearance hole for the M3x0.5 screw, the feature would be called M3. This would save time when reviewing parts and tapping holes. 

<div>FeatureScript 1112;
import(path : "onshape/std/geometry.fs", version : "1112.0");

annotation { "Feature Type Name" : "MyHole" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        // Define the parameters of the feature type
        annotation { "Name" : "Points", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
        definition.Points is Query;
        
        
        annotation { "Name" : "Hole Diameter" }
        isLength(definition.diameter, NONNEGATIVE_LENGTH_BOUNDS);

        annotation { "Name" : "Hole Depth" }
        isLength(definition.depth, NONNEGATIVE_LENGTH_BOUNDS);

    }



    {
        definition.Plane = evOwnerSketchPlane(context, {
                    "entity" : definition.Points
                });
                
        var Location = evVertexPoint(context, {
                "vertex" : definition.Points
        });
        
        println(Location);
        var Radius=definition.diameter/2;
        var LocationX=Location[0];
        var LocationY=Location[1];

        var origin= vector(definition.Plane.origin);
        var normal= vector(definition.Plane.normal);
        var x= vector(definition.Plane.x);
       
        var plane1 is Plane= plane(origin, normal, x);
        
        var sketch1 = newSketchOnPlane(context, id + "sketch1", {
                "sketchPlane" : plane1
        });
        var Center is Vector = vector(LocationX, LocationY);
        println(Center);
        var Circle = skCircle(sketch1, "circle1", {
              "center" : Center,
              "radius" : Radius
        });

    skSolve(sketch1);
println(Circle);
println(plane1.normal);


       

});
        

</div><div></div>

Comments