非基本形状中的数据

访问非基本形状的数据

有时,您需要访问非内置形状的形状的数据。内置形状称为基本形状;而不是内置形状的称为非基本形状。例如,您可以使用不同的曲线连接线定义自己的形状。

非基本形状

在Aspose.Cells for Python via .NET中,非原始形状分配了类型AutoShapeType.NOT_PRIMITIVE。您可以使用Shape.auto_shape_type属性检查它们的类型。

使用 Shape.paths 属性访问形状数据。它返回组成非原始形状的所有连接路径。这些路径的类型为 ShapePath,包含了所有段的列表,而每个段又包含了每个段中的点。

显示了非原始形状的示例
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))