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

+ モデルの強度を維持しながらも軽量化できる
+ モデルの(単位立方体あたりの)表面積を大きくできる
+ 他のインフィル構造と比較して、内部の応力集中を軽減できる
+ 外部の系へは熱断熱性が高く、断熱材として保温性に優れる
+ 多孔質材料としては、表面からの伝熱性が良く、ヒートシンクや熱交換器などへの応用できる
Eq. (Gyroid-Expression)
G-coordinator
gcoordinator
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
$ pip install -r 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
Linuxにgcoordinatorをインストール
G-coordinator
G-coordinator
pyenv/virtualenv
gcoordinator
$ pyenv install 3.8.6
$ pyenv virtualenv 3.8.6 gc-env
$ pyenv versions
* 3.8.6 (set by /home/******/.pyenv/version)
3.8.6/envs/gc-env
gc-env
$ pyenv local gc-env
gcoordinator
gcoordinator
$ pip install gcoordinator
demo.py
import gcoordinator as gc
import numpy as np
full_object = []
for height in range(100):
arg = np.linspace(0, 2*np.pi, 100)
x = 10 * np.cos(arg)
y = 10 * np.sin(arg)
z = np.full_like(x, (height+1) * 0.2)
wall = gc.Path(x, y, z)
full_object.append(wall)
gc.show(full_object)
$ python demo.py

まとめ
余談
#Gcoordinator(ハイフンなしに注意)
参考サイト
記事を書いた人
ナンデモ系エンジニア
電子工作を身近に知っていただけるように、材料調達からDIYのハウツーまで気になったところをできるだけ細かく記事にしてブログ配信してます。
カテゴリー