|
In case anyone was interested, I've genericized the script into a VBScript function. You simply pass the script 3 items: the drawing you want to split, the column that has the values you want to split into, and another drawing with the coordinate system you are interested in. When the script is done, you'll have N drawings that are represented by the attribute value that you wanted to split by. I'm assuming the geometry field is called 'g', but we could also add the geometry field as a variable to pass into the function. This is pretty easy to script, but it would be nice to have it as a Transform. However, if Manifold isn't going to add lots and lots of Transforms, maybe we could create some kind of code challenge library where people write their code to do certain functions, and others can pull from it. As another thought, it would be cool if Manifold could create a Transform tool maker that would allow users to create their own transforms with VBScript. Sort of like how Esri does it with Script Tools. The variables could be directives to create a Transform interface. So, in the example of my script, we could have a transform with 3 inputs: the drawing we want to transform, the column we want to transform, and the coordinate system we want to use. ' VBScript Set app = Manifold.Application Set db = app.GetDatabaseRoot() Sub Main SplitByAttributes "allpoints", "start_depth", "allpoints Drawing" End Sub Sub SplitByAttributes (drawing_name, column_name, coordDrawing) Set db = app.GetDatabaseRoot() thesql = "SELECT distinct([" + column_name + "]) AS uniquename FROM [" + drawing_name + "]" Set uniquefeatures = db.Run(thesql) Set sequence = uniquefeatures.SearchAll(Array("uniquename")) Do While sequence.Fetch() theuniqueval = sequence.GetValues()(0).Data sqlquery = "SELECT * INTO [split_" + cstr(theuniqueval) + "] FROM " + drawing_name + " " &_ " WHERE " + column_name + " = " + cstr(theuniqueval) app.log sqlquery db.Run(sqlquery) sqlquery = "CREATE DRAWING [split_" + cstr(theuniqueval) + " Drawing] " &_ " ( PROPERTY 'FieldGeom' 'g', PROPERTY 'Table' '[split_" + cstr(theuniqueval) + "]' );" db.Run(sqlquery) sqlquery = "ALTER TABLE [split_" + cstr(theuniqueval) + "] (ADD PROPERTY 'FieldCoordSystem.g' ComponentCoordSystem([" + coordDrawing + "]));" app.log sqlquery db.Run(sqlquery) Loop End Sub
|