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.
get featureList of parent feature from a query?
EvanReese
Member, Mentor Posts: 2,188 ✭✭✭✭✭
How can I take a query of a sketch edge, and get the featureList of the parent sketch? I know how to get the sketch Id, but I'm not sure where to go from there.
Evan Reese
0
Best Answers
-
_anton Member, Onshape Employees Posts: 413So you want the feature id?
https://cad.onshape.com/documents/19d37a12b586bed2588d0cd3/w/2b3260397b1c17b89cecdaf6/e/e7b403c016b91174c135d374
1 -
Jacob_Corder Member Posts: 137 PRO@Evan_Reese
Are you just trying to copy the sketch?
this does it and keeps it as a sketch
probably add construction filters if you want.FeatureScript 1977; import(path : "onshape/std/common.fs", version : "1977.0"); annotation { "Feature Type Name" : "pattern Sketch" } export const patternSketch = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "sk Ent", "Filter" : EntityType.EDGE||EntityType.FACE, "MaxNumberOfPicks" : 1 } definition.skEnt is Query; } { var owner = lastModifyingOperationId(context, definition.skEnt) as Id; owner = owner[0]; owner = makeId(owner); opPattern(context, id+"Copy", { "entities" : qCreatedBy(owner, EntityType.BODY), "transforms" : [identityTransform()], "instanceNames" : ["copySketchEnts"] }); });
2
Answers
https://cad.onshape.com/documents/19d37a12b586bed2588d0cd3/w/2b3260397b1c17b89cecdaf6/e/e7b403c016b91174c135d374
Thanks. I've gotten that far, but I'm wanting it formatted in whatever form applyPattern() ingests. I thought I might need to use featureList(), but I'm not sure.
Something like this:
Are you just trying to copy the sketch?
this does it and keeps it as a sketch
probably add construction filters if you want.
FeatureScript 1977; import(path : "onshape/std/common.fs", version : "1977.0"); annotation { "Feature Type Name" : "pattern Sketch" } export const patternSketch = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "sk Ent", "Filter" : EntityType.EDGE||EntityType.FACE, "MaxNumberOfPicks" : 1 } definition.skEnt is Query; } { var owner = lastModifyingOperationId(context, definition.skEnt) as Id; owner = owner[0]; owner = makeId(owner); opPattern(context, id+"Copy", { "entities" : qCreatedBy(owner, EntityType.BODY), "transforms" : [identityTransform()], "instanceNames" : ["copySketchEnts"] }); });
Thanks for seeing through my wrong question and giving me the answer to the one I should have asked. That does accomplish what I'm after. I had done something similar, but I guess different enough to mess up other feature's ability to find the sketch plane direction. This should unblock me on what I'm working on!