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.

Table (New Custom Feature!)

MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
edited December 2022 in FeatureScript

Table (New Custom Feature!)

https://cad.onshape.com/documents/01485b6de17aef414a25e778/w/926dfaef6b63d239b8d9d739/e/fb5da00aa581ddc9c53c4379?renderMode=0&rightPanel=cutlistPanel&uiState=6398b9684c6d6f30a465a5b1

Table allows you to:

  • Import CSV data
  • Manually input data
  • Store data as a custom table
  • Store data as a Cutlist table so it can be inserted into a drawing

Special thanks to @NeilCooke for creating the native Cut list feature which allows this feature to get tables to drawings.

If you use Onshape for work, consider saving hours of work by automating your process with custom features and API.
CADSharp specializes in custom features and API.









How to add this 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 🔴

Comments

  • romeograhamromeograham Member, csevp Posts: 676 PRO
    Nice!
    Michael - do you think we could use Variables or Custom properties in the tables, like so?


    I guess you need to allow "use expression" in the Value field...something like that?

    Thanks!
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO

    Great feedback @romeograham!

    Currently it is set to string / text only. Expressions would be excellent to have, I'll include this in the next update.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • sebastian_glanznersebastian_glanzner Member, Developers Posts: 422 PRO
    @MichaelPascoe
    You created a composite part to display "Table data"!
    Is this the easter egg?
  • sebastian_glanznersebastian_glanzner Member, Developers Posts: 422 PRO
    Or that you allow "11" columns? B)
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited December 2022

    @sebastian_glanzner You got it. Normal table features might only go to 10 columns.. This one goes to 11!

    https://www.youtube.com/watch?v=4xgx4k83zzc

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • romeograhamromeograham Member, csevp Posts: 676 PRO
    Fantastic @MichaelPascoe - love your responsiveness.

  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited December 2022

    Update!

    • NEW - Table name.
    • NEW - Custom tables panel now supports multiple tables.
    • NEW - Check box to simplify part for drawing. This reduces primitive count from over 3000 to 13.
    • Moved "Cut list" check box near the top of the UI.
    • "Cut list" composite part data is now named.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited January 2023

    Update!

    • NEW - Export to Excel (via JSON)
    Simply right click the JSON to copy. Paste it into whichever conversion software you like (JSON to Excel).




    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Chris_D_Mentes_001Chris_D_Mentes_001 Member, csevp Posts: 102 PRO
    Oh very nice! Thank you
  • jeff_brown304jeff_brown304 Member Posts: 23 ✭✭
    Oh that JSON export is cute!

    I spent a little time experimenting with how to export significant amounts of data from a custom feature in a Parts Studio.  Unfortunately, it looks like Custom Tables and the Variables Table truncate data for display in the UI after a few hundred characters or so and they also return truncated results when using the "Copy to Clipboard" action.  So that's no good.

    It looks like you're using a parameter in the feature editor.  I played with that too and I managed to shove about 100 KB in there (which really surprised me!) but I suspect it'll cause stability issues if I push it too far.  It's cute that it works but it doesn't seem scalable.

    Unfortunately I can't embed newlines in a way that will survive copy-paste so for my purposes I'm going to try writing a custom app so I can have a more convenient download button and not risk overloading the UI.  Creating a custom app has lots of other advantages although the barrier to entry is significantly higher.
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO

    @jeff_brown304, good info. And legit! let me know how it goes.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • SethFSethF Member Posts: 130 PRO
    Looks like the expression driven approach overwrites the expression with a string? Which makes it so it doesn't update with changes to the variables used.
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited January 2023

    @SethF, Switch to expression first, then type the expression.

    I have it set to try and convert the expression to string and vise versa. I'll take a closer look. Sounds like it isn't working how I intended.

    There we go, see if that is better. It will not try to convert the string to expression, so there should be less confusion now. It will try to convert expression to string if you go the other way.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • SethFSethF Member Posts: 130 PRO
    There we go. Before it seemed like it was overwriting whether or not I ever hit boolean again after setting the expression. But now it looks like it's maintaining those expressions as long as you don't switch it back and forth. Thanks!
  • EvanReeseEvanReese Member, Mentor Posts: 2,125 ✭✭✭✭✭
    This is great incentive for us to add functionality like importing custom tables into drawings.  Because if we don't, our users do stuff like this  :)
     :D
    Evan Reese
  • jeff_brown304jeff_brown304 Member Posts: 23 ✭✭
    edited January 2023

    @jeff_brown304, good info. And legit! let me know how it goes.


    So I’ve made a lot of progress on my CAM features and I’ve come up with two good solutions for getting substantial amounts of data out of Part Studios.

    One solution was to simply use println() to dump the data to the Notices area from which the user can then copy-paste.  I have a checkbox to do this in my G-Code post processor.

    And the much more convenient solution was to store the data into variables in the context and write an app to get the data out.

    So I did that.  My G-Code post processor feature stores its generated files in variables along with a file index. My app’s user interface gets embedded into OnShape as a right side element panel for Part Studios and it provides links to download or view the files.  Click a link, receive a file, it’s that simple!

    Here’s the code for my app.  It handles authentication with the OnShape API and presents the panel.  If you had a whole ton of JSON or CSV or other data to export from a custom feature then something like this might do the trick!

    (Or instead of writing an app, yet another alternative might be to write a shell script to download the data from the OnShape API using ‘curl’.)

    Source: https://github.com/j9brown/camel 

    Aside: I’m planning to make a more formal announcement of my CAM features after I work out some more bugs and limitations and write some documentation. So let’s keep the conversation here focused on Michael’s cool new feature!
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO

    @jeff_brown304 wow, cool! Don't worry about my feature, it is a temporary plug while we wait for the real deal. But hey, have any GIFs? I would love to see this neat app and features in action. 


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Javier_López_del_PueyoJavier_López_del_Pueyo Member Posts: 74 PRO
    I've been looking for ways to automatize property asignation through FeatureScripts and I've always come to the same conclusion: i need a database that is native in OnShape so I can query its information. Could this Table FS be the solution I have been looking for? Could that be a reasonable use case?
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited February 2023

    @javl0p_2, this is more for viewing the data you already have in a custom table. However, what you are describing is possible. It will all depend on how automated you want your process to be and where you want to store your data.

    A very manual workflow might look like this:
    • Store all of your data in a google sheet.
    • Copy and paste that sheet into a Variable studio.
    • Now you can access that Variable studio from any Onshape document. 
    • Use custom features to assign those variables to the corresponding properties of your part.
    There are entire systems for automating processes like this so that you save time and don't have to do any repetitive work by hand. Let me know if this is for your company and I can connect you with CADSharp.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Javier_López_del_PueyoJavier_López_del_Pueyo Member Posts: 74 PRO
    Ok, Variable Studios also seem like a fairly good choice, I'll check them out.

    Thanks!
  • Alex_PittAlex_Pitt Member Posts: 65 PRO
    This is fantastic! Great work @MichaelPascoe !
  • Kyle_BurtKyle_Burt Member Posts: 11 PRO
    @MichaelPascoe I've been heavily utilizing your FS (thank you!)

    With Onshape's recent addition of the Tolerance column in an Inspection Table, I wanted to see if you think it's possible in your code to add the ability to exclude that column (or any other column) after a csv is read and before the cut list is created?  I've been combing through your Feature Studio, but can't quite figure out how to make it work (figured it might involve skipping over a specific column number from the csv...)


    Thanks again!
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO

    @Kyle_Burt Glad you like it! 

    So the ability to ignore a selected row or column from a csv?


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
    This featurescript works pretty well - the main issue I'm having is that when I enter in an expression into a cell sometimes the expression or variable gets erased and replaced with a static value (usually the last value of that specific variable when I edited the table). Is there any way to prevent my formulas or variables from being erased out of the table?
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited April 2
    @Sam_Schlageck this is a bug, I'll look into it. In the mean time, you can use Onshapes built in way to do this.
    • While keeping the input in (abc) mode, right click the input box > convert to expression.
    • Place your variable within a toString() because the expression has to result in a string.
    EDIT: After trying this some more, it appears that edit logic or arrays is breaking expressions. The try catch doesn't work either. I'll continue the search for a way to fix this.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    edited April 2

    Update!

    Thank you @Sam_Schlageck for providing feedback which triggered this update.

    There is currently a bug related to editing logic and arrays that breaks expressions. 
    To account for this, I have changed the opposite direction button to a check box which avoids using edit logic.

    TLDR: With this update, variables will no longer break when adding new rows or clicking buttons.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
    Awesome! Thanks for looking into this @MichaelPascoe !

Sign In or Register to comment.