Subscribe to this thread
Home - General / All posts - Python 3 and Manifold 9
artlembo


3,255 post(s)
#03-May-22 22:32

Has anyone used Manifold with Python 3? I’d like to be able to instantiate a Manifold object via Python and call it from inside of ArcGIS, using ArcPy. That way, I can try to run Manifold SQL from within an Arcpy script.

For those of you with Esri knowledge, imagine creating a script tool in a Geodatabase, but instead of calling an ArcPro geoprocessing tool, you replace it with a Manifold 9 SQL function.

This idea just screams speed test.

danb


1,931 post(s)
#03-May-22 23:17

Nice idea. I don't know the mechanics of it, but in terms of speed, wouldn't the issue for the Manifold SQL be the read and write access speeds imposed by the FGDB?

I'd be very interested to hear where you get to with this however. Sounds like fun!


Landsystems Ltd ... Know your land | www.landsystems.co.nz

rk
504 post(s)
#04-May-22 06:57

With Python.NET http://pythonnet.github.io/ it should be possible. I did try it once.

#python

# conda create -n pnnet pythonnet

# conda activate pnnet

import clr

clr.AddReference('System.Threading')

from System.Threading import ApartmentState, Thread, ThreadStart

clr.AddReference("C:\\Program Files\\Manifold\\v9.0\\bin64\\extnet.dll")

import Manifold

# check

print(dir(Manifold))

def app_thread():

    dir(Manifold)

    root = Manifold.Root('')

    app = root.Application

    print(app.Name)

    db = app.CreateDatabaseForFile(r"D:\some\m9_mapfile.map"True)

    print(db.Technology)

    in_csv_filename = r"D:\Some\csv_file.csv"

    csv = app.CreateDatabaseForFile(in_csv_filename, True)

    print(csv.Technology)

def main():

    thread = Thread(ThreadStart(app_thread))

    thread.SetApartmentState(ApartmentState.STA)

    thread.Start()

    thread.Join()

if __name__ == '__main__':

    main()

 

### should print ###

# Manifold System

# manifold

# csv

###

Attachments:
mfd-pythonnet.py

artlembo


3,255 post(s)
#05-May-22 14:10

right. That's python.net. I'm interested in calling extnet.dll from inside of ArcGIS through Arcpy - the ability to do that opens up a portal to a really large world of things that can be done. Therefore, I'd be using Python 3.7. I don't know if this is possible or if we need to lobby Manifold to make a manifold package that we can import.

rk
504 post(s)
#05-May-22 18:09

pythonnet (not IronPython) should support 3.7. Try 'pip install pythonnet', using pip from arcpy installation.

I had trouble with 'pip install pythonnet', probably because I used latest python 3.10.something. conda automatically chose a good one.

# Name                    Version                   Build  Channel

bzip2                     1.0.8                h8ffe710_4    conda-forge

ca-certificates           2021.10.8            h5b45459_0    conda-forge

libffi                    3.4.2                h8ffe710_5    conda-forge

libzlib                   1.2.11            h8ffe710_1014    conda-forge

openssl                   3.0.3                h8ffe710_0    conda-forge

pip                       22.0.4             pyhd8ed1ab_0    conda-forge

pycparser                 2.21               pyhd8ed1ab_0    conda-forge

python                    3.9.12          hcf16a7b_1_cpython    conda-forge

python_abi                3.9                      2_cp39    conda-forge

pythonnet                 2.5.2            py39hcbf5309_4    conda-forge

setuptools                62.1.0           py39hcbf5309_0    conda-forge

sqlite                    3.38.3               h8ffe710_0    conda-forge

tk                        8.6.12               h8ffe710_0    conda-forge

tzdata                    2022a                h191b570_0    conda-forge

ucrt                      10.0.20348.0         h57928b3_0    conda-forge

vc                        14.2                 hb210afc_6    conda-forge

vs2015_runtime            14.29.30037          h902a5da_6    conda-forge

wheel                     0.37.1             pyhd8ed1ab_0    conda-forge

xz                        5.2.5                h62dcd97_1    conda-forge

artlembo


3,255 post(s)
#05-May-22 23:57

thanks for the great advice. I have things loaded in Arcpy.

using your code above, I am able to import clr, and add the reference. but when I run

clr.AddReference("C:\\manifold9\\bin64\\extnet.dll")

I get the error:

System.IO.FileNotFoundException: Unable to find assembly 'C:\manifold9\bin64\extnet.dll'.

at Python.Runtime.CLRModule.AddReference(String name)

I've made sure to unblock the .dll in the properties.

Any thoughts? Once I can grab the Manifold object, I can try and bury the code into an ArcGIS Script Tool. I'm going to try with Clip, and see how it goes from there.

tjhb

9,970 post(s)
#06-May-22 05:39

.

artlembo


3,255 post(s)
#06-May-22 10:09

I got it to run. Turns out, the Unblock didn't work, so I had to recheck it. Hoping to have some script tools written this weekend. If I'm successful, I'll post a video.

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