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.
Transfer queries across different featurescripts
Federico_Casarini
Member Posts: 9 PRO
Hello everyone! Time for another super newbie questions, sorry in advance. I am trying to do something but I am struggling to find a way.
I have the following problem: I created a feature which runs a number of different operations. One of them is an opboolean subtraction of two intersecting 3D geometries. Now I want to query all the faces generated from this subtraction from another featurescript. Is there a way to do it? I tried by creating a function which returns a query but it doesn't work.
The code looks something like this (this is only for example):
Thanks in advance!
Fed
I have the following problem: I created a feature which runs a number of different operations. One of them is an opboolean subtraction of two intersecting 3D geometries. Now I want to query all the faces generated from this subtraction from another featurescript. Is there a way to do it? I tried by creating a function which returns a query but it doesn't work.
The code looks something like this (this is only for example):
FeatureScript 1287; import(path : "onshape/std/geometry.fs", version : "1287.0");
import(path : pathtofirstfeaturescript, version : "1287.0"); annotation { "Feature Type Name" : "second_operation" }
export const second_operation = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
}
{
var onlybooleanfaces = hollow_faces(context, id + "boolean1");
//highlight only the faces created by the opboolean on the first featurescript
debug(context, onlybooleanfaces);
}); </code><span>FeatureScript 1287; </span><span>import(path : "onshape/std/geometry.fs", version : "1287.0"); </span>annotation { "Feature Type Name" : "first_operation" }<br>export const first_operation = defineFeature(function(context is Context, id is Id, definition is map)<br><span> precondition </span> {<br> }<br> {<br> fCuboid(context, id + "cuboid1", {<br> "corner1" : vector(0, 0, 0) * inch,<br> "corner2" : vector(1, 1, 1) * inch<br> });<br> fCuboid(context, id + "cuboid2", {<br> "corner1" : vector(0, 0, 0) * inch,<br> "corner2" : vector(2, 2, 2) * inch<br> });<br> var allsolids = qAllModifiableSolidBodies();<br> var smallcube = qNthElement(allsolids, 0);<br> var bigcube = qNthElement(allsolids, 1);<br> opBoolean(context, id + "boolean1", {<br> "tools" : smallcube,<br> "targets": bigcube,<br> "operationType" : BooleanOperationType.SUBTRACTION<br><span> }); </span> });<br>export function hollow_faces(context is Context, id is Id) returns Query<br>{<br>return qCreatedBy(id, EntityType.FACE);<br>} </pre><br>Second featurescript on different tab:<br><br><pre class="CodeBlock"><code>
Thanks in advance!
Fed
0
Comments
The only way I can think of "transferring" data from one feature to another is to use attributes to tag the faces. See setAttribute / getAttribute.
PhD, Mechanical Engineering, Stanford University
Fed