<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>
Looking for a snippet that will cycle through all points in a nominated sketch
philip_thomas
Member, Moderator, Onshape Employees, Developers Posts: 1,381
I just don't know what the code looks like - is there something similar someone can point me to or perhaps just paste a snippet?
Thank you.
Thank you.
Philip Thomas - Onshape
0
Best Answers
-
sometimes ago i found a handy overload of qCreatedBy() in the standart library:
<a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#qCreatedBy-FeatureList">qCreatedBy </a><span>(features is <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#FeatureList">FeatureList</a>) </span><span> returns <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#Query">Query</a></span>
so if you get the sketch as FeatureList you just feed it to this qCreatedBy() and filter the point bodies with qBodyType()if you are asking seriously)5 -
If you created the sketch in the current feature (and have its id) this should be just
for (var point in evaluateQuery(context, qCreatedBy(id + "sketch1", EntityType.VERTEX))) { ...
6 -
^ Although you may hit each point twice by doing that. It is safer to also add a body type filter:
for (var point in evaluateQuery(context, qBodyType(qCreatedBy(<sketchId>, EntityType.VERTEX), BodyType.WIRE))) { ...
Jake Rosenfeld - Modeling Team6 -
Thank you (and Jake) - here are the fruits


https://cad.onshape.com/documents/e02f8da5c872d4d55e30e218/w/41d8b64176967ea1955c14fa/e/63364cbd3b3f3c845a6a46ad
Philip Thomas - Onshape2
Answers
-
sometimes ago i found a handy overload of qCreatedBy() in the standart library:
<a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#qCreatedBy-FeatureList">qCreatedBy </a><span>(features is <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#FeatureList">FeatureList</a>) </span><span> returns <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#Query">Query</a></span>
so if you get the sketch as FeatureList you just feed it to this qCreatedBy() and filter the point bodies with qBodyType()if you are asking seriously)5 -
If you created the sketch in the current feature (and have its id) this should be just
for (var point in evaluateQuery(context, qCreatedBy(id + "sketch1", EntityType.VERTEX))) { ...
6 -
^ Although you may hit each point twice by doing that. It is safer to also add a body type filter:
for (var point in evaluateQuery(context, qBodyType(qCreatedBy(<sketchId>, EntityType.VERTEX), BodyType.WIRE))) { ...
Jake Rosenfeld - Modeling Team6 -
Thank you (and Jake) - here are the fruits


https://cad.onshape.com/documents/e02f8da5c872d4d55e30e218/w/41d8b64176967ea1955c14fa/e/63364cbd3b3f3c845a6a46ad
Philip Thomas - Onshape2 -
1



