Skip to content

1D Line

Build a rectangle of lines

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Import ocp_vscode which is an addon to view the 3D model in VScode
from ocp_vscode import *
# Import build123d library to be able to use build123 commands
from build123d import *

# Define an x and y value for the rectangle
x=20
y=10

# Start the Line Builder and define the name of the finished line object as RectangleOfLines
with BuildLine() as RectangleOfLines:
  # Define first line
  Line((0,0),(x,0))
  # Define second line
  Line((x,0),(x,y))
  # Define third line
  Line((x,y),(0,y))
  # Define fourth and last line to close the rectangle shape
  Line((0,y),(0,0))

# Show all created objects which is only RectangleOfLines
show_all()

Line building can be very helpfull if you have irregular shapes which you want to build with other 1D objects like:

  • Bezier
  • CenterArc
  • EllipticalCenterArc
  • FilletPolyline
  • Helix
  • IntersectingLine
  • JernArc
  • Line
  • PolarLine
  • Polyline
  • RadiusArc
  • SagittaArc
  • Spline
  • TangentArc
  • ThreePointArc

For multi edged forms you can use 2D polyline. Also there are predefined 2D shapes like rectangles, triangles or circle.

To extrude the form you have created from 1D commands and use it for further building you will need to make a 2D sketch out of it.

This will create a so called face.

See: 2D Rectangle