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



