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.
Setting custom variable values for part studio imported into feature script?
victoria_meerman
Member Posts: 2 ✭
I am new to feature script: I've followed a lot of tutorials and become a bit overwhelmed at trying to something that is likely very obvious and simple.
I have a part studio that ends with a linear pattern. I'd like to turn it into a feature script so I can call it in other studios and set the number of repeats. I've finally gotten my script to recreate my original part studio parts, but I am not sure how to pass user defined repeat numbers.
Here is my code below. (I apologise for the butchered script copied from various tutorials and forum answers). The variables in my original part studio were called "#nlong" and "#nwide" and set the number of repeats in two directions for my linear pattern.
FeatureScript 2180;
If anyone can suggest further tutorials, other helpful posts, I will be very grateful!
I have a part studio that ends with a linear pattern. I'd like to turn it into a feature script so I can call it in other studios and set the number of repeats. I've finally gotten my script to recreate my original part studio parts, but I am not sure how to pass user defined repeat numbers.
Here is my code below. (I apologise for the butchered script copied from various tutorials and forum answers). The variables in my original part studio were called "#nlong" and "#nwide" and set the number of repeats in two directions for my linear pattern.
FeatureScript 2180;
import(path : "onshape/std/common.fs", version : "2180.0");
gfbinbase::import(path : "d2a068a57d0ba244eb45d72e", version : "e8086df0e3d24d26ffa92a3b");
annotation { "Feature Type Name" : "gfbinbase" }
export const gfbinbase = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "nwide" }
isInteger(definition.nwide, POSITIVE_COUNT_BOUNDS);
annotation { "Name" : "nlong" }
isInteger(definition.nlong, POSITIVE_COUNT_BOUNDS);
}
{
// Build a thing in a separate context
var contextWithThing is Context = gfbinbase::build();
// Add thing's context to the current Part Studio
opMergeContexts(context, id + "gfbinbase", {
"contextFrom" : contextWithThing
});
});
If anyone can suggest further tutorials, other helpful posts, I will be very grateful!
1