- Need Help!- How to import planetcnc module in Python
-
Member
How to import planetcnc module in Python
I am trying to run steppers motor which are connected to planetcnc card and able to be run via tng software but it does not work on python interface and the problem seems to be the planecnc library can not be found. How to add it?
#! /usr/bin/env python
# name=Lissajous curve
# desc=Generates Lissajous curve
import sys
import time
import math
import planetcnc
import gcode
# sys.path.append(planetcnc.getPathProfile("Python") )
def calc(angle, A, A2, A3, B, B2, B3):
xx = A * math.sin(math.radians(A2 * angle + A3))
yy = B * math.cos(math.radians(B2 * angle + B3))
return xx, yy
def Lissajous(x, y, z, A, B, A2, B2, A3, B3, scale, res):
if not gcode.lineAddAllowed():
planetcnc.msg("Adding g-code lines is not allowed!")
return 1
gcode.lineAdd("%")
gcode.lineAdd("G00 X", x, " Y", y + scale, " Z", z)
angle = 0
while angle < 360:
xx, yy = calc(angle, A, A2, A3, B, B2, B3)
gcode.lineAdd("G01 X", x + (scale * xx), " Y", y + (scale * yy))
angle += res
gcode.lineAdd("%")
if __name__ == '__main__':
Lissajous(0, 0, 0, 1, 1, 1, 3, 0, 0, 100, 1)
# Lissajous(0, 0, 0, 1, 1, 2, 5, 0, 0, 100, 1)
# Lissajous(0, 0, 0, 1, 1, 5, 3, 0, 0, 100, 1)
Similar Threads:
Last edited by murkoc; 03-23-2021 at 04:08 AM.
Reason: added code sample
-
- Need Help!- How to import planetcnc module in Python
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules