Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Project Work
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Del Villar
Project Work
Commits
ddef1e1e
Commit
ddef1e1e
authored
1 year ago
by
Fabian
Browse files
Options
Downloads
Patches
Plain Diff
Create test3-2.py
parent
3c0a8e38
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test3-2.py
+73
-0
73 additions, 0 deletions
test3-2.py
with
73 additions
and
0 deletions
test3-2.py
0 → 100644
+
73
−
0
View file @
ddef1e1e
def
create_rectangular_prism
():
# Prompt for the dimensions of the rectangular prism
length
=
float
(
input
(
"
Enter the length of the prism:
"
))
width
=
float
(
input
(
"
Enter the width of the prism:
"
))
height
=
float
(
input
(
"
Enter the height of the prism:
"
))
# Create the STL code for the rectangular prism
stl_code
=
f
'
solid prism
\n
'
# Front face
stl_code
+=
f
'
facet normal 0 0 -1
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Back face
stl_code
+=
f
'
facet normal 0 0 1
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
0
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Right face
stl_code
+=
f
'
facet normal 1 0 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Left face
stl_code
+=
f
'
facet normal -1 0 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex 0 0
{
height
}
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Top face
stl_code
+=
f
'
facet normal 0 1 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
{
height
}
\n
'
stl_code
+=
f
'
vertex
{
length
}
{
width
}
0
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
# Bottom face
stl_code
+=
f
'
facet normal 0 -1 0
\n
'
stl_code
+=
f
'
outer loop
\n
'
stl_code
+=
f
'
vertex 0 0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0 0
\n
'
stl_code
+=
f
'
vertex
{
length
}
0
{
height
}
\n
'
stl_code
+=
f
'
endloop
\n
'
stl_code
+=
f
'
endfacet
\n
'
stl_code
+=
f
'
endsolid prism
\n
'
# Write the STL code to a file
with
open
(
'
prism.stl
'
,
'
w
'
)
as
file
:
file
.
write
(
stl_code
)
print
(
"
Rectangular prism STL file
'
prism.stl
'
has been generated.
"
)
# Call the function to create the rectangular prism
create_rectangular_prism
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment