Subscribe to this thread
Home - General / All posts - API Copy method
sknox59 post(s)
#18-Feb-21 22:23

I'm assuming the only ways to copy Table / Drawing components in the API are to run a SQL query, or have I missed something?

Also, is there a way to merge components? I have rolled my own by Topology Unioning all layers sequentially to each other in SQL but I imagine the merge layers algorithm is more efficient if it could be exposed?


309 post(s)
#19-Feb-21 00:40

There has been that level of component control in v.8 but with the retooling done for 9 it hasn't been exposed to that level yet. I am confident that this resides in a timeline someplace, but I understand other enhancements have a precedence before we get there. I don't remember the link to the developers hints at upcoming target areas of development. I should think that this can be turned on rapidly enough, but may expose some degree of worm-can prematurely.

The migration to a all database objects was a big one for Manifold 9 a necessary change, but a practical change of workflow. Seeking out how to code up and run the query of a table creation/update is a valuable skill moving forward. My advice is to delve into this sooner than later.

sknox59 post(s)
#19-Feb-21 01:20

Yeah, it's ok, I was able to knock this up reasonably quickly to be fair, and I totally understand the point about other priorities, it's just I guess I expected to find that function. But no matter, can definitely live with it.

def copy_table(old_table, new_table):

    fld_names = []

    properties = db.GetProperties(old_table)

    with db.Search(old_table) as tbl:

        schema = tbl.GetSchema()

        fields = schema.Fields

        for fld in fields:


        sequence = tbl.SearchAll(Array[str](fld_names))

        new_tbl = db.Insert(new_table,"Table", schema)

        db.SetProperties(new_tbl, properties)

        with db.Search(new_tbl) as tbl2:



9,635 post(s)
#19-Feb-21 21:55

That looks so economical. Great example (which I will use, thanks).

Manifold User Community Use Agreement Copyright (C) 2007-2019 Manifold Software Limited. All rights reserved.