-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.py
62 lines (52 loc) · 2.23 KB
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import logging
logging.basicConfig(level=logging.INFO)
def create_shape(shape_type, x, y, width, height, color="default"):
"""
Creates a shape in Visio at given coordinates with specified dimensions.
"""
# Validate input types
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
raise ValueError("Coordinates (x, y) must be numbers.")
if not isinstance(width, (int, float)) or not isinstance(height, (int, float)):
raise ValueError("Width and height must be numbers.")
if not isinstance(color, str):
raise ValueError("Color must be a string.")
# Adjust coordinates based on shape size to ensure it's fully within the canvas
adjusted_x = max(width / 2, min(x, 100 - width / 2))
adjusted_y = max(height / 2, min(y, 100 - height / 2))
logging.info(f"Creating shape '{shape_type}' at ({adjusted_x}%, {adjusted_y}%) with dimensions {width}%x{height}% and color {color}")
return {
"status": "success",
"shape_type": shape_type,
"position": {"x": adjusted_x, "y": adjusted_y},
"dimensions": {"width": width, "height": height},
"color": color
}
def connect_shapes(shape1, shape2, connection_type="line"):
"""
Connects two shapes in Visio with a specific connection type (line, arrow, etc.)
"""
logging.info(f"Connecting shape '{shape1}' with shape '{shape2}' using {connection_type}.")
return {
"status": "success",
"connection_type": connection_type,
"shapes": [shape1, shape2]
}
def modify_shape_properties(shape, property_name, value):
"""
Simulates modifying properties of a shape in Visio.
"""
valid_properties = ["color", "width", "height", "line_style"] # Add more as needed
if property_name not in valid_properties:
logging.warning(f"Unknown property '{property_name}' for shape '{shape}'.")
return {
"status": "error",
"message": f"Unknown property '{property_name}' for shape '{shape}'."
}
logging.info(f"Modifying shape '{shape}': Setting {property_name} to {value}")
return {
"status": "success",
"shape": shape,
"property": property_name,
"new_value": value
}