Skip to content

Instantly share code, notes, and snippets.

@patrikalienus
Last active March 3, 2025 05:49
Show Gist options
  • Save patrikalienus/549fcf76be41097545fe61da88e4dafe to your computer and use it in GitHub Desktop.
Save patrikalienus/549fcf76be41097545fe61da88e4dafe to your computer and use it in GitHub Desktop.
Make Orca Slicer discover your printer
# My computer is on ethernet and the Bambu printer is on WLAN. These two networks can communicate with
# eachother, but OrcaSlicer is still not able to discover the printer. This will "trick" Orca into
# discovering the printer and connect to its IP. I've tested this extensively and working as expected.
# I have full control over the printer that is in LAN only mode. I have to have it in LAN only mode
# because I don't want to install their coming update which will decrease the usability of the printer
# if you're using Orca - and so many are.
#
# Change the parameters to fit your environment and run it after launching Orca.
import socket
from datetime import datetime
# Parameters
PRINTER_IP = "x.x.x.x" # IP address of your BambuLab Printer
TARGET_IP = "x.x.x.x" # IP address of your PC running BambuStudio
PRINTER_USN = "000000000000000" # Enter your own Printer Serial Number here
# PRINTER_DEV_MODEL: https://github.com/bambulab/BambuStudio/tree/master/resources/printers
# X1C : "3DPrinter-X1-Carbon"
# X1 : "3DPrinter-X1"
# X1E : "C13"
# P1P : "C11"
# P1S : "C12"
# A1 mini: "N1"
# A1 : "N2S"
PRINTER_DEV_MODEL = "C11" # Set this to your model
PRINTER_DEV_NAME = "PRINTER-NAME" # Whatever you want
PRINTER_DEV_SIGNAL = "-44" # Good Signal (Artificial)
PRINTER_DEV_CONNECT = "lan" # LAN Mode
PRINTER_DEV_BIND = "free" # Not bound to a Cloud user-account
# Port settings
remoteudpport = 2021 # port to send to
sourceudpport = 0 # SourcePort, 0 means any available port
# Message to send
message = (
f"HTTP/1.1 200 OK\r\n"
f"Server: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8\r\n"
f"Date: {datetime.now().strftime('%a, %d %b %Y %H:%M:%S GMT')}\r\n"
f"Location: {PRINTER_IP}\r\n"
f"ST: urn:bambulab-com:device:3dprinter:1\r\n"
f"EXT:\r\n"
f"USN: {PRINTER_USN}\r\n"
f"Cache-Control: max-age=1800\r\n"
f"DevModel.bambu.com: {PRINTER_DEV_MODEL}\r\n"
f"DevName.bambu.com: {PRINTER_DEV_NAME}\r\n"
f"DevSignal.bambu.com: {PRINTER_DEV_SIGNAL}\r\n"
f"DevConnect.bambu.com: {PRINTER_DEV_CONNECT}\r\n"
f"DevBind.bambu.com: {PRINTER_DEV_BIND}\r\n\r\n"
)
# Create UDP socket
udp_client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_client.bind(('', sourceudpport))
# Send message
byte_buffer = message.encode('ascii')
udp_client.sendto(byte_buffer, (TARGET_IP, remoteudpport))
# Close the socket
udp_client.close()
@lukaskirner
Copy link

lukaskirner commented Jan 20, 2025

Use these model names for PRINTER_DEV_MODEL, otherwise the print profile won't match.

# PRINTER_DEV_MODEL: https://github.com/bambulab/BambuStudio/tree/master/resources/printers
# X1C    : "3DPrinter-X1-Carbon"
# X1     : "3DPrinter-X1"
# X1E    : "C13"
# P1P    : "C11"
# P1S    : "C12"
# A1 mini: "N1"
# A1     : "N2S"

@lukasmalkmus
Copy link

Thanks, appreciate this <3

@brummbrum
Copy link

brummbrum commented Jan 22, 2025

This method works fine just like the Linux Shell script version (https://github.com/gashton/bambustudio_tools/blob/master/bambudiscovery.sh) or PowerShellScript (https://gist.github.com/fritzw/7d981046b509a27e204d01c9bd73f37b).

It is particularly useful if you run the printer in an isolated network (VLAN, subnet) which has no internet access.

However, from a privacy perspective, it is worth noting that Bambu's networking plugin still contacts the Bambu server, namely api.bambulab.com! Even AFTER Bambu Studio found the printer thanks to the script, it still requires to contact api.bambulab.com in order to make the connection. This is quite ridiculous since the connection is clearly directly over LAN with the printer and not relayed via the cloud. It does not matter that your local router can route the traffic between different local networks (VLANs, subnets, ...) - Bambu Studio requires the handshake with the Bambu cloud. If you block outgoing traffic from Bambu to the internet, the connection to the printer fails.

EDIT: While it is true that Bambu Studio phones home even if you only use LAN mode it is possible to use the printer with no internet connection. I made a config mistake in the funny Windows Firewall (which oddly does not process the firewall rules in any order and therefore requires a different logic than other firewalls. In Windows firewall an ALLOW rule for outbound traffic will always be superseded by a BLOCk rule irrespective of the order. By blocking all IP addresses for outbound traffic but the local ones to the printer (residing in a different subnet/VLAN) you can print without leaving any traces whatsoever. Another (positive) side effect is that Bambu Studio does not perform the hidden update of the network plugin it would normally perform every time on startup.

@patrikalienus
Copy link
Author

patrikalienus commented Jan 22, 2025

@lukaskirner Thanks for this list. I'll update the gist to include the correct names. It wasn't until after I put this gist up that I discovered that even though I could control the printer through OrcaSlicer, I couldn't actually send print jobs, which is weird to me and I assumed it was because of my somewhat complicated network setup and that I'd need to allow specific UDP packets to go to my LAN, which I haven't fiddled with yet. I consider wifi insecure even though I change the WPA2 key relatively often, which is why that network isn't allowed to initiate traffic to the wired LAN.

If you block outgoing traffic from Bambu to the internet, the connection to the printer fails

Yes, it's absolutely ridiculous that it needs an internet connection in order to even function properly. I hope the "new DEV mode" that Bambu is (now) peddling will solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment