Instantiation within a function?
MichaelPascoe
Member Posts: 2,965 PRO
I'm modifying a custom feature. Instead of having the feature pattern a part, I would like it to create instantiations of a part.
The feature uses a pattern operation inside a function. I replaced the pattern operation with an instantiator, but I get an error saying the instantiator transform needs to be a function. Usually the instantiator does not need the transform to be in function format. I'm not sure how to fix this. Can someone help explain what I'm doing wrong?
Error message:

Shortened version of the code:
The feature uses a pattern operation inside a function. I replaced the pattern operation with an instantiator, but I get an error saying the instantiator transform needs to be a function. Usually the instantiator does not need the transform to be in function format. I'm not sure how to fix this. Can someone help explain what I'm doing wrong?
Error message:

Shortened version of the code:
function createBodyPattern(id is Id, context is Context, baseBody, mateConnector, coordMatrix, matSize, definition, cutDepth)
{
//Old pattern operation
opPattern(context, id + "pattern1", {
"entities" : baseBody,
"transforms" : transform,
"instanceNames" : instanceNames
});
//New instantiator
var x = .25 * inch;
var y = .3 * inch;
var z = .01 * inch;
const instantiator = newInstantiator(id + "inst", {});
var queries = [];
for (var i = 0; i < size(instancePlanes); i += 1)
{
var q = addInstance(instantiator, brick::build,
{ "configuration" : {
"width" : x,
"depth" : y,
"height" : z },
"transform" : transform(XY_PLANE, instancePlanes[i]) //Error: Called value must be a function, value is array
});
queries = append(queries, q);
q = append(queries, q);
}
instantiate(context, instantiator);
}▚▞▚▞▚▞▚▞▚
Tagged:
0
Best Answers
-
I think I'm on to it now. I need to make the instantiator transform match the function the old pattern was calling for.
Got it working, but i'm still not sure why it required the instantiation transform to be in function format.
▚▞▚▞▚▞▚▞▚0 -
It's much better if you share a link to the document. I suspect that the issue is actually in the part of the code you shortened -- you declared transform as a variable and that hid the transform function you're trying to call.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc1
Answers
-
I think I'm on to it now. I need to make the instantiator transform match the function the old pattern was calling for.
Got it working, but i'm still not sure why it required the instantiation transform to be in function format.
▚▞▚▞▚▞▚▞▚0 -
It's much better if you share a link to the document. I suspect that the issue is actually in the part of the code you shortened -- you declared transform as a variable and that hid the transform function you're trying to call.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc1
-

