Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99204918
untitled0.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 22, 08:43
Size
4 KB
Mime Type
text/x-python
Expires
Fri, Jan 24, 08:43 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
23738561
Attached To
R11910 Additive Manufacturing Work
untitled0.py
View Options
"""
A simple example showing how to use PySLM for generating slices across a 3D model
"""
import
pyslm
from
pyslm
import
hatching
as
hatching
import
numpy
as
np
from
helpers
import
*
import
pyslm.visualise
import
pyslm.geometry
import
pyslm.analysis
def
get_scan_strategy
(
layer_no
,
contour_velocity_mag
,
infill_velocity_mag
,
infill_scan_limits
,
contour_scan_limits
,
contour_infill_delay
):
# Imports the part and sets the geometry to an STL file (frameGuide.stl)
solidPart
=
pyslm
.
Part
(
'inversePyramid'
)
solidPart
.
setGeometry
(
'/home/kubilay/Documents/additive-manufacturing-work/Part_geometry/layer/layer_001.stl'
)
#solidPart.origin[0] = 0
#solidPart.origin[1] = 0
#solidPart.scaleFactor = 1.0
#solidPart.rotation = [0, 0, 0]
#solidPart.dropToPlatform()
# Create a StripeHatcher object for performing any hatching operations
myHatcher
=
hatching
.
Hatcher
()
# Set the base hatching parameters which are generated within Hatcher
if
layer_no
%
2
==
1
:
myHatcher
.
hatchAngle
=
90
elif
layer_no
%
2
==
0
:
myHatcher
.
hatchAngle
=
0
myHatcher
.
spotCompensation
=
0.05
myHatcher
.
numInnerContours
=
0
myHatcher
.
numOuterContours
=
1
myHatcher
.
scanContourFirst
=
True
myHatcher
.
hatchDistance
=
0.05
myHatcher
.
hatchSortMethod
=
hatching
.
AlternateSort
()
# Set the layer thickness
#layerThickness = 0.04 # [mm]
#infill_velocity_mag = 0.8
#contour_velocity_mag = 0.9
#alpha = 8e-6
#contour_infill_delay = get_interpolation_limits(0.00377/2, infill_velocity_mag, alpha)
#contour_scan_limits = get_interpolation_limits(0.00377/2, contour_velocity_mag, alpha)
#Perform the hatching operations
print
(
'Hatching Started'
)
layers
=
[]
contour_coordinates
=
[]
infill_coordinates
=
[]
geomSlice
=
solidPart
.
getVectorSlice
(
solidPart
.
boundingBox
[
5
]
-
1e-7
)
# Hatch the boundary using myHatcher
layer
=
myHatcher
.
hatch
(
geomSlice
)
print
(
'Completed Hatching'
)
# Plot the layer geometries using matplotlib
pyslm
.
visualise
.
plot
(
layer
,
plot3D
=
False
,
plotArrows
=
False
,
plotOrderLine
=
False
,
plotColorbar
=
False
)
#plt.xlim([-10, -5])
"""
for i in layer.getContourGeometry():
for j in i.coords:
contour_coordinates.append(np.array([j[0], j[1] , solidPart.boundingBox[5]]))
contour_coordinates = np.array(contour_coordinates)/1000
for i in layer.getHatchGeometry():
for j in i.coords:
infill_coordinates.append(np.array([j[0], j[1] , solidPart.boundingBox[5]]))
infill_coordinates = np.array(infill_coordinates)/1000
t = 0.00001
contour_layer = Layer()
for i in range(len(contour_coordinates)-1):
del_x = contour_coordinates[i+1] - contour_coordinates[i]
vel = contour_velocity_mag*del_x/np.linalg.norm(del_x)
del_t = np.linalg.norm(del_x)/np.linalg.norm(vel)
s = Scan(t, t+del_t, contour_coordinates[i], vel, contour_scan_limits)
contour_layer.addScan([s])
t += del_t
t += contour_infill_delay
infill_layer = Layer()
i = 0
while i <= (len(infill_coordinates)-2):
del_x = infill_coordinates[i+1] - infill_coordinates[i]
vel = infill_velocity_mag*del_x/np.linalg.norm(del_x)
del_t = np.linalg.norm(del_x)/np.linalg.norm(vel)
s = Scan(t, t+del_t, infill_coordinates[i], vel, infill_scan_limits)
infill_layer.addScan([s])
t += del_t
i += 1
try:
del_x = infill_coordinates[i+1] - infill_coordinates[i]
vel = infill_velocity_mag*del_x/np.linalg.norm(del_x)
del_t = np.linalg.norm(del_x)/np.linalg.norm(vel)
t += del_t
i += 1
except IndexError:
break
contour_layer.combineLayers(infill_layer)
"""
model
=
pyslm
.
geometry
.
Model
()
model
.
mid
=
1
model
.
name
=
"Sample"
bstyle
=
pyslm
.
geometry
.
BuildStyle
()
bstyle
.
setStyle
(
bid
=
1
,
focus
=
1
,
pointExposureTime
=
0
,
pointExposureDistance
=
0
,
power
=
200.0
,
laserSpeed
=
800
,
laserMode
=
pyslm
.
geometry
.
LaserMode
.
CW
)
model
.
buildStyles
.
append
(
bstyle
)
scanIter
=
pyslm
.
analysis
.
ScanIterator
([
model
],
[
layer
])
scanIter
.
recoaterTime
=
10
# s
scanIter
.
timestep
=
5e-3
# Generate a list of point exposures - note the 3rd column is the current time
ab
=
np
.
array
([
point
for
point
in
scanIter
])
print
(
ab
)
return
0
return
contour_layer
if
__name__
==
'__main__'
:
infill_velocity_mag
=
0.8
contour_velocity_mag
=
0.9
alpha
=
8e-6
infill_scan_limits
=
get_interpolation_limits
(
0.00377
/
2
,
infill_velocity_mag
,
alpha
)
contour_scan_limits
=
get_interpolation_limits
(
0.00377
/
2
,
contour_velocity_mag
,
alpha
)
l
=
get_scan_strategy
(
198
,
0.8
,
0.8
,
infill_scan_limits
,
infill_scan_limits
,
0.3
)
print
(
l
.
numberOfScans
())
Event Timeline
Log In to Comment