【pythonで動くG-codeビルダー】G-coordinatorをLinuxにインストール&動作確認してみる
※ 当ページには【広告/PR】を含む場合があります。
2023/06/13

+ モデルの強度を維持しながらも軽量化できる
+ モデルの(単位立方体あたりの)表面積を大きくできる
+ 他のインフィル構造と比較して、内部の応力集中を軽減できる
+ 外部の系へは熱断熱性が高く、断熱材として保温性に優れる
+ 多孔質材料としては、表面からの伝熱性が良く、ヒートシンクや熱交換器などへの応用できる
Eq. (Gyroid-Expression)
LinuxにG-coordinatorをインストール
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
$ python --version
Python 3.8.6
$ pip --version
pip 23.1 from /home/*********/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)
contourpy==1.0.7
cycler==0.11.0
fonttools==4.39.4
importlib-resources==5.12.0
kiwisolver==1.4.4
matplotlib==3.7.1
networkx==3.1
numpy==1.24.3
packaging==23.1
Pillow==9.5.0
PyOpenGL==3.1.6
pyparsing==3.0.9
PyQt5==5.15.9
PyQt5-Qt5==5.15.2
PyQt5-sip==12.12.1
pyqtgraph==0.13.2
python-dateutil==2.8.2
pytz==2023.3
Rtree==1.0.1
scipy==1.10.1
six==1.16.0
trimesh==3.21.7
tzdata==2023.3
zipp==3.15.0
requirements.txt
$ git clone https://github.com/tomohiron907/G-coordinator.git
$ cd G-coordinator/
$ cd src/
$ python main.py

src
$ python src/main.py
ジャイロイドのサンプルコードを読み込む
[Open File]
example
gyroid.py

[Reroad]
[Gcode Export]

gyroid.py
import numpy as np
import math
import print_settings
from path_generator import *
import matplotlib.pyplot as plt
a = 30
resolution = a*2
density = 3
x = np.linspace(-a , a , resolution)
x+=np.pi/2+0.5
y = np.linspace(-a , a , resolution)
y+=np.pi/2+0.5
z = np.linspace(-a , a , resolution*2)
X, Y, Z = np.meshgrid(x, y, z)
X /= density
Y /= density
Z /= density
#Equation for the Gyroid surface
equation = np.sin(X) * np.cos(Y) + np.sin(Y) * np.cos(Z) + np.sin(Z) * np.cos(X)
LAYER =5
def object_modeling():
full_object=[]
for height in range(resolution*2):
slice_plane = equation[:, :, height]
contours = plt.contour(x, y, slice_plane, levels=[0], colors='black')
for contour in contours.collections:
paths = contour.get_paths()
for path in paths:
points = path.vertices
x_coords = points[:, 0]
y_coords = points[:, 1]
z_coords = np.full_like(x_coords, height/2)
wall = Path(x_coords, y_coords, z_coords)
full_object.append(wall)
return full_object
equation = np.sin(X) * np.cos(Y) + np.sin(Y) * np.cos(Z) + np.sin(Z) * np.cos(X)
object_modeling
equation[:, :, height]
full_object
def object_modeling():
full_object=[]
for height in range(resolution*2):
slice_plane = equation[:, :, height]
contours = plt.contour(x, y, slice_plane, levels=[0], colors='black')
for contour in contours.collections:
paths = contour.get_paths()
for path in paths:
points = path.vertices
x_coords = points[:, 0]
y_coords = points[:, 1]
z_coords = np.full_like(x_coords, height/2)
wall = Path(x_coords, y_coords, z_coords)
full_object.append(wall)
return full_object
注意点〜v2.0.0はまだバグも多い
gyroid_infill.py
#...
syntax error!!
Traceback (most recent call last):
File "/home/*********/g-coordinator/G-coordinator/src/window/main_window.py", line 91, in draw_updated_object
self.full_object=modeling.object_modeling() # get the list of coordinate from modeling.py
File "./modeling.py", line 19, in object_modeling
NameError: name 'gyroid_infill' is not defined
Traceback (most recent call last):
File "/home/*********/g-coordinator/G-coordinator/src/window/main_window.py", line 106, in draw_updated_object
self.slider_layer.setRange(0, len(self.full_object)) # set slider range
AttributeError: 'MainWindow' object has no attribute 'full_object'
まとめ
余談
#Gcoordinator(ハイフンなしに注意)
参考サイト
記事を書いた人
ナンデモ系エンジニア
電子工作を身近に知っていただけるように、材料調達からDIYのハウツーまで気になったところをできるだけ細かく記事にしてブログ配信してます。
カテゴリー