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.

Select Configuration States using the URL?

owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
Hi all.
Please forgive me if this has been discussed elsewhere.
I was wondering is it, or will it be, possible to select a PartStudio Configuration via its URL?
Example:-
Here I have a dummy part with a pair of configurations.


What I'd like to be able to do is have a non cad user be able to open a configuration directly from a hyperlink along these lines:-
cad.onshape.com/documents/12345/w/678910/&HoleQty3&BracketWidthLarge

Background:-
I'm changing roles within my company and will no longer be designing stuff.  Instead I'm building some software to handle the thousands of possible configurations our products can be ordered in.  This will allow our sales team to see what it is they're asking for and for our purchasing and production departments to understand what has been sold...
Long term this might end up as a web portal using the Onshape API to return configurations, but shorter term it'll be a desktop application.  An easy win from my point of view would be for my system to build a string for the configured part/assembly and spit it to a web browser. 
Thanks all,
Owen S.
 
Business Systems and Configuration Controller
HWM-Water Ltd

Comments

  • john_mcclaryjohn_mcclary Member, Developers Posts: 2,870 PRO
    I think @billy2 has done something very similar on rusty shed. 
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    edited December 2019
    I think @billy2 has done something very similar on rusty shed. 
    Yea, his site is verrrry nice using the API's. 
    I have a steep learning curve for some other stuff at the moment so don't intend diving into the API's for a while.  Hoping the URL method will be viable as that's pretty simple, but still allows all the conditional logic and numpty-proofing to be contained within my software so isn't dependent on Onshape doing the working out what to show, just the actual showing of the "dumb configuration".
    Cheers, Owen S.

    Business Systems and Configuration Controller
    HWM-Water Ltd
  • TimRiceTimRice Member, Moderator, Onshape Employees Posts: 264
    Currently the only way to get the config url is to open the Share dialog with whatever config you want active and then momentarily turn on Link sharing:



    This adds the config parameters to the url.
    Tim Rice | User Experience | Support 
    Onshape, Inc.
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    TimRice said:
    Currently the only way to get the config url is to open the Share dialog with whatever config you want active and then momentarily turn on Link sharing:



    This adds the config parameters to the url.

    Thanks for the reply.  I was worried you'd say that. :/   With an infinite number of potential configurations that unfortunately doesn't fit this particular use case.  (Sales personage sitting with a customer and building their quotes / orders in front of them.)

    Just out of interest if I were to be able to mimic what the link would contain had I have created it manually as above, would my constructed link work, or does the process above set some stuff on your end?  
    Cheers, Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 3,186
    Absolutely it works. Don't forget you can rename input tables from the 3 dot menu => "Edit FeatureScript IDs..." to make URLs easier to construct.
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    edited December 2019
    NeilCooke said:
    Absolutely it works. Don't forget you can rename input tables from the 3 dot menu => "Edit FeatureScript IDs..." to make URLs easier to construct.
    Hi Neil. 
    That's AWESOME :)
    Thanks fella :+1:
    For anyone following along we can edit the ID's as Neil indicated above.  Below you'll see some friendly names have been set both for the configuration option's description and the possible values.


    Which in turn gives a friendly URL parameter like so:-
    (Question) Just out of interest what does the "%3D" represent?
    Also to answer my own question above.  I used the "generate link" with in the share to get "config1" as a URL and was able to edit that and open other configs without having to set each individually.  Even more awesome.
    Happy Onshaperist here.
    Thanks folks,
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 3,186
    %3D is the hex ASCII character for =
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    NeilCooke said:
    %3D is the hex ASCII character for =
    Doh, thanks Neil.
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    OK, this has promise.

    Tiny demo app that will open an instance of chrome and show the user a part configured in onshape to their specification:-
    No servers, no HTML, no API, just 30-ish lines of code.
    Onshape you should be shouting how easy this is from the rooftops!
    Now to do it with some real products...
    Owen S..


    Business Systems and Configuration Controller
    HWM-Water Ltd
  • 3dcad3dcad Member, OS Professional, Mentor Posts: 2,442 PRO
    @owen_sparks
    I suppose you are feeding configurations manually into your application? Would be awesome to fetch the list from Onshape..

    I'm pretty much in same position 'code wise' as you - I can create local/web database applications but don't have enough time to dive into API even though I would like to.. 
    //rami
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    3dcad said:
    @owen_sparks
    I suppose you are feeding configurations manually into your application? Would be awesome to fetch the list from Onshape..

    I'm pretty much in same position 'code wise' as you - I can create local/web database applications but don't have enough time to dive into API even though I would like to.. 
    Yeah it's all manually entered for now.  It looks like I'll have a significant amount of time to throw at this project so I'm optimistic it'll yield some good results.  The 30 lines of code has gone up a bit over the last couple of days 😉. I'll have something to demo in the new year.

    Currently I'm working with partstudios not assemblies (because featurescript, and I like PS configs). Composite parts look really interesting and so very nearly do what I need but I'm not quite there yet, or they're not, can't tell which yet!

    More to come.
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Hi folks,

    This may or may not be of interest but will post just in case it helps someone out in the future. :)

    Finally had a chance to have a look at this some more.  Initially I was just sending the url to a new instance of chrome, however this seems to be better.

    There is a Nuget package called "CefSharp" that is a wrapped version of chrome, which means that unlike the built in web-browser this one is actually WebGL compliant.

    Hardware Check:-

    Which can lead to some of this:-

    Obviously this leads to some vulnerability as far as updates to chrome but if you want a WinForms application to have some CAD data to hand this seems a reasonable approach.

    Cheers, Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • john_mcclaryjohn_mcclary Member, Developers Posts: 2,870 PRO
    Sweet
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 1,845 PRO
    edited January 9
    @owen_sparks

    Would you be able to use Microsoft's WebView2 control that uses Edge Chromium?
    https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2

    EDIT: Added URL
    MB - I make FeatureScripts: View FeatureScripts
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Thanks @MBartlett21 I'll have a read.
    Cheers,
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Hello @harmanpa
    Thanks for the information, that look great.
    Thanks for sharing.

    Cheers,
    Owen S.


    Business Systems and Configuration Controller
    HWM-Water Ltd
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,452 PRO
    @harmanpa

    good job on your configurator, nicely done



  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,452 PRO
    edited January 16
    I just noticed that I still had access to Bill Schnoebelen's onshape document. 

    Big deal?

    So Bill and I were working together on the idea of a web based configurator and came up with this about a year ago. It's still running. He shared a document with rustyshed that had configurations defined and I parsed the configuration tables into html, displayed on a  website and allowed web based changes to his part.

    All that was required was for him to share the document with me and in return it gave the world access to his configured document. He could change the document at any time and then the world would have more options.

    https://rustyshed.com/?route=circuitCase

    I think Owen is looking for url configuration endpoints.

    All the options under the sun will require access to a web server and a little code. harmanpa did a great job. I'm waiting for the API access call to gltf for the display list information. Currently you have to convert STL data over to webgl which is more work than necessary. harmanpa how did you do it?

    You can manually export gltf and then paste it into some code, but I'm waiting until I can download it through the API. Maybe it's possible now. I haven't ckecked lately.



  • harmanpaharmanpa Member, User Group Leader Posts: 7 PRO
    The configurator demonstrator uses STL exported for each part, the reason for exporting parts individually is that we detect the changes in the assembly structure when the configuration changes so only download geometry where necessary.
    It is however now possible to export GLTF via the API, it requires calling the createTranslation method (which is asynchronous).
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,452 PRO
    Thanks, I was looking for the method the other day and couldn't find it. 

    Is GLTF the way to go? A year ago I was working on a webgl interface and read about GLTF at the khronos group. That's when I put a ticket in to get GLTF inside OS.

    With STL you don't get materials or colors; do you keep track of color, material & STL for each part? It's a lot of work to get STL working. 

    I've downloaded your example; thanks for putting it together.

    Does GLTF offer up anything better?. Could you send the whole assembly and it'd render properly? Would it render like it does in OS?


  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,452 PRO
    edited January 19
    This API is a mess.....

    Here's the trail of methods available for translating an element type assembly:


    Get Element Translator Formats


    Here's the translation name GLTF listed in the returned "Body"; make sure it's capitalized.



    Create Assembly translation



    All looks good, look at the returned "Body"


    Goto the async callback location


    Says there's an error. 


    Change it to translate STEP



    So I can translate a STEP but not a GLTF.



    I think I'll go back into hibernation until they clean this API up and support it better.



Sign In or Register to comment.