Plugin help - Get build volume

Is there a function I can use within OctoPrint to pull the currently loaded profile's build volume? From either the python or javascript side, doesn't really matter.

Think I figured it out. Added dependency to printerProfilesViewModel and used the following in my javascript.

var maxX = self.printerProfilesViewModel.currentProfileData().volume.width();
var maxY = self.printerProfilesViewModel.currentProfileData().volume.depth();
var maxZ = self.printerProfilesViewModel.currentProfileData().volume.height();

You need to be careful if the user has a custom volume. I have some python to extract it here:

octoprint_printer_profile = self._printer_profile_manager.get_current()
volume = octoprint_printer_profile["volume"]
custom_box = volume["custom_box"]
# see if we have a custom bounding box
if custom_box:
    min_x = custom_box["x_min"]
    max_x = custom_box["x_max"]
    min_y = custom_box["y_min"]
    max_y = custom_box["y_max"]
    min_z = custom_box["z_min"]
    max_z = custom_box["z_max"]
    min_x = 0
    max_x = volume["width"]
    min_y = 0
    max_y = volume["depth"]
    min_z = 0
    max_z = volume["height"]

This code was modified to fit in this example and requires some modification. It also requires some injected properties to work. Let me know if that helps.

Extremely helpful FormerLurker, thanks.

1 Like