Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88836851
scan_strategy.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
Sun, Oct 20, 22:29
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Oct 22, 22:29 (2 d)
Engine
blob
Format
Raw Data
Handle
21807813
Attached To
R11910 Additive Manufacturing Work
scan_strategy.py
View Options
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 11 16:32:00 2022
@author: kubilay
"""
import
sys
import
os
import
numpy
as
np
sys
.
path
.
append
(
'/usr/lib/freecad-python3/lib'
)
import
FreeCAD
import
Part
from
FreeCAD
import
Base
#read step file
part
=
Part
.
Shape
()
part
.
read
(
'/home/kubilay/Documents/additive-manufacturing-work/Part_geometry/layer/layer_005.step'
)
#get geometric data of the part
x_max
=
part
.
BoundBox
.
XMax
x_min
=
part
.
BoundBox
.
XMin
y_max
=
part
.
BoundBox
.
YMax
y_min
=
part
.
BoundBox
.
YMin
z_min
=
part
.
BoundBox
.
ZMin
z_max
=
part
.
BoundBox
.
ZMax
del_z
=
z_max
-
z_min
del_y
=
y_max
-
y_min
del_x
=
x_max
-
x_min
center
=
Base
.
Vector
(
part
.
BoundBox
.
XMin
,
part
.
BoundBox
.
YMin
,
part
.
BoundBox
.
ZMin
)
extension
=
'.step'
infill_offset
=
0.01
contour_offset
=
0.01
y
=
y_min
+
contour_offset
+
infill_offset
intersection_points
=
np
.
empty
((
0
,
3
))
while
np
.
round
(
y
+
contour_offset
+
infill_offset
,
5
)
<=
y_max
:
edge
=
Part
.
makeLine
((
x_min
,
y
,
z_max
),
(
x_max
,
y
,
z_max
))
#get the intersection
common
=
edge
.
common
(
part
)
for
p
in
common
.
Vertexes
:
print
(
p
.
Point
)
intersection_points
=
np
.
vstack
((
intersection_points
,
np
.
array
([
p
.
Point
.
x
,
p
.
Point
.
y
,
p
.
Point
.
z
])))
y
+=
infill_offset
#save the intersection
name
=
'/layer_{}'
.
format
(
str
(
count
)
.
zfill
(
3
))
common
.
exportStep
(
args
.
geom_dir
+
name
+
extension
)
#increment loop variables
z
+=
args
.
layer_thickness
count
+=
1
#call meshing script on the saved step file
meshing
(
args
.
geom_dir
,
name
,
extension
,
args
.
mesh_dir
)
Event Timeline
Log In to Comment