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.
Why are my variables not working when set for feature driven pattern
brad_phelan
Member Posts: 91 ✭✭
I have the following profile designed using a variable width

In my custom feature I have tried the following
The profiles are patterned

but the two new sketches don't accept the width variable. Any idea what I am doing wrong?

In my custom feature I have tried the following
annotation { "Name" : "Profile", "Filter" : SketchObject.YES, "MaxNumberOfPicks" : 1 }
def.profile is FeatureList;
...
...
setVariable(context, "width", 115 * millimeter);
applyPattern(context, id + "sk0", {
"patternType" : PatternType.FEATURE,
"instanceFunction" : valuesSortedById(context, def.profile),
"transforms" : [transform(vector(50, 0, 0) * millimeter)],
"instanceNames" : ["a"]
}, identityTransform());
setVariable(context, "width", 315 * millimeter);
applyPattern(context, id + "sk1", {
"patternType" : PatternType.FEATURE,
"instanceFunction" : valuesSortedById(context, def.profile),
"transforms" : [transform(vector(100, 0, 0) * millimeter)],
"instanceNames" : ["a"]
}, identityTransform());
The profiles are patterned

but the two new sketches don't accept the width variable. Any idea what I am doing wrong?
Tagged:
0
Best Answers
-
check if the entity that is refferenced by the "width" dimension is internal geometry of the sketch, i would reccomend put a point to the sketch origin and apply a fix constrain to it. then dimension everything relative to this point/ all the external sketch refferences are droped by feature pattern and it is the main problem
5 -
Ok. That did the trick.

0
Answers
-
check if the entity that is refferenced by the "width" dimension is internal geometry of the sketch, i would reccomend put a point to the sketch origin and apply a fix constrain to it. then dimension everything relative to this point/ all the external sketch refferences are droped by feature pattern and it is the main problem
5 -
I have a lot of constraints to the origin. Ok I'll try your fix. Thanks0
-
Ok. That did the trick.

0 -
@ilya_baran When doing this I would suggest an improvement to applyPattern. Currently I think I have to do a loop
for(;;;){
setVariable(context,...);
applyPattern(context,...);
}
it would be nice if applyPattern had an extraparameter
variables of type array of map where variables for each instance could be set.
2 -
I would even request an option of feature pattern to not to drop external sketch references
1 -
Note the 220 calls to generate the below take about 5 seconds. And yes +1 to not dropping the external refs.


1 -
Hi-Does anyone have a link to a FS that does this setVariable inside a for loop with a pattern? I want to do essentially the same thing and I'm not getting the array syntax.0
-
Perhaps this is a bit beginner, but I don't quite understand the array syntax in FS. This is not quite working:
definition.entities = definition.bodies;
definition.instanceNames = names;
definition.transforms = transforms;
for (var k = 0; k < size(transforms); k += 1)
{
setVariable(context, "dCharacteristic", .030*(1 + (k*.002))*inch);
applyPattern(context, id + ("pattern" ~ k), definition, remainingTransform);
}
0 -
what error message are you getting @david_gregory ?
If you click the FeatureScript notices button it will flyout a console output on the bottom of the screen If you toggle on Monitoring you can see the result of the last committed script
0

