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.

Using Feature Script someone else wrote?

dean_mulladean_mulla Member Posts: 7 EDU
I'm trying to use @lemon1324's Laser Joint Feature Script but am completely new to Feature Scripts.

It's not at all clear to me how I can access his Feature Script from my document/assembly/part studio.  I tried to copy the code for the 3 Feature Script files he has into my own (and rename to the same name and change the import statements to work with these new paths/locations).  However there is still a FeatureScript Laser Utils/V5.0/Laser Utils Feature Script for which I don't know how to get to it or how to find it - it is imported using 3 hashes but I can't figure out where they really are to get the code for them.

Or am I going about it completely incorrectly and I don't have to actually create copies of the Feature Script documents at all?

Thanks for any help/tips/pointers.

Best Answers

Answers

  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    You'll need to also update the versions of his FeatureScripts you have to point to the versions you've copied over. In particular, an import is simply a static reference to the ids which define where a document is located in Onshape. When you copy and paste his code, you copy and paste the imports, so they won't automatically update to point to the other feature studios you've copied and pasted. To fix this, delete the imports, then use the import button in your toolbar to re-add the imports, this time choosing the new version of the feature studios you've created. For example, if the previous import pointed towards his Laser Utils/V5.0/Laser Utils FeatureScript, then you'll need to delete that import and re-add it so it points to the Feature Studio you've copied Laser Utils FeatureScript into.

    Remember to also pay attention to the export keyword, which may be required if enum declarations or editing logic have been broken out into a separate document.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • MichaelPascoeMichaelPascoe Member Posts: 2,028 PRO
    edited August 2022 Answer ✓
    @Alex_Kempen is right. 

    Also, if you simply want to add a feature to your toolbar, you can just click the "+" button at the top of the document that has the featurescript.



    How to add a custom feature to your toolbar:



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • dean_mulladean_mulla Member Posts: 7 EDU
    Thanks!  The video from @MichaelPascoe really helped.

    So my next question - the FS only shows up in PartStudio, not in an Assembly.  Is that expected?  i.e. is it only expected that the FS can operate in a PartStudio and cannot edit in context in an Assembly?

  • dirk_van_der_vaartdirk_van_der_vaart Member Posts: 549 ✭✭✭
    edited August 2022 Answer ✓
    Edit in context open's a new part studio.
    And yes FS only works in part studio's
  • MichaelPascoeMichaelPascoe Member Posts: 2,028 PRO
    edited August 2022
    @dean_mulla FS are only for Part studios.

    However, like @dirk_van_der_vaart said, while in your assembly, you can right click a part then select "edit in context". This lets you edit that part in the current context of the assembly. Here is a useful self paced course from the Learning Center: In Context Design

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
Sign In or Register to comment.