<p>Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.</p></p><strong>First time visiting? Here are some places to start:</strong></p><ol style="list-style:inherit;margin-left:25px;"><li>Looking for a certain topic? Check out the <a href="https://forum.onshape.com/categories">categories filter</a> or use Search (upper right).</li><li>Need support? <a href="https://forum.onshape.com/post/question/community-support">Ask a question</a> to our <a href="https://forum.onshape.com/categories/community-support">Community Support</a> category.</li><li>Please submit support tickets for bugs but you can request improvements in the <a href="https://forum.onshape.com/categories/product-feedback">Product Feedback category</a>.</li><li>Be respectful, on topic and if you see a problem, Flag it.</li></ol><p>If you would like to contact our Community Manager personally, feel free to <a href="https://forum.onshape.com/profile/6/LouGallo">send a private message</a> or <a href="mailto:lgallo@onshape.com">an email</a>.
</p>
</p>
get featureList of parent feature from a query?
EvanReese
Member, Mentor Posts: 3,084 PRO
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.
0
Best Answers
-
So you want the feature id?
https://cad.onshape.com/documents/19d37a12b586bed2588d0cd3/w/2b3260397b1c17b89cecdaf6/e/e7b403c016b91174c135d374
1 -
@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
-
So you want the feature id?
https://cad.onshape.com/documents/19d37a12b586bed2588d0cd3/w/2b3260397b1c17b89cecdaf6/e/e7b403c016b91174c135d374
1 -
@_anton is close, but to get the sketch features id you need take the first element in the id. So ownerSketchId[0] should do it.
1 -
@_anton
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:applyPattern(context, id + "copySketch", { "instanceFunction" : sketchId, "patternType" : PatternType.FEATURE, "transforms" : [identityTransform()], "instanceNames" : ["copy"], "fullFeaturePattern" : false }, identityTransform());
0 -
@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 -
@Jacob_Corder
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!0 -
@_anton is to receive credit, I didn't even think of using lastModificationFeatureId to extract it. I was surprised that opPattern actually copied the sketch as it is. I just tested it to see what would happen and boom a sketch.2
-
Team effort. :P4
-


