Code for drawing a beam in civil engineering

Question:


Repl link:

SCREEN 12  ' Set screen mode to graphics
' Define beam parameters
beam_length = 500
beam_height = 20
load1_pos = 100
load2_pos = 250
load3_pos = 400
load_force = 100
' Draw beam
LINE (0, 200)-(beam_length, 200 + beam_height), 15, B
LINE (0, 200)-(beam_length, 200), 15, B
LINE (0, 200 + beam_height)-(beam_length, 200 + beam_height), 15, B
' Draw point loads
CIRCLE (load1_pos, 200), 10, 15, , , F
CIRCLE (load2_pos, 200), 10, 15, , , F
CIRCLE (load3_pos, 200), 10, 15, , , F
' Label point loads
LOCATE 5, 1
PRINT "Load 1"
LOCATE 5, 2
PRINT "Load 2"
LOCATE 5, 3
PRINT "Load 3"
' Draw arrows for point loads
ARROW (load1_pos, 200 + beam_height + 20)-(load1_pos, 200 + beam_height), 15, , , F
ARROW (load2_pos, 200 + beam_height + 20)-(load2_pos, 200 + beam_height), 15, , , F
ARROW (load3_pos, 200 + beam_height + 20)-(load3_pos, 200 + beam_height), 15, , , F
' Label arrows with load force
LOCATE 5, 4
PRINT load_force, "N"
LOCATE 5, 5
PRINT load_force, "N"
LOCATE 5, 6
PRINT load_force, "N"

Hey @promisechi welcome to the forums!

Thank you for your post and sorry that you are experiencing issues. However, we may not be able to help you with this issue if you do not complete the template fields fully.

Without more information, there won’t be much we can do to help you. A screenshot of the expected output would also be appreciated.

The more information you provide at the start, the easier it will be to identify the bug in your program.

1 Like

Seems you are using basic.

I saw nothing wrong with your code, my only recomendation would be to you create subroutines for each part of the drawing process (draw point loads, label loads, draw arrows, and label arrows) for better code organization and modularity.

Like 9pfs1 said you need to provide more information about what’s happening and what you want to achieve.