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 to make a duplicate of a part in featurescript
leti_ryder
Member Posts: 7 EDU
Hi guys!
I am trying to make a duplicate of a part in featurescript, I am using opPattern which requires a transform input. I am not sure what to enter.
I am trying to make a duplicate of a part in featurescript, I am using opPattern which requires a transform input. I am not sure what to enter.
var bfsBody = qCreatedBy(sketchId + "revolve1", EntityType.BODY);
var bfsBody = qCreatedBy(sketchId + "revolve1");
debug(context, bfsBody);
opPattern(context, id + "pattern1", {
"entities" : bfsBody,
"transforms" : transform(vector(1, 2, 50) * millimeter),
"instanceNames" : "scaled_body"
});
0
Answers
-
I believe the input for "transforms" is an array of transforms. So you'll need to add brackets [] around the transform command to turn it into an array of one transform. The transform dictates where exactly the copy is going to be placed. In your example, you're using a transform with a single distance vector input of (1, 2, 50) * millimeter. That means your copy will be moved 1/2/50mm in x/y/z. Check out the documentation at the link below for details on more complicated transforms involving scaling/rotation along with specific syntax.
https://cad.onshape.com/FsDoc/library.html#module-transform.fs
0 -
Echoing @mahir. opPattern needs a "transform" of some sort to know what to do with the new item.
The transform and the name must be in an array [ ]. You can transform the new patterned entity to its original position like this:var bfsBody = qCreatedBy(sketchId + "revolve1", EntityType.BODY); var bfsBody = qCreatedBy(sketchId + "revolve1"); debug(context, bfsBody); opPattern(context, id + "pattern1", { "entities" : bfsBody, "transforms" : [transform(XY_PLANE, XY_PLANE)], "instanceNames" : ["scaled_body"] });
If you wanted to pattern multiple items the transforms and the names must be separated by a comma:var bfsBody = qCreatedBy(sketchId + "revolve1", EntityType.BODY); var bfsBody = qCreatedBy(sketchId + "revolve1"); debug(context, bfsBody); opPattern(context, id + "pattern1", { "entities" : bfsBody, "transforms" : [transform(XY_PLANE, XY_PLANE), transform(XY_PLANE, XY_PLANE), transform(XY_PLANE, XY_PLANE)], "instanceNames" : ["scaled_body1", "scaled_body2", "scaled_body3"] });
RENDERCAD
rendercad.ai - Photorealistic product rendering.
▚▞▚▞▚▞▚▞▚
________________________________________________________________________1 -
Michael is right on the money here. If you don't want to move it in any way you can use identityTransform() to make a transform that doesn't do anything instead of transform(XY_PLANE, XY_PLANE)1


