05-31-2022, 01:23 PM
RoboDK may be unable to properly retrieve the size of your image in some circumstances, such as when you load the SVG image you shared. One workaround is to use a PNG file instead (as you mentioned). If you want better resolution you can load a larger image, then, scale it down using the Scale option.
另一个选择would be to scale the image object to obtain your desired size after you loaded the image. For example, once you loaded the image in RoboDK as an object, you can retrieve the size and scale accordingly:
另一个选择would be to scale the image object to obtain your desired size after you loaded the image. For example, once you loaded the image in RoboDK as an object, you can retrieve the size and scale accordingly:
Code:
my_desired_width = 100 # Set the desired image width in mm
import json
# Get the current width and calculate the scale
img_size = object.setParam("BoundingBox")
img_size = json.loads(img_size) # Convert the JSON formatted string to a dict
scale = my_desired_size / img_size['max'][0]
# You can also provide a per-axis scale
object.Scale(scale)