Nice :) - and shows that Manifold offers many ways to the same goal! FWIW here's a version of the script, project with components attached. A good oppportunity to test the relative speeds of SQL and scripting... M Sub Main ' This script displays a list of vertices with the lat / lon pairs in one column ' first get all the vertices in a "long list" ' Then loop through the list, and summarise the output into one record per id ' The project needs a query called "query", a query called "actionQuery" ' and a table called "Table" with columns ID (integer) and coordinates (text) ' And, of course, the drawing to split Set doc = Application.ActiveDocument ' Get the doc Set cs = doc.ComponentSet ' Get the Component Set ' empty the output table cs("Table").clear set theQuery = cs("Query") ' the split query set actionQuery = cs("ActionQuery") ' this is the insert query for each id ' First run the "split" query to get the vertices ' This is Tim's query, I added sorting by id and longitude theText = "OPTIONS COORDSYS(""Drawing"" AS COMPONENT);" theText = theText & "SELECT " theText = theText & "[ID], [Point], " theText = theText & " CentroidX([Point]) AS [Longitude], " theText = theText & " CentroidY([Point]) AS [Latitude] " theText = theText & "FROM " theText = theText & " (SELECT " theText = theText & " [ID], " theText = theText & " Project([Vertex], COORDSYS(""Latitude / Longitude"")) AS [Point] " theText = theText & " FROM [Drawing]" theText = theText & " WHERE IsArea([ID]) " theText = theText & " SPLIT BY Coords([Geom (I)]) AS [Vertex] " theText = theText & " ) " theText = theText & "ORDER BY " theText = theText & " [ID],Centroidx(Point);" theQuery.text = theText theQuery.RunEx TRUE ' run the query Set theTable = theQuery.Table ' the querie's table Set theRecords = theTable.RecordSet '... and the recordset recordCount = 0 ' track the previous id. As we loop through the records, write a record when this changes oldID = "" ' the id from the previous record theValue = "" ' A list of all the lon / lat pairs newID = "" ' the ID from the current record newValue = "" ' the lon / lat pair from the current record FOR EACH r in theRecords ' loop through the records recordCount = recordCount + 1 ' increment the record counter newID = r.datatext("ID") ' get the new ID, treat it as text in the script newValue = r.dataText("Longitude") & " " & r.dataTExt("Latitude") ' concatenate lon and lat IF newID <> oldID THEN ' The ID has changed ' IF it is not the first record, write the old record IF recordcount > 1 THEN actionQuery.text = "insert into [Table] values(" & oldID & " ,""" & theValue & """)" actionQuery.RunEx TRUE END IF ' reset the variables oldID = newID theValue = newValue ELSE ' append the next value theValue = theValue & ", " & newValue END IF NEXT ' write the last record actionQuery.text = "insert into [Table] values(""" & oldID & """ ,""" & theValue & """)" actionQuery.RunEx TRUE ' display the table cs("Table").open END SUB Attachments: vertices.map
|