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.
Beginner FeatureScript Help + Circular Pattern
Onshape Document: https://cad.onshape.com/documents/e14506ff4d20585b290e1eb9/w/f810b9cde10509e5ce6e5ed7/e/e9f37d1a61a2dd62e3b9d8fb
After being interested in writing FeatureScripts but daunted by the task of learning it with zero coding experience whatsoever, I am knee deep in my first FS that isn't a step by step or hand holding example (I have done these tutorials so far: Building a Complete Custom Feature (FeatureScript) (youtube.com) and Create a slot feature (onshape.com). I have been able to incorporate what I have learned from these to get started on this one.
. What I am trying to accomplish can be seen in the tab "What I Want". I am creating a cut slot spec that has two options, 1 or 3, to cut into an existing tube based off of a mate connector selection. I have been able to achieve the one slot option (minus the filleted edge, haven't thought that one through yet), but am struggling with the 3 slot pattern. Based on some forum searching I think I am close, but I am not sure if my query for the axis of rotation is correct. I would like it to be the z axis of the initial mate connector that is queried, definition.MC. The other difficulty I have is that the slot for the 3 slot option needs to be opposite from where the 1 slot is cut. I think that creating an if else statement would allow me to flip the direction of the extrude, but I am still not solid on those. Any suggestions would be awesome, I am finding that there is a missing link between what I am learning/understanding vs. where I want to be. I am hopeful that I can crack it soon.
I do wish that the FeatureScript documentation had actual snippets and examples of each action (not sure of the correct vocabulary still), since it seems you either have to search the forum for an example within code or existing FeatureScripts.
Thanks in advance for any feedback or help!
Best Answer
-
MichaelPascoe Member Posts: 2,012 PRO
There are operation function opPattern(), and then there are the entire feature circularPattern. You are trying to call the entire circular pattern feature. In order to do this, import the circular pattern feature near the top of your feature studio. You can find a link to it from the Onshape standard source library then use the import button in your feature studio, or just copy and paste this code here near the top of your studio:
import(path : "12312312345abcabcabcdeff/86a9b34c22ba3251e92c1f5c/5e639eb1b1834188ae46203a", version : "9794c5cb592df70947a5e891");
-
Then, change the axis you were trying to do with just the definition.MC:
"axis" : definition.MC,
-
Here is a copy of your document with these changes: https://cad.onshape.com/documents/afde563c059443a83a78fd93/w/c48c5a0c…
-
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴0
Answers
There are operation function opPattern(), and then there are the entire feature circularPattern. You are trying to call the entire circular pattern feature. In order to do this, import the circular pattern feature near the top of your feature studio. You can find a link to it from the Onshape standard source library then use the import button in your feature studio, or just copy and paste this code here near the top of your studio:
-
Then, change the axis you were trying to do with just the definition.MC:
-
Here is a copy of your document with these changes: https://cad.onshape.com/documents/afde563c059443a83a78fd93/w/c48c5a0c…
-
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Oh, and I started making some FeatureScript video lessons that will help people get into FS: https://www.cadsharp.com/onshape-featurescript-video-tutorials/ These will take you from zero FS and coding knowledge all the way to more advanced topics. It's a work in progress so expect to see more lessons soon.
-
Also check out Onshape's own FS fundamentals course here: https://learn.onshape.com/courses/featurescript-fundamentals Both courses have different teaching styles and cover different topics.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
@MichaelPascoe thank you for the quick response, this is extremely helpful and I'm really excited to go through your videos! I've admired yours and others' knowledge on FS for a while, so I am happy to be making progress on my own abilities.
@MichaelPascoe Dude these are awesome! I know this will help many people dive deeper into FS. These are the kinds of resources I wish I had when I started in FS all those years ago. Looking forward to more in the series.
chadstoltzfus@premiercb.com
@Rhett_Robinson Your off to a great start. With some practice, you will have it down in no time.
-
@chadstoltzfus Thanks man! Me too. Would have saved so much time. With all of the different resources now, it's much easier to start making custom features.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
***EDIT: I finally found what it was right after posting. I wasn't reading my enum correctly. Lesson learned!
I have made the changes, and the circular pattern still doesn't seem to be working. I'm not getting an error in the FS, but it doesn't seem to be generating the new bodies. Am I missing a required parameter?