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.
Transformation of a surface in a loop fails
j_j406
Member Posts: 6 ✭
I am running the following sequence
1. transform+copy an existing surface 5 times
2. Add the new surfaces an attribute "Slicer"
3. Delete all surfaces with an attribute "Slicer"
4. Got back to step 1.
During the first iteration everything works fine, however during the second iteration transform fails with "Cannot Resolve Entities". I checked that my delete operation does not delete the original surface, only copies. Does anyone have an idea what the problem might be?
var distance=0;
for ( var i=1;i<5;i=i+1)
{
println(i);
distance=0;
for ( var count=1;count<5;count=count+1)
{
distance = distance+2+6;
print("-");
println(count);
//print("---");
//println(definition.xslicer);
transform(context, id + i+count+"transformx"+i+count, {
"entities" : definition.xslicer,
"transformType" : TransformType.TRANSLATION_3D,
"dx" : distance*millimeter,
"dy" : 0*millimeter,
"dz" : 0*millimeter,
"makeCopy" : true
});
setAttribute(context, {
"entities" : qMatching(definition.xslicer),
"name" : "Slicer",
"attribute" : "Slicer"
});
}
try
{
opDeleteBodies(context, id + "deleteBodies", {
"entities" : qHasAttribute("Slicer")
});
}
catch
{
println("Error - opDeleteBodies");
}
}
for ( var i=1;i<5;i=i+1)
{
println(i);
distance=0;
for ( var count=1;count<5;count=count+1)
{
distance = distance+2+6;
print("-");
println(count);
//print("---");
//println(definition.xslicer);
transform(context, id + i+count+"transformx"+i+count, {
"entities" : definition.xslicer,
"transformType" : TransformType.TRANSLATION_3D,
"dx" : distance*millimeter,
"dy" : 0*millimeter,
"dz" : 0*millimeter,
"makeCopy" : true
});
setAttribute(context, {
"entities" : qMatching(definition.xslicer),
"name" : "Slicer",
"attribute" : "Slicer"
});
}
try
{
opDeleteBodies(context, id + "deleteBodies", {
"entities" : qHasAttribute("Slicer")
});
}
catch
{
println("Error - opDeleteBodies");
}
}
0
Comments