from pyautocad import Autocad, APoint
def draw_tree(autocad, base_point, trunk_height, trunk_width, foliage_radius):
# Draw the trunk
trunk_point1 = base_point
trunk_point2 = APoint(base_point.x + trunk_width, base_point.y)
trunk_point3 = APoint(base_point.x + trunk_width, base_point.y + trunk_height)
trunk_point4 = APoint(base_point.x, base_point.y + trunk_height)
# Draw rectangle for the trunk
autocad.model.AddLine(trunk_point1, trunk_point2)
autocad.model.AddLine(trunk_point2, trunk_point3)
autocad.model.AddLine(trunk_point3, trunk_point4)
autocad.model.AddLine(trunk_point4, trunk_point1)
# Draw the foliage
foliage_center = APoint(base_point.x + trunk_width / 2, base_point.y + trunk_height + foliage_radius / 2)
autocad.model.AddCircle(foliage_center, foliage_radius)
def main():
autocad = Autocad(create_if_not_exists=True)
autocad.prompt("Script running...\n")
base_point = APoint(0, 0) # Starting point for the tree
trunk_height = 10 # Height of the tree trunk
trunk_width = 4 # Width of the tree trunk
foliage_radius = 6 # Radius of the tree foliage
draw_tree(autocad, base_point, trunk_height, trunk_width, foliage_radius)
if __name__ == "__main__":
main()