【pythonで動くG-codeビルダー】シンプルなシリンダー形状のサンプルでG-coordinatorの使い方を学習する
※ 当ページには【広告/PR】を含む場合があります。
2023/09/26

シリンダーサンプルを印刷してみる
sample
default_cylinder.py


import math
import numpy as np
import print_settings
from path_generator import *
from infill_generator import *
from console import *
LAYER = 100
#👇解説ポイント①
def object_modeling():
#👇Pathオブジェクトの配列
full_object=[]
#👇解説ポイント②
for height in range(LAYER):
#👇解説ポイント③
arg = np.linspace(0, 2*np.pi, 100)
#👇解説ポイント④
x = 10 * np.cos(arg)
y = 10 * np.sin(arg)
#👇解説ポイント⑤
z = np.full_like(arg, (height+1) * print_settings.layer_height)
#👇解説ポイント⑥
wall = Path(x, y, z)
full_object.append(wall)
print(f'layer at {height=}')
return full_object
object_modeling
def object_modeling():
#👇Pathオブジェクトの配列
full_object=[]
###...full_objectに詰物(計算結果)を入れる処理をユーザーが定義
return full_object
#...中略
LAYER = 100
#...中略
for height in range(LAYER):
#...一層ごとの処理を記述
range
range(100)
[0, 1, ..., 99]
for height in range(LAYER):
height
arg = np.linspace(0, 2*np.pi, 100)
numpy
np.linspace
np.linspace(0, 2*np.pi, 100)
cos
sin
x = 10 * np.cos(arg)
y = 10 * np.sin(arg)
cos
sin
np.full_like
z = np.full_like(arg, (height+1) * print_settings.layer_height)
np.full_like
a = np.array([1, 2, 3, 4, 5])
b = np.full_like(a, 6)
print(b)
#実行結果 --> [6, 6, 6, 6, 6]
print_settings.layer_height
print_settings

print_settings.layer_height = 0.2
(height+1) * print_settings.layer_height
height = 0
height+1
+1
Path
wall = Path(x, y, z)
full_object.append(wall)
1. レイヤー数の設定
2. レイヤーごとのx,y座標の配列を計算
3. z座標の計算
4. Pathオブジェクトの生成とfull_object配列への追加
何も考えず印刷開始



スパイラルモードを使ってZシームは消えるのか?

default_cylinder.py
object_modeling
#...
def object_modeling():
#...
for height in range(LAYER):
#...
#👇コメントアウト
#z = np.full_like(arg, (height+1) * print_settings.layer_height)
#👇以下の式に変更
z = np.linspace(height * print_settings.layer_height,
(height+1) * print_settings.layer_height,
100)
#...

0.04mm
0.04 ~ 0.05mm
0.2mm
4 ~ 5ステップ
z = np.linspace(height * print_settings.layer_height,
(height+1) * print_settings.layer_height,
100)
0.2mm
まとめ
記事を書いた人
ナンデモ系エンジニア
電子工作を身近に知っていただけるように、材料調達からDIYのハウツーまで気になったところをできるだけ細かく記事にしてブログ配信してます。
カテゴリー