Dati in Forma Non Primitiva

Accesso ai Dati di Forma Non-Primitiva

A volte, è necessario accedere ai dati da una forma non incorporata. Le forme incorporate sono chiamate forme primitive; quelle che non lo sono vengono chiamate non primitive. Ad esempio, è possibile definire le proprie forme utilizzando diverse linee collegate da curve.

Una Forma Non-Primitiva

In Aspose.Cells per Python via .NET, le forme non primitive vengono assegnate il tipo AutoShapeType.NOT_PRIMITIVE. È possibile verificare il loro tipo utilizzando la proprietà Shape.auto_shape_type.

Accedere ai dati della forma utilizzando la proprietà Shape.paths. Restituisce tutti i percorsi collegati che compongono la forma non primitiva. Questi percorsi sono del tipo ShapePath che contiene un elenco di tutti i segmenti che a loro volta contengono i punti in ciascun segmento.

Mostra un esempio di una forma non primitiva
todo:image_alt_text
from aspose.cells import Workbook
from aspose.cells.drawing import AutoShapeType
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
workbook = Workbook(dataDir + "NonPrimitiveShape.xlsx")
worksheet = workbook.worksheets[0]
# Accessing the user defined shape
shape = worksheet.shapes[0]
if shape.auto_shape_type == AutoShapeType.NOT_PRIMITIVE:
# Access shape's data
shapePathCollection = shape.paths
# Access information of indvidual path
for shapePath in shapePathCollection:
# Access path segment list
pathSegments = shapePath.path_segement_list
# Access individual path segment
for pathSegment in pathSegments:
# Gets the points in path segment
segmentPoints = pathSegment.points
for pathPoint in segmentPoints:
print("X: " + str(pathPoint.x) + ", Y: " + str(pathPoint.y))