کانکتور
Contents
[
Hide
]
نحوه اتصال اشکال با کانکتورها و تغییر هدفهای آنها را با استفاده از Aspose.Slides for Python via .NET نشان میدهد.
افزودن یک کانکتور
یک شکل کانکتور را بین دو نقطه در اسلاید وارد کنید.
def add_connector():
with slides.Presentation() as presentation:
slide = presentation.slides[0]
# اضافه کردن یک شکل کانکتور خمیده.
connector = slide.shapes.add_connector(slides.ShapeType.BENT_CONNECTOR2, 0, 0, 100, 100)
presentation.save("connector.pptx", slides.export.SaveFormat.PPTX)
دسترسی به یک کانکتور
اولین شکل کانکتور افزوده شده به یک اسلاید را بازیابی کنید.
def access_connector():
with slides.Presentation("connector.pptx") as presentation:
slide = presentation.slides[0]
# دسترسی به اولین کانکتور در اسلاید.
first_connector = None
for shape in slide.shapes:
if isinstance(shape, slides.Connector):
first_connector = shape
break
حذف یک کانکتور
یک کانکتور را از اسلاید حذف کنید.
def remove_connector():
with slides.Presentation("connector.pptx") as presentation:
slide = presentation.slides[0]
# فرض کنید شکل اول یک کانکتور است.
connector = slide.shapes[0]
# حذف کانکتور.
slide.shapes.remove(connector)
presentation.save("connector_removed.pptx", slides.export.SaveFormat.PPTX)
اتصال مجدد اشکال
یک کانکتور را به دو شکل متصل کنید با اختصاص هدفهای شروع و پایان.
def reconnect_shapes():
with slides.Presentation("connector.pptx") as presentation:
slide = presentation.slides[0]
# افزودن اولین شکل مستطیل.
shape1 = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 0, 0, 50, 50)
# افزودن دومین شکل مستطیل.
shape2 = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 100, 100, 50, 50)
# افزودن یک شکل کانکتور خمیده.
connector = slide.shapes.add_connector(slides.ShapeType.BENT_CONNECTOR2, 0, 0, 100, 100)
# اتصال نقطه شروع کانکتور به اولین شکل.
connector.start_shape_connected_to = shape1
# اتصال نقطه پایان کانکتور به دومین شکل.
connector.end_shape_connected_to = shape2
presentation.save("shapes_reconnected.pptx", slides.export.SaveFormat.PPTX)