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 extrude imported parts with a featurescript

I am making a featurescript that generates some parts to make the CAD process faster for my FRC team and I'm not sure how to extrude an imported part. I want to make it so that you can change it's length based off a definition.length inputted earlier in the featurescript. This is my first time doing a featurescript so the answer might be obvious but I just don't know what to do yet. If someone could point me to the right documentation or give me some examples that'd be greatly appreciated.
Code Snippet I have for the import of the 8020 part I want to extrude
if (definition.materialSelection == materialChoice.eightyTwenty)
{
startVec = evVertexPoint(context, { "vertex" : definition.startPoint });
if (definition.generationChoice == generationType.TWO)
{
endVec = evVertexPoint(context, { "vertex" : definition.endPoint });
dir = normalize(endVec - startVec);
dVec = endVec - startVec;
normDVec = norm(dVec);
}
if (definition.generationChoice == generationType.ONE)
{
csys = evMateConnector(context, { "mateConnector" : definition.startPoint });
dir = csys.zAxis;
if (definition.reverseDir == true)
{
dir = -1 * csys.zAxis;
}
}
if (definition.generationChoice == generationType.ONE)
{
if (definition.eightyTwentyType == eightyTwentyTypeOptions.ONE)
{
addInstance(instantiator, eightyTwenty1x1::build, { "transform" : thingTransform });
instantiate(context, instantiator);
}
if (definition.eightyTwentyType == eightyTwentyTypeOptions.TWO)
{
addInstance(instantiator, eightyTwenty1x2::build, { "transform" : thingTransform });
instantiate(context, instantiator);
}
}
if (definition.generationChoice == generationType.TWO)
{
}
}
Any tips on how to layout this differently would be greatly appreciated as well since this is one of my first featurescripts so any advice or tips would be greatly appreciated.
Comments
Here is a simple example of how to instantiate a pre imported part as well as letting the user choose like a derive:
https://cad.onshape.com/documents/bf218127a4290c050e205e75/w/42342e313f737ad5d1388f67/e/26b5c545d60a0412c45a7108…
And here is a more complex example showing how to access configurations and drive them with maps:
https://forum.onshape.com/discussion/26452/product-catalog-new-custom-feature…
.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
I might be reading your question wrong, but if you're working with 8020 profile and want variable length parts in a studio, can't you just use the default frame tool with 8020 profiles, or your own custom frame library? Or is this the basis of a more advanced script?
Thank you so much for the examples! I managed to get it working and I figured it out thank you so much I really appreciate it. I hope you have a great rest of your day.