Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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

Rhett_RobinsonRhett_Robinson Member Posts: 130 PRO
edited October 2 in FeatureScript

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

  • MichaelPascoeMichaelPascoe Member Posts: 2,012 PRO
    edited October 2 Answer ✓

    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 🔴

Answers

Sign In or Register to comment.