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.
Query that Resolves to nothing != qNothing()
Jonathan_Hutchinson
Member Posts: 91 PRO
I stumbled on some strange behaviour I couldn't figure out. What I thought was quite a straightforward conditional where I do a qSubtraction, resolved weirdly. As below.
const allGeom = qCreatedBy(id + "extrudeThin", EntityType.FACE);
const planeGeom = qGeometry(qCreatedBy(id + "extrudeThin", EntityType.FACE), GeometryType.PLANE);
const curvedGeom = qSubtraction(allGeom, planeGeom);
debug(context, allGeom, DebugColor.RED);
debug(context, planeGeom, DebugColor.RED);
debug(context, curvedGeom, DebugColor.RED);
if (curvedGeom != qNothing())
{
println("is something");
}
else
{
println("is nothing");
}
Returned in the console:
debug: Query resolves to 6 faces
debug: Query resolves to 6 faces
debug: Query resolves to nothing >>> (curvedGeom variable)
is something >>> (curvedGeom variable, resolves to nothing but isn't equal to qNothing?)
My workaround is to evaluate the query and test if it's equal to an empty array. But I thought equality to qNothing was possible?
Returned in the console:
debug: Query resolves to 6 faces
debug: Query resolves to 6 faces
debug: Query resolves to nothing >>> (curvedGeom variable)
is something >>> (curvedGeom variable, resolves to nothing but isn't equal to qNothing?)
My workaround is to evaluate the query and test if it's equal to an empty array. But I thought equality to qNothing was possible?
Tagged:
0
Comments
if(isQueryEmpty(curvedGeom)==false)
{
}
so, use isQueryEmpty(curvedGeom)
if(!isQueryEmpty(curvedGeom))
{
}