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.
How Do I Subtract a Number from My Variable
3966_cad
EDU
I am trying to iterate an skCircle to space them out evenly, but I keep on running into an error:
"Can not subtract ValueWithUnits (map) and number"
I know what the error means, but I can't figure out how to make it work.
I would appreciate any help you can offer me.
"Can not subtract ValueWithUnits (map) and number"
for (var i = 0 * inch; i < definition.length; i += 1)
{
var iss = i - 0.5;
skCircle(sketch2, "circle" ~ i, {
"center" : vector((iss), 0.5 * inch),
"radius" : 0.6299 * inch
});
}Here is the link to the full file.I know what the error means, but I can't figure out how to make it work.
I would appreciate any help you can offer me.
Tagged:
0
Comments
-
In expression var iss = i - 0.5; i is a ValueWithUnits , namely length. The value you subtract from it also has to be length :
var iss = i - 0.5 * inch<span>; would fix the the error. </span>
0 -
You are going to run into similar issues with:
i += 1
and</code>skCircle(sketch2, "circle" ~ i, {...</pre>The first is the same issue as you posed about (adding a number and a ValueWithUnits) and the second if that the Featurescript interpreter won't be happy with using a ValueWithUnits in an Id string. You can fix these issues by using:<br><pre class="CodeBlock"><code>i += 1 * inchandskCircle(sketch2, "circle" ~ (i / inch), {...respecively.Jake Rosenfeld - Modeling Team0 -
Thanks! I was just about to ask that.
0 -
OK. So I did that and I got another error that my qContainsPoint wasn't resolving to anything. Any tips on this?
0 -
Still need help by the way0
-
I would guess the issue is that qSketchRegion(id + "sketch2") may not be selecting what you expect (try passing that into debug) and instead you should use qCreatedBy(id + "sketch2", EntityType.FACE)Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
Got it.
0


