from pyautocad import Autocad, APoint
def draw_tree():
acad = Autocad()
acad.prompt("Creating a simple tree...\n")
# Define base coordinates for the trunk
base_point = APoint(0, 0)
trunk_height = 100
trunk_width = 20
# Draw the trunk
trunk1 = acad.model.AddLine(base_point, APoint(0, trunk_height))
trunk2 = acad.model.AddLine(APoint(trunk_width, 0), APoint(trunk_width, trunk_height))
trunk3 = acad.model.AddLine(base_point, APoint(trunk_width, 0))
trunk4 = acad.model.AddLine(APoint(0, trunk_height), APoint(trunk_width, trunk_height))
# Define top point for branches
top_point = APoint(trunk_width / 2, trunk_height)
# Define branch length
branch_length = 50
# Draw simple branches
branch1 = acad.model.AddLine(top_point, APoint(top_point.x - branch_length, top_point.y + branch_length))
branch2 = acad.model.AddLine(top_point, APoint(top_point.x + branch_length, top_point.y + branch_length))
# Draw leaves as additional lines/ circles (optional)
# Example of adding simple circle to represent a leaf
# Uncomment and customize as needed
# leaf_radius = 10
# leaf1 = acad.model.AddCircle(APoint(top_point.x - branch_length, top_point.y + branch_length), leaf_radius)
# leaf2 = acad.model.AddCircle(APoint(top_point.x + branch_length, top_point.y + branch_length), leaf_radius)
acad.prompt("Tree creation is complete.\n")
if __name__ == "__main__":
draw_tree()