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.
@OPPATTERN: INVALID_INPUT
nir_naron
Member Posts: 26 EDU
Trying to duplicate a user-selected line. No idea why these two Featurescripts attached below aren't working.
@NeilCooke HELP!
Also, side questions:
1) What's the best way to have the pattern be perpendicular to the line? Currently they're in the same direction. I was hoping to be able to go <evvLine.direction.normal> though it seems like that's not the way it works.
2) How do I get <selctedLine>'s start-point and end-point? The start-point is <evvLine.origin> but I'm not sure about the end-point.
Thanks!
FeatureScript 2345;
import(path : "onshape/std/common.fs", version : "2345.0");
annotation { "Feature Type Name" : "Pattern Line"}
export const patternLine = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Select Line:", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
definition.selectedLine is Query; }
{
const selectedLine = definition.selectedLine;
debug(context, selectedLine);
const evvLine = evEdgeTangentLine(context, {
"edge" : selectedLine,
"parameter" : 0
});
debug(context, evvLine);
opPattern(context, id + "pattern1", {
"entities" : selectedLine,
"transforms" : [transform(evvLine.direction*inch)],
"instanceNames" : ["Copy1"]
});
});
// annotation { "Feature Type Name" : "Pattern Line Wierdly" }
// export const patternLineWierdly = defineFeature(function(context is Context, id is Id, definition is map)
// precondition
// {
// annotation { "Name" : "Select Line:", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
// definition.selectedLine is Query;
// }
// {
// const selectedLine = definition.selectedLine;
// debug(context, selectedLine);
// const evvLine = evEdgeTangentLine(context, {
// "edge" : selectedLine,
// "parameter" : 0
// });
// opExtractWires(context, id + "opExtractWires1", {
// "edges" : selectedLine
// });
// debug(context, qCreatedBy(id + "opExtractWires1", EntityType.EDGE));
// opPattern(context, id + "pattern1", {
// "entities" : qCreatedBy(id + "opExtractWires1", EntityType.EDGE),
// "transforms" : [transform(evvLine.direction*inch)],
// "instanceNames" : ["Copy1"]
// });
// });
Tagged:
0
Comments
So either you need to have the feature take a wire body, or put the edge query through qOwnerBody before passing it to opPattern. Here, I'm doing the former: https://cad.onshape.com/documents/94ddc4d34e104cb58a6e2814/w/6095cff03382e4a3f5843d49/e/f0ceb4faf6d6ba5f60d27fb4
1. There's an infinite number of vectors perpendicular to a line. Is the input necessarily a sketch entity? Then you can get its sketch normal with evOwnerSketchPlane and do a cross product to get a perpendicular direction.
2. Probably the easiest way is evvLine.origin + evvLine.direction * evLength(context, { "entities": selectedLine }); (untested, so YMMV).