Page MenuHomec4science

untitled0.py
No OneTemporary

File Metadata

Created
Wed, Feb 12, 18:12

untitled0.py

"""
A simple example showing how to use PySLM for generating slices across a 3D model
"""
import pyslm
import pyslm.visualise
from pyslm import hatching as hatching
import numpy as np
# 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_005.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
myHatcher.hatchAngle = 0
myHatcher.volumeOffsetHatch = 0.08
myHatcher.spotCompensation = 0.06
myHatcher.numInnerContours = 1
myHatcher.numOuterContours = 1
myHatcher.hatchSortMethod = hatching.AlternateSort()
# Set the layer thickness
layerThickness = 0.04 # [mm]
# Perform the slicing. Return coords paths should be set so they are formatted internally.
#myHatcher.layerAngleIncrement = 66.7
#Perform the hatching operations
print('Hatching Started')
layers = []
myHatcher.hatchAngle = 90
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
# Note: the use of python slices to get the arrays
#pyslm.visualise.plotLayers(layers[0:-1:10])
pyslm.visualise.plot(layer, plot3D=False, plotArrows=True, plotOrderLine=False, plotColorbar=False)
layer.getContourGeometry()[0].coords

Event Timeline