Kragrathea / pgcode

118 stars 19 forks source link

PrettyGCode for Klipper

PrettyGCode WebGL based GCode preview and simulator

Features

Screenshots

Screen1

Installation via Kiauh (Recommended)

PrettyGCode can now be installed using the Kiauh installer. This is by far the easiest method to install.

https://github.com/th33xitus/kiauh

On the main Kiauh screen select Option 1) [Install] and then select PrettGCode: InstallScreen1

Port can be set as part of installation. Default port is 7136

Moonraker config

Depending on your setup you will probably have to edit Moonraker.conf to allow access. This can be done in Fluidd in the Configuration menu.

Partial moonraker.conf

[authorization]#<--If this section is present then PrettyGCode needs to use an API Key to connect
cors_domains:
  *.local
  *.lan
  *://app.fluidd.xyz
  *:7136  #<--Allow PrettyGCode (port 7136) on all domains (recommended) OR...
  *.local:7136  #<--Allow PrettyGCode (port 7136) on just .*local domain. (more secure I guess)

trusted_clients:
    10.0.0.0/8
    127.0.0.0/8
    169.254.0.0/16
    172.16.0.0/12
    192.168.1.0/160  #<--Trust local network machines. Only needed if [authorization] enabled.
    FE80::/10
    ::1/128

# enables support for slicer uploads via partial Octoprint API impl
[octoprint_compat]

# Adds PrettyGCode to Moonrakers update manager
[update_manager pgcode]
type: git_repo
primary_branch: main
origin: https://github.com/Kragrathea/pgcode.git
path: ~/pgcode
is_system_service: False

Fluidd config

If you haven't already you may have to enable SD support in Fluidd

Partial Fluidd client.cfg

[virtual_sdcard]
path: ~/gcode_files

Connecting to Fluidd/Moonraker

Assuming you installed on a machine with a local name of "fluiddpi" you can access the PrettyGCode page by using this url.

http://fluiddpi.local:7136 <-Should automatically connect to the local instance of Fluidd

If you installed to some other machine subsititute the ip address or name.

The above URL should take you to the PrettyGCode home page. If don't have your printer machine set to require login it should automatically connect. If you have your system secured you will have to use an API key to allow access. To configure the connection to the printer click on the connection button in the upper right of the screen. There you can enter your server address and any API key. Screen2

Using an API key to connect

If you have Moonraker secured behind a user name and password then you can use an API key to allow PrettyGCode to connect.

You can get your API key in Fluidd via the System configuration menu Screen1

Troubleshooting connections

For now to trouble shoot the connection you need to open the browsers developer console and look for warnings in the console.

[authorization]#<--If this section is present then PrettyGCode needs to use an API Key to connect
cors_domains:
  *.local
  *.lan
  *://app.fluidd.xyz
  *  #<--Allow all domains

You may have to enable [octoprint_compat] in moonraker.conf file.

Mixed Content (e.g., Reverse Proxies)

If you're using a reverse proxy and it's serving your front-end via https://, then it's likely your browser won't allow mixing the http:// calls to your moonraker instance. A simple fix is to create another reverse proxy endpoint to moonraker. For example, if you access Fluidd on https://myprinter.example.com, create a new domain name such as https://api-myprinter.example.com pointing to moonraker's host and port.

Alertnatively, you can configure your browser to allow "mixed content" (which is no longer the default on some modern browsers) to both the secure and insecure content. This option may not be available on every browser, however, particularly some mobile browsers.

Manually setting server via URL parameter

If your server is located on another machine or isn't being detected you can specifiy it on the command line like this:

http://fluiddpi.local:7136?server=http://fluiddpi.local:7125 <-Connect to the local instance of Moonraker (port 7125 by default)

or.

http://pgcode url:7136?server=http:// moonraker machine url:port

NOTE: For now URLS must be in the format http://servername:port without any trailing path info.

Specify the API key in the URL like this:

http://fluiddpi.local:7136?apiKey=

or http://fluiddpi.local:7136?server=http://fluiddpi.local:7125&apiKey=

Setting printer bed volume

By default the bed volume is 300x300 with the origin at the corner. If that doesn't match your printer you can adjust it via a URL parameter. Supported origins are currently, "center" and "lowerleft"

For example this will set a 200x200 volume with the origin at the "center"

http://fluiddpi.local:7136?bed.width=200&bed.depth=200&bed.origin=center

Options:

To make the background transparent in OBS Studio paste this CSS in the Browser source options set the CSS to something like this:

body { background-color: rgba(110, 0, 0, 0); margin: 0px auto; overflow: hidden; }
canvas {background-color:rgba(0,0,0,0.5) !important; }