Gcode preview and remap

More
21 Sep 2023 10:53 #281290 by zz912
Replied by zz912 on topic Gcode preview and remap
I tried make dirty fix:
 

It dont work. Probably I need modification for Python 3 from Python.
 

I would like ask you for help.

 
Attachments:

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 11:13 - 21 Sep 2023 11:15 #281291 by rmu
Replied by rmu on topic Gcode preview and remap
it says right there at the end of the error message. In python, indentation is part of the syntax. It needs to say
if fn == None:
fn = self.ilename
if fn.split....


notice same indentation level, you have additional indentation on the line with "if fn.split...". rule of thumb, if the previous line is a complete statement (no open parenthesis, ...) and doesn't end with a colon (":") then next line must be on same level.
Last edit: 21 Sep 2023 11:15 by rmu.
The following user(s) said Thank You: zz912

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 11:13 #281292 by Aciera
Replied by Aciera on topic Gcode preview and remap
The preview interpreter doesn't know if you want a subroutine displayed or not.

Try using the #<_task> parameter in your subroutine so it is only executed when you are actually running the gcode program.

#<_task> - 1.0 if the executing interpreter instance is part of milltask, 0.0 otherwise. Sometimes it is necessary to treat this case specially to retain proper preview, for instance when testing the success of a probe (G38.n) by inspecting #5070, which will always fail in the preview interpreter (e.g. Axis).

The following user(s) said Thank You: zz912

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 11:29 #281294 by zz912
Replied by zz912 on topic Gcode preview and remap

it says right there at the end of the error message. In python, indentation is part of the syntax. It needs to say
if fn == None:
fn = self.ilename
if fn.split....


notice same indentation level, you have additional indentation on the line with "if fn.split...". rule of thumb, if the previous line is a complete statement (no open parenthesis, ...) and doesn't end with a colon (":") then next line must be on same level.

It no longer gives the error message, but it didn't solve the problem. Still showing path of ATC. Still, thanks for the help.

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 11:31 #281295 by zz912
Replied by zz912 on topic Gcode preview and remap

The preview interpreter doesn't know if you want a subroutine displayed or not.

Try using the #<_task> parameter in your subroutine so it is only executed when you are actually running the gcode program.

#<_task> - 1.0 if the executing interpreter instance is part of milltask, 0.0 otherwise. Sometimes it is necessary to treat this case specially to retain proper preview, for instance when testing the success of a probe (G38.n) by inspecting #5070, which will always fail in the preview interpreter (e.g. Axis).

The same advice give me rene-dev.
github.com/LinuxCNC/linuxcnc/issues/2651...uecomment-1729335327
But I dont know how use #<_task>.
 

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 11:46 #281296 by zz912
Replied by zz912 on topic Gcode preview and remap
I tried this:
o<ATC> sub

#<_task> = 1

G53 G1 Z-195 f20000

G53 G1 Z0 f20000

#<_task> = 0

o<ATC> endsub [10]
m2 

But #<_task> is only readonly parameter.
 
Attachments:

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 12:11 - 21 Sep 2023 12:27 #281298 by Aciera
Replied by Aciera on topic Gcode preview and remap
This is an example from 'sim/axis/geometry/xyzc.ngc':
o300 if [#<_task> eq 1]
g10l2p0x1
(debug, Next: run with g5x xoffset=#5221, s to continue)
m0
o100 call

g10l2p0x0y0z0c0
g92x2
(debug, Next: run with g92 xoffset=#5211, s to continue)
m0
o100 call
o300 endif


 
Last edit: 21 Sep 2023 12:27 by Aciera.

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 12:26 #281299 by zz912
Replied by zz912 on topic Gcode preview and remap
I have absolutely no idea how this is going to help me. I don't understand why I have to check #<_task>. I need the ATC exchange to happen every time, not just depending on some parameter. I just need Preview to ignore it.

I tried this:
(PREVIEW,hide)
<G-code to be hidden>
(PREVIEW, show)
linuxcnc.org/docs/2.9/html/gui/gmoccapy.html#_preview_control

But it didn't help on physical machine.

I'm stupid today.

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 12:27 - 21 Sep 2023 12:36 #281300 by Aciera
Replied by Aciera on topic Gcode preview and remap
Try this:
o<ATC> sub
  o100 if [#<_task> eq 1]
    G53 G1 Z-19.5 f20000
    G53 G1 Z0 f20000
  o100 endif
o<ATC> endsub [10]
Last edit: 21 Sep 2023 12:36 by Aciera.
The following user(s) said Thank You: zz912

Please Log in or Create an account to join the conversation.

More
21 Sep 2023 12:32 - 21 Sep 2023 12:35 #281301 by Aciera
Replied by Aciera on topic Gcode preview and remap

need the ATC exchange to happen every time, not just depending on some parameter. I just need Preview to ignore it.


The point is this:
gcode is run in a separate interpreter for the preview and for this the parameter #<_task> is = 0.
If the code is executed 'on the hardware' (by clicking on the 'Run' button) then the parameter #<_task> = 1.

So you check that parameter #<_task> == 1 to make the code in the if-endif subroutine invisible for the preview but execute it when you actually click on the 'Run' button.
Last edit: 21 Sep 2023 12:35 by Aciera.
The following user(s) said Thank You: zz912

Please Log in or Create an account to join the conversation.

Time to create page: 0.557 seconds
Powered by Kunena Forum