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.

Custom Frame FS without precondition

marcus_schaefermarcus_schaefer Member Posts: 4 PRO

Does anyone know how to implement a custom frame in featurescript without using the precondition/UI? I found the FS for the frame tool in the std documentation that uses the UI, and I am wondering if it's possible to create a frame without it. For reference there was a post in here on Sept 4 about a custom Frame: FS Frame — Onshape, I essentially want to create a custom frame feature using a line I have already defined in featurescript as the path, and then choose one of Onshape's standard library sketch profiles.

Comments

  • Caden_ArmstrongCaden_Armstrong Member Posts: 149 PRO

    The short answer is yes, you can implement a custom frame without using any of the existing frame features. If you read through the frame.fs code in the std library, in the most basic sense the frame feature is some profile extrudes, cuts, and stored metadata. If you make some geometry and correctly apply the frame attributes it should work just fine. But I wouldn't recommend it.

    Using the existing frame feature does a lot of the heavy lifting for you. If you want to create topology that the current frame features aren't capable of - you might need to make your own feature. But if you are just looking to short cut/hardcode some of the inputs, you can use the frame feature inside of your feature with the "selections" set to your existing path and then either hard code the rest of the inputs or pick which ones should be exposed to the user.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • marcus_schaefermarcus_schaefer Member Posts: 4 PRO
    edited October 23

    I imported the frame.fs into my custom frame FS and realized I can make a frame using the frame(context, id, definition) function. Regarding the definition, I can pass just the "profileSketch" and "selections" to create a frame (go this to work using a precondition). I then created a sketch of a line segment with FS, and instead of passing the query stored in definition.edges, I can use a query to get my sketch entity base on it's id - this works as well. My issue now is figuring out how to 'hard code' the PartStudioData that's required for the "profileSketch". I still want to reference Onshape's standard library for frame profiles but I don't know how to extract that specific data/configuration/sketch as PartStudioData.

    I currently have the partStudio for a frame profile (MC-shape) imported into my FS and know exactly which, document, partstudio, configuration and thus sketch I want to use as my sketch profile, but I'm not sure how to get this as specifically the PartStudioData type. I'm assuming this falls under an application of 'Reference parameters' but all the examples use the precondition/UI to get the to get PartStudioData. Do you know if it's possible to get this without the user-selection?

  • Caden_ArmstrongCaden_Armstrong Member Posts: 149 PRO

    I forgot hardcoding PartStudioData to the frame library isnt exactly straight forward.

    First step: check out this sample document I made:
    https://cad.onshape.com/documents/a2b5b75e5174310d936a970c/w/808034fae6b6481349311183/e/60b8daf9eb1a25c9d740c667

    You have to import the correct part studio, and construct your own PartStudioData object by providing a build function and a query (and config if relevant).
    If you want a custom profile, just import your own part studio containing an origin centered sketch.

    If you want the onshape standard library, its a bit tricky because you need to find the document that has all the frame profiles, but Onshape does a good job of hiding them.
    Open the test feature, and use the PartStudioData input to select the frame that you want.
    Then, right click your part studio and do "show code". Find the definition of your feature, and the input for the frame.
    Part of it will be the "namespace" of the frame. Something like:

    "buildFunction" : d1828c2eb863ee177b5a1d699::v3c4bdd532757091960c24147::e56edb720718e8472f9247fc3::m5bbec7fb947ae50c13245ba7::build

    And you need to reconstruct it into a url like below:

    "buildFunction" : d1828c2eb863ee177b5a1d699::v3c4bdd532757091960c24147::e56edb720718e8472f9247fc3::m5bbec7fb947ae50c13245ba7::build

    becomes:
    https://cad.onshape.com/documents/9ea71701c83a78369e7ad711/v/ef1588c32a12e203c03f1a34/e/9b103177fb0b31ee035310d5
    careful to check that each ID starts with an extra character, d/v/e.

    Find the correct tab, and then import it into your featurescript (for example, see line 7 where MYPROFILE is the namespace of the profile I picked).
    I do this by opening the tab, and then going back to my featurescript and clicking "recently opened", or just copying in the URL.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • marcus_schaefermarcus_schaefer Member Posts: 4 PRO

    Awesome, works great. Thanks!

Sign In or Register to comment.