Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Featurescript UI Question
meepinator
Member Posts: 5 ✭
Hello everyone.
This is my first featurescript.
I am attempting to expand on @jeff_brown304 's Camel project, by making an improved CAM drill tool. The intent is to have the user select a cylindrical hole surface, and subsequently unhide portions of the UI that correspond to different features that the hole may have. For example, if the hole is countersunk, a "countersink tool" selection box will show up, along with a dropdown for unique feeds & speeds, etc.
I have figured out how to pull the holeType attribute, and assign it to a boolean variable, but I am now realizing that this cannot be brought back to the precondition.
//if(????) I would like to toggle the below feature based on the presence of a countersink attribute
{
annotation { "Name" : "Countersink Tool", "Filter" : BodyType.COMPOSITE, "MaxNumberOfPicks" : 1 }
definition.countersinkTool is Query;
}
}
{
var selections = evaluateQuery(context, definition.selectedHoles);
for (var face in selections)
{
var allAttributes = getAttributes(context, { "entities" : face });
var foundHoleData = false;
var counterSunk = false;
var counterBored = false;
for (var attr in allAttributes)
{
if (attr.holeType == HoleStyle.C_SINK)
{ counterSunk = true; }
if (attr.holeType == HoleStyle.C_BORE)
{ counterBored = true; }
if (attr.holeDiameter != undefined)
{
foundHoleData = true;
if (attr.isTappedHole)
println("Major Diameter " ~ attr.majorDiameter ~ " Pitch: " ~ attr.threadPitch);
else {
println("Simple Hole: " ~ attr.holeDiameter);
}
}
}
if (!foundHoleData)
{
debug(context, face, DebugColor.RED);
throw regenError("Feed me a hole" );
}
}
I am looking for a way to get attributes of a feature selected in the precondition, back into the precondition.
Here's the document: https://cad.onshape.com/documents/927a40c416a1bc927796df37/w/3800a45cf3b68f0191925f6d/e/a85f5e7c93463861124927d4
Additionally, the way I have the "holes to drill" menu set up, allows selection of incorrect geometry, (partial radiuses and cylindrical extrusions) and sends an error message if no hole data is found. I would like to somehow disallow highlighting and selection of everything but cylindrical holes parallel to the machine setup Z axis, and allow simple circular extrusions with no attached hole data.
annotation { "Name" : "Holes to Drill", "Filter" : GeometryType.CYLINDER && EntityType.FACE }
definition.selectedHoles is Query;
I'd appreciate any help or pointers.
Answers
If you want to create dynamic feature dialogs you need to use Editing logic
Experts in Onshape Automation - Custom Features and Integrated Applications