Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Realtime motion to raspberry pi and Arduino

1 REPLY 1
Reply
Message 1 of 2
msmanne2
219 Views, 1 Reply

Realtime motion to raspberry pi and Arduino

Realtime motion to raspberry pi and Arduino

 

Type Tcp/ip Bluetooth modbus conection to fusion 360 studio

 

Pluggin ?

 

 

1 REPLY 1
Message 2 of 2
OceanHydroAU
in reply to: msmanne2

I looked for the oldest unanswered forum posting I could find, just for giggles 🙂

 

I've done something similar for Minecraft - a protocol analyzer that intercepted the player traffic and sent servo-commands to a lego-model on the top of the monitor: everyhitng the player did in the game, the lego did in real life 🙂

 

In Fusion360, to do the same thing, you hook the CommandHandler and interpret the events that flow through it:

# Check to see if they changed something that would require us to send out motion data...
class CommandHandler(adsk.core.ApplicationCommandEventHandler):
    def __init__(self, targetCommand):
        super().__init__()
        self.tgtCmd = targetCommand
    def notify(self, args):
        global _ui
        try:
            eventArgs = adsk.core.ApplicationCommandEventArgs.cast(args)
            #do your checks and movement data outputs here...
            # Possible things to watch...: FusionDragSketchCommand SketchEditDimensionCmdDef SketchDimension ChangeParameterCommand
            pass

        except:
            pass

I'd recommend TCP or UDP output which is easy and supported without needing external libs, and gives no lag/delay to the user.

 

You need non-blocking sockets for that - here's how (works in Fusion add-ins on both Mac and Windows)

# stores socket 'nbs' and send data 'nbd' and response data 'nbr' in the global pnl[] structure
pnl['nbs'] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if not pnl['nbs']:
    return 0
pnl['nbs'].setblocking(0)
pnl['nbs'].connect_ex(("endpoint-tcp-server.com", 80))
pnl['nbd']=web_pkt(req) # 'GET /do_stuff...  HTTP/1.1\x0d\x0a\x0d\x0a'

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report