How to distinguish or identify whether a object is OLE Object or Chart or Shape?
Lets suppose I have slide consist of OLE Object, Chart and Shape. So, how will I get to know the type of object using Aspose.Slides for Python via .NET?
How to distinguish or identify whether a object is OLE Object or Chart or Shape?
Lets suppose I have slide consist of OLE Object, Chart and Shape. So, how will I get to know the type of object using Aspose.Slides for Python via .NET?
@a0pro0b,
Thank you for posting the question.
To check the type of an object placed on a PowerPoint presentation slide, you can use the isinstance
function like this:
if isinstance(shape, OleObjectFrame):
print(shape.name)
Thanks for your reply Andrey. The solution Works.
However, I am looking for a more generalized way of doing it. I mean you just give a object as input and get the object type as output. Also, it should work for every object that PowerPoint supports, not only for ole object or chart but for all the other objects like shapes, groups etc.
Let me know if you have anything for the above.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESPYNET-75
You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thanks for creating the ticket.
What’s the estimated timeline to get a answer for my query?
Actually, I’m working on a PPT automation project where I deal with different object like chart, ole_object, different shapes and many more. As we have different methods for different objects for example, ‘chart_data’ can only be accessed from chart object.
Therefore, in order to use these methods with their corresponding compatible objects, I need to know which type of object is it.
Although you shared me a workaround earlier, that doesn’t really fit with my requirements cause I’m dealing thousands of different objects and passing each object through a if statement increase the time complexity and also I need to write the if statement for all type of objects which I believe isn’t a good way of writing the snippet.
As a result, I require a function which takes in a object and spits out the type of object.
Just for your reference, Python-PPTX has a method named “shape_type” which takes in an object and spits you the type of object like “TEXT_BOX (17)” for text boxes, “CHART (3)” for charts, “AUTO_SHAPE (1)” for different shapes, “EMBEDDED_OLE_OBJECT (7)” for ole objects.
I hope I make my use cases clear for you. Thanks for trying to help me out.
@a0pro0b,
The string representation of an object type can be obtained in the following way:
import aspose.slides as slides
with slides.Presentation("presentation.pptx") as pres:
slide = pres.slides[0]
for shape in slide.shapes:
print(shape.get_type().full_name)