CauldronDevelopmentLLC / CAMotics

Open-Source Simulation & Computer Aided Machining - A 3-axis CNC GCode simulator
Other
602 stars 138 forks source link

RuntimeError when calling Simulation.set_path() in Python #415

Closed bluesun212 closed 3 months ago

bluesun212 commented 4 months ago

Simulation.set_path() throws a RuntimeError stating "Can't dereference NULL pointer!" when used like so (with valid parameters for open and set_path):

from camotics import Simulation

sim = Simulation()
sim.open(...)
sim.set_path(...)

This is because self->s->path in PySimulation is never set. Additionally, if you insert compute_path before set_path, the error goes away (because compute_path sets the path variable), but the additional JSON data is appended to the existing path data instead of replacing it. This seems like unintended behavior given that the name is "set_path". Inserting self->s->path = new GCode::ToolPath(self->s->project.getTools()); before the line self->s->path->read(*PyJSON(path).toJSON()); in PySimulation._set_path fixed both issues for me.

jcoffland commented 3 months ago

thanks