Chain Featurescript - Game Design Challenge

Hi folks!

The PTC Education team is proud to release this simple chain featurescript! Given the heavy chain component of the Game Design Challenge, we hope this tool will make your life easier as you work to include chain in your models.

Simply select your chain size and the edge/curve/path you’d like the chain to follow. This workflow gets particularly easy as you get the hang of the 3d spline and bridging curve tools which allow you to build complex curvature given just points.

Chain FS Gif

You can find it in MKCAD - Featurescript when searching public documents. Plenty more functionality is on the horizon though I wanted to release this progress now so teams can start using it. Let me know if there are improvements or other sizes/types of chain you’d like to see!

Here’s a sample document

16 Likes

that sounds cool

1 Like

I got a message asking how this FS works. Posting here in case anyone else is curious. More featurescripts on the way soon so shoot me your requests.

Featurescript, for folks who may not know, is the programming language that Onshape developers use to write the standard features like extrude and fillet. Because this language is public-facing, anyone can use featurescript to make a custom feature like the one I’ve made above. This can be used to automate repetitive tasks, create custom funcitonality, and make your life much easier in Onshape!

In this particular featurescript I want to generate a path of chain links across a given curve.

Featurescripts start with parameters - what inputs do you want the feature to work with?


The top lines are the building blocks for this particular feature and the precondition{} takes the parameters. In english, this is saying, I want a parameter called Chain Size which allows the user to pick from array/enum Sizes. This faces the user as a dropdown from options I listed prior and their choice is accessible as definition.size. Second, I have a parameter called Chain Path, the query term prompting the user to select geometry and only accepting a single edge. This is later accessible in the code as definition.chainPath.


From there, we move into the main body of the code. I start by evaluating the length of the curve with evLength() which calculates how many links to do. I also use evEdgeeTangentLine to create a reference tangent line which serves as the angle for the first link. After that, I build a new coordiante system around the origin and tangent line of the curve so that it’s easy to place and pattern the chain link. Once that’s defined, I use the instantiate operation to create two links, one rotated 90 degrees and further along the path from the other.


Now that we have two links exactly where we want them, I build a curvePattern to pattern them along the inputted curve. The number of links is calculated in the variable “flor” which is effectively dividing the curve length by the ideal chain link spacing. curvePattern2 has a lot more links because patterns start at the edge - I go back and delete every other instance later in a for loop.

Hope this is helpful to some. Feel free to shoot questions or feature requests my way!

5 Likes

@marcusbernstein many thanks for sharing this.

During crunch time, our cad lead student was able to quickly add chain to the field element just before submission !

5 Likes

Very stoked to hear! Great work and glad I could help

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.