Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Options

Hole Feature Naming

Sam_EttingerSam_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

Sign In or Register to comment.