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.

Options

Send control input to Onshape using the API

Overlord6464Overlord6464 Member Posts: 5
Hello,
I'm currently trying to integrate the control input from a DIY 3D Mouse into onshape.
I would like to know if it exist a custom api call to send control input in the current part studio or assembly.
For example something like : 
-My mouse detect a rotation.
-Software transform this rotation to an api call and send the input to the current view.

Someone knows which part of the api I should look into ?

Thanks

Best Answer

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,726 PRO
    edited February 3 Answer ✓

    From what I know, this is not currently possible. 3DConnexion has a special deal with Onshape which is how they can do it. Onshape listens on a port to messages from space mouse and acts accordingly. There is probably a way to piggy back off of the space mouse drivers if you know what your doing.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎

Answers

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,726 PRO
    edited February 3 Answer ✓

    From what I know, this is not currently possible. 3DConnexion has a special deal with Onshape which is how they can do it. Onshape listens on a port to messages from space mouse and acts accordingly. There is probably a way to piggy back off of the space mouse drivers if you know what your doing.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    Overlord6464Overlord6464 Member Posts: 5
    Ok thanks for the response
  • Options
    Matt_ShieldsMatt_Shields Member Posts: 225 PRO

    If you can capture the mouse data, you can send that to the API with a pretty simple script.
  • Options
    Overlord6464Overlord6464 Member Posts: 5
    Oh nice,
    Do you have any sample script or API reference that I can take a look into ?
    On your video it's seems your directly modifying the assembly not rotating the view ?

    Thanks for the insight
  • Options
    Matt_ShieldsMatt_Shields Member Posts: 225 PRO
    Oooh.  You want to change the view.  Pretty sure you can't do that.  I was just modifying assemby mates, not rotating the view.
  • Options
    billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,018 PRO
    @Matt_Shields ok, how did you do that?

    Is your breakout board hooked to your computer or does it have a wifi chip on it?


  • Options
    Matt_ShieldsMatt_Shields Member Posts: 225 PRO
    It's an Arduino.  It is using the serial monitor to print the three potentiometer positions over a serial port.  Then, I have a a Python script reading in those serial values and updating my Onshape assembly via API calls.
  • Options
    billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,018 PRO
    edited February 6
    I've been playing around with the API lately and I saw this post. I'm trying to figure out the answer.

    Is rotating a view a API thing?

    Nope, you can turn on the network console and see the calls the client makes to the server. Spinning a model does not create a get or post call to the server. Since the API deals with the server, you're not going to rotate the screen with a 3DConnexion by making calls to the server.



    Onshape is a cloud app which brings along with it some surprising facts. Onshape has no access to the files on your computer and it can not see any of the hardware. Chrome has access to a computer's hardware. It's a security thing.

    What is it then?

     Inspect elements tab shows that the viewport is a canvas tag which is used by webgl.


    Does webgl allow 3D input devices?

    Yes, you can build a simple website that'll spin something with a 3DConnexion.


    Can you tap into the Onshape tab from a tab you created?
    No, you can not build a website that'll read about the other tabs in a browser. It's security thing.

    Onshape doesn't allow you to peggy back onto their client tab in a browser. There is no client api. You can't customize the client. Even though they have a connection to a 3DConnexion device through the canvas tag, you don't have access to it.

    3DConnexion has an API and you might pretend that your device is a 3DConnexion.

    I think the solution to your problem is a hardware to computer issue. Keep in mind that the cloud has no access to the hardware attached to your computer. It's a security thing.

    If you get it working please post how you did it.




  • Options
    billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,018 PRO
    @Matt_Shields that's cool, I've been wanting to drive automated equipment from onshape. Looks likes you're almost there. It could save a lot of time for programming a piece of equipment if you started virtually.

    Are you serving on localhost? Are you on a PC or Mac?

  • Options
    Matt_ShieldsMatt_Shields Member Posts: 225 PRO
    I'm on a Mac.  I use Google Colab for a lot of my API work, but for this one, I had to run locally to access the local serial port data.
Sign In or Register to comment.