4.3 矢量图形和表格

用户可以使用 MicroCity 脚本操作 形状(Shapes)表格(Tables)。有关形状(Shapes)的详细数据结构,您可以参考上一章节 2.23.2。由于形状(Shapes)可以被视为带有地理数据的表格(Tables),因此一些用于表格数据操作的嵌入函数可以在 形状(Shapes)表格(Tables) 中同时使用。本章节的示例代码可以在 项目(Project) 选项卡的"shapes_samples"文件夹中找到,该文件夹位于 iconScriptEditor

表格数据操作

CreateShapes ("name", "Point|Line|Polygon")

返回一个 Shapes 对象。

CreateTable ("Name")

返回一个 Table 对象。

GetFieldCount (Shapes|Table)

返回 ShapesTable 中字段的数量。

GetField (Shapes|Table, iField)

输入字段的索引(从 1 开始)并返回字段名和类型("Int"、"Float"、"Double" 或 "String")。

AddField (Shapes|Table, "field1", "Int|Float|Double|String" [, "field2", "Int|Float|Double|String", ...])

向 *Table 或 Shapes 添加字段,并按照顺序返回布尔值(truefalse)。

DelField (Shapes|Table, iField)

成功删除字段时返回 true

GetRecCount (Shapes|Table)

返回 ShapesTable 中的记录总数。

AddRecord (Shapes|Table)

ShapesTable 添加一条记录,并返回该记录的索引。

GetValue (Shapes|Table, "field_name", index1 [, index2, ...])

从指定字段和 ShapesTable 的索引中检索值。按照索引的顺序返回多个值。

SetValue (Shapes|Table, value, "field_name", index1 [, index2, ...])

为指定字段和 ShapesTable 的索引设置值。

地理数据操作

GetSelections (Shapes)

Shapes中返回所选的形状对象。

GetShape (Shapes, index1 [, index2, ...])

按索引顺序从Shapes中返回Shape对象。

AddShape (Shapes, Shape)

Shape对象添加到Shapes中并返回其索引。

AddShape (Shapes [, x1, y1, x2, y2, ...])

将定义为点的Shape对象添加到Shapes中。返回Shape对象和索引。

DelShape (Shape|Shapes)

删除一个ShapeShapes对象,如果成功则返回true。

AddPoint (Shape, x, y [, iPart = 1])

Shape中添加一个点,如果成功则返回true。

InsPoint (Shape, x, y [, iPoint = 1 [, iPart = 1]])

Shape中插入一个点,如果成功则返回true。

SetPoint (Shape, x, y [, iPoint = 1 [, iPart = 1]])

设置Shape中的点坐标,如果成功则返回true。

DelPoint (Shape, iPoint [, iPart=1])

Shape中删除位置为iPoint的一个点,如果成功则返回true。

DelPart (Shape, iPart)

Shape中删除一个部分,如果成功则返回true。

GetPartCount (Shape)

返回Shape中部分的数量。

GetPointCount (Shape [, iPart])

返回Shape中点的数量。

GetPointXY (Shape [, iPoint [, iPart = 1]])

Shape或指定点的坐标中返回所有点的坐标:x1,y1,x2,y2,...。

CopyShapeTo (TargetShapes, dx, dy, Shape1 [, Shape2, ...])

Shape对象复制到目标Shapes,并进行相对平移(dx,dy),返回新的Shape对象。

MoveShapeTo (dx, dy, Shape1 [, Shape2, ...])

Shape对象平移到其相对位置(dx,dy)。

GetCenterXY (Shapes)

返回Shapes的中心坐标(x,y)。

GetCenterXY (Shapes, index1 [, index2, ...])

返回在Shapes中由索引指定的Shape对象的中心坐标(x1,y1,x2,y2,...)。

GetCenterXY (Shape1 [, Shape2, ...])

返回Shape对象的中心坐标(x1,y1,x2,y2,...)。

GetDistance (x1, y1, x2, y2 [, x3, y3, ...])

返回每两个坐标(x,y)对之间的总距离。

GetShapeLen (Shape1 [, Shape2, ...])

返回Shape对象的长度。

GetShapeArea (Shape1 [, Shape2, ...])

返回Shape对象的面积。

GetShapeType (Shape|Shapes)

返回ShapesShape对象的类型("Point","Line"或"Polygon")。

GetExtent (Shapes)

返回Shapes的范围坐标(Lx,By,Rx,Ty)。

GetExtent (Shapes, index)

返回Shapes中索引为index的Shape的范围坐标(Lx,By,Rx,Ty)。

GetExtent (Shape)

返回Shape的范围坐标(Lx,By,Rx,Ty)。

GetIntersection (ShapeA, ShapeB)

返回两个Shapes的交集的ShapePointLinePolygon)对象。

GetValue (Shape, "field_name")

返回Shape的指定字段的值。

SetValue (Shape, value1, "field_name1" [, value2, "field_name2", ...])

Shape的不同字段设置值。

SetCoorSys ("Earth"|"Non-Earth")

设置坐标系统。如果使用"Earth",距离、长度和面积将根据地球椭球坐标系统计算。默认情况下使用"Non-Earth",即笛卡尔坐标系统。

这篇文章使用ChatGPT翻译自其他语言,如果有问题请在反馈open in new window页面提交反馈。

Last Updated:
Contributors: huuhghhgyg