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.

WHERE USED

shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
I have tried using this feature on and off since it was release to professional accounts.  I have never really felt I was actually getting accurate results from it.  I very often get a report that the released item is not included anywhere even though I know it is included in a drawing.  Is it possible the where used command is still in "beta" mode or something, or am I possible just an idiot and not understanding how to use it.  I do a search, select the release from the results and then select where used from the side panel.  Most of the time the results are empty or not used anywhere.
As a little extra question, can we access where used from the api?  I'm thinking not as I am not seeing anything about it in glassworks.  It would be really useful if we could.  Having an app pull out a release and also show a list of all the drawings that have been made that include the release would be very powerful.
Tagged:

Best Answer

  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    Answer ✓
    @dsteinegger
    Where used can be done via the api with:

    GET /api/productstructure/whereused?configuration=...&documentId=...&elementId=....&workspaceId=...

    Theres some other parameters that can be included in the url such as:

    partId
    partNumber
    useLatest
    includeProperties
    includeVersionInfo
    and probably more that I havent figured out yet.

Answers

  • tim_hesstim_hess Member Posts: 46 ✭✭
    I know I've seen some different behaviors in assemblies when you reference a "released part" versus "a version that contains a released part". I could imagine something similar happening if you add a part to a drawing and then release the drawing and part together. Then, drawing<->part link might be a link to a version rather then a release, which could mess up the where-used search results (which would be I think would be a bug or oversight). 

    I don't know, I could be way off, thought. 

  • dsteineggerdsteinegger Member Posts: 3 PRO
    @shawn_crocker

    Have you found a way to get a "where used" functionality with the API?

    I'm also looking for something :-) 
  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    Answer ✓
    @dsteinegger
    Where used can be done via the api with:

    GET /api/productstructure/whereused?configuration=...&documentId=...&elementId=....&workspaceId=...

    Theres some other parameters that can be included in the url such as:

    partId
    partNumber
    useLatest
    includeProperties
    includeVersionInfo
    and probably more that I havent figured out yet.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    Thanks for the info @caden_armstrong.  I was told where used in the API was still traveling down the pipe.  I will have to try that end point out.
  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    @shawn_crocker
    If its not in the official documentation then technically it isn't supported. There is a chance that Onshape could change (or even remove) that endpoint, its also possible that it won't always work as expected. Use it with caution, and don't build any critical apps that rely on it.
  • chadstoltzfuschadstoltzfus Member, Developers, csevp Posts: 128 PRO
    @caden_armstrong
    Have you found a way to do a Where Used without specifying a specific configuration using the API? Almost like a Where Used for a workspace/version id instead of per part. I guess if that endpoint doesn't exist it wouldn't be hard to just loop through all documents in an Enterprise and check import statements but I wonder if there's a better way.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,253
    Remember that where used does not work for workspaces, so even if you have a released part used in a drawing, if the drawing isn't versioned or released then where used won't find it.
    Senior Director, Technical Services, EMEAI
  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    NeilCooke said:
    Remember that where used does not work for workspaces, so even if you have a released part used in a drawing, if the drawing isn't versioned or released then where used won't find it.
    That's a good tidbit to keep in mind.
  • dsteineggerdsteinegger Member Posts: 3 PRO
    But how would a PDM Plugin/App would get the information where a part, Assembly, drawing is used? And if used, which version? etc.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    @dsteinegger
    I am just now, starting to test out how I will use (or is I even can use) the end point noted by @caden_armstrong.  Based on your question, I am unsure of your level of understanding of how the API system functions.  Incase you are not aware, you use something to send a request in the form of a URL to a server.  The server usually sends back information in the form of JSON.  You then take that received data and usually reformat it to your liking using some type of scripting language (JavaScript) so that you can present the received data exactly how you want inside of the application you are building.  For my use, I am planning on having a BOM that allows clicking a button that opens up a modal and displays a list of all drawings that have been made of that BOM item.  Clicking on the item in the list will directly open up the drawing.  In this way I feel it will be easier to have production stations more directly driven off of the onshape bom with out people having to do too much searching and printing onto paper.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    So I did a quick test with https://cad.onshape.com/api/v5/productstructure/whereused?partNumber=P3665.  I used a GET request  It didn't work.  It returned:

    {
      "message": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n\n<html>\n<head>\n  <title>www.onshape.com</title>\n  <link rel=\"shortcut icon\" href=\"/favicon.png\">\n</head>\n<body class=\"page-rec\">\n  <div id=\"wrapper\">\n    <div id=\"content\" style=\"padding:100px;\">\n      <div style=\"padding: 10px; -moz-border-radius: 5px 5px 5px 5px; background: -moz-linear-gradient(center top, rgb(255, 249, 204) 0%, rgb(255, 237, 116) 100% ) repeat scroll 0pt 0pt transparent; font-size: 26pt; font-family: 'QuicksandBook', Helvetica, Arial, sans-serif; text-shadow: 1px 1px 1px rgb(255, 255, 255); line-height: 1.2em; width: 730px;\">\n      Access denied. Click <a href=\"/\">here</a> to go to home page.\n      </div>\n    </div>\n  </div>\n</body>\n</html>\n"
    }

    I sent this out within the same scope and authorizations that are currently setup and working for all my other onshape API interactions which are working.

    @caden_armstrong Are you able to offer any insights?  Am I understanding your comment correctly in terms of structuring the end point?

  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    If I had to guess, the document id, workspace or version Id, and element is are required variables. It's not going to work with just the part number.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    @caden_armstrong
    In your experience, has this worked with the workspace id?  I thought where used only worked at the version level?  I'm sort of confused about the partNumber parameter and why I would supply it if the required parameters already fully define what the part number and revision would be.

    I have used this.  https://cad.onshape.com/api/v5/productstructure/whereused?documentId=5a36e3321c7fa3cc05839659&versionId=f4f5b67beb8ea75b38c948cd&elementId=438bd35730e2b15225e3d60a&partId=RxCD

    and received.

    {
      "message": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n\n<html>\n<head>\n  <title>www.onshape.com</title>\n  <link rel=\"shortcut icon\" href=\"/favicon.png\">\n</head>\n<body class=\"page-rec\">\n  <div id=\"wrapper\">\n    <div id=\"content\" style=\"padding:100px;\">\n      <div style=\"padding: 10px; -moz-border-radius: 5px 5px 5px 5px; background: -moz-linear-gradient(center top, rgb(255, 249, 204) 0%, rgb(255, 237, 116) 100% ) repeat scroll 0pt 0pt transparent; font-size: 26pt; font-family: 'QuicksandBook', Helvetica, Arial, sans-serif; text-shadow: 1px 1px 1px rgb(255, 255, 255); line-height: 1.2em; width: 730px;\">\n      Access denied. Click <a href=\"/\">here</a> to go to home page.\n      </div>\n    </div>\n  </div>\n</body>\n</html>\n"
    }
  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    Technically the call will give a return with the workspaceid provided (instead of erroring), but it just gives a body containing the versions for the part and no information about where its used.

    I dug a little more,
    and it looks like "includeProperties=true" is also required to get the information you need.

    So you need:
    version id
    document id
    element id
    part id
    includeProperties=true


    The error you're seeing is because you aren't authenticated.


  • shawn_crockershawn_crocker Member, OS Professional Posts: 790 PRO
    edited October 2022
    Thanks @caden_armstrong for the extra info.  I'm still not getting it to work for some reason.  I'm not sure why the request would be coming back as not authenticated.  I am sending out all of the same credentials with this request as with the other end points I am currently using and are working.  Like BOM calls, metadata, thumbnails.  Interestingly I tryed structuring the URL like:

    https://cad.onshape.com/api/v5/productstructure/whereused/d/5a36e3321c7fa3cc05839659/v/f4f5b67beb8ea75b38c948cd/e/438bd35730e2b15225e3d60a/p/RxCD?includeProperties=true

    I'm getting the same error message coming back.  ?  You mentioned you did some digging.  Can you share where are you digging for this info?

    edit:

    actually I'm wrong.  I get a 404 response not found when I restructure like this.
Sign In or Register to comment.