OSArch Community

[topologic] topologicpy - an independent python API for topologic

  1. T

    Hi everyone,

    As you may know, I have embarked on an effort to port all the capabilities of Topologic + TopologicSverchok into a host-independent, GUI-independent, and platform-agnostic API. The result is topologicpy and it can be installed with a simple command on Windows and Linux:

    
      > pip install topologicpy
    

    I would like to use this forum to collect your feedback on this effort and to make sure that this API is robust and useful for you. You can comment on anything regarding this project including its direction, the quality of the code, the quality of the documentation, suggestions for the future, among other issues.

    At the moment, topologicpy implements the complete API for topologic (Core). So it is useful in its current state. Additionally, most of the relevant classes of TopologicSverchok have also been ported, but they have not yet been fully tested. The code is being refactored where needed and documented using docstrings. The documentation is being auto-generated using pdoc3 https://pdoc3.github.io/pdoc/. This is ongoing work and any help is more than welcome.

    As a user of topologicpy, you have a choice to access topologic directly using:

    
      from topologicpy import topologic
    
      v = topologic.Vertex.ByCoordinates(0,0,0)
    
      print(v)
    
      >>> <topologic.Vertex object at 0x00000211E0205C30>
    

    or access topologic through topologicpy classes:

    
      from topologicpy.Vertex import Vertex
    
      v = Vertex.ByCoordinates(0,0,0)
    
      print(v)
    
      >>> <topologic.Vertex object at 0x000001DF2B3B2C70>
    

    Please do test topologicpy and go through the code and documentation, report any issues, and ask for features and improvements. I hope you will enjoy topologicpy and I hope this discussion topic will be as active and rich as the original discussion topic for Topologic.

  2. M

    This is awesome! So TopologicSverchok now uses TopologyPy under the hood, is TopologicFreeCAD (I recall seeing an implementation there) also ported? I assume the Dynamo/Grasshopper implementations share a TopologicC# or similar under the hood?

  3. T

    No sorry TopologicSverchok has not yet migrated to topologicpy, but that will be the next step once all the methods in topologicpy have been refactored and tested. It will make TopologicSverchok nodes have far less code in them.

    I do have the start of a TopologicFC workbench on GitHub that decomposes a CellComplex, but I need help with that. I don’t know how to implement numeric input, checkboxes etc and how to pass to topologic multiple selections of FreeCAD scene objects.

    TopologicDynamo and TopologicGH share the same but much older C# and C++ code base. This will be deprecated. If I ever have time, these nodes will be recreated to also use topologicpy. This will keep all platforms synced. The new nodes will be nothing more than custom python nodes wrapping around topologicpy classes and methods.

    Another aspect is that once topologicpy is ready, Streamlit can just pip install it and it will be available to topologic-based web apps. We have already proven that with our work connecting Speckle and Pollination (we being myself and Jake Staub).

    And finally, there is a need to migrate topologicpy methods down to the C++ level so we increase performance. For now it is easier for me not to mess with the C++ code base and implement new functionality in topologicpy in python.

  4. M

    Still sounds pretty amazing! Do you think it's appropriate to write a ~300 word article about it on osarch.org?

  5. T

    @Moult said:

    Still sounds pretty amazing! Do you think it's appropriate to write a ~300 word article about it on osarch.org?

    Sure. Will also include a diagram of the architecture and the ecosystem.

  6. C

    Nice!

    Do you have any examples?

    Could it be used to create space meshes from bounded walls, slabs, celings, to create IfcSpaces?

  7. T
  8. P

    I used @brunopostle 's rpm for use in FreeCAD on Fedora 36.

    Any difference with topologicpy ? Thanks :)

  9. T

    Hi @paullee yes big difference. If I am not mistaken, what you are using is only Topologic (Core). topologicpy is the sum total of core plus all the functionality of TopologicSverchok nodes made headless. So things like machine learning, advanced graph functionality, energy analysis etc etc

  10. B

    @paullee I need to rearrange my rpms to match this new code split

  11. T

    Just to note that topologicpy is a few weeks from being complete. The Core is complete. I am working my way through all the topologicsverchok classes and methods to streamline. There will be some API differences between sverchok and py (not to Core). These will be brought back to sverchok eventually.

  12. C
  13. T
  14. A

    Hi, i am trying to make a topology by using a shape from Open Cascade. I am using the method

    
    topologicpy.topologic.TopologyByOcctShape(newShape) 
    

    I'm passing the argument newShape, which is an OCC.Core.TopoDS.TopoDS_Shape from PythonOCC module and getting the following error:

    
     TypeError: ByOcctShape(): incompatible function arguments. The following argument types are supported:
    
        1. (rkOcctShape: topologic.TopoDS_Shape, rkInstanceGuid: str = '') -> topologic.Topology
    

    Is there a way to convert a OCC.Core.TopoDS.TopoDS_Shape to topologic.TopoDS_Shape ?

    Thanks for any info.

  15. T

    Hi @ArchProgrammer

    PythonOCC is probably wrapping the TopoDS_Shape which Topologic knows nothing about. Instead, the easiest way is to produce the BREP string from your TopoDS_Shape and feed it to myTopology = Topology.ByString(brepString)

  16. A

    @topologic said:

    Hi @ArchProgrammer

    PythonOCC is probably wrapping the TopoDS_Shape which Topologic knows nothing about. Instead, the easiest way is to produce the BREP string from your TopoDS_Shape and feed it to myTopology = Topology.ByString(brepString)

    Thanks, it worked!

  17. T

    @ArchProgrammer said:

    @topologic said:

    Hi @ArchProgrammer

    PythonOCC is probably wrapping the TopoDS_Shape which Topologic knows nothing about. Instead, the easiest way is to produce the BREP string from your TopoDS_Shape and feed it to myTopology = Topology.ByString(brepString)

    Thanks, it worked!

    Great. Please share visual results if you can! :)

  18. T

    Also. If PythonOCC can create entities from a BREP string, you can use brepString = Topology.String(aTopology, version=1)

  19. P

    Hope the topologicpy can work in FreeCAD 0.21, as it works in 0.20 :D

  20. T

    @paullee said:

    Hope the topologicpy can work in FreeCAD 0.21, as it works in 0.20 :D

    Sadly no :(

    I don't know why. It loads perfectly well under python3.8 and it works perfectly with FreeCAD 0.20. What did they change in 0.21 to make it fail??

    import topologicpy

    Traceback (most recent call last):

    File "<input>", line 1, in <module>

    File "C:\Program Files\FreeCAD 0.21\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport__feature__.py", line 142, in _import

    return original_import(name, *args, **kwargs)

    File "C:\Program Files\FreeCAD 0.21\bin\lib\site-packages\topologicpy__init__.py", line 19, in <module>

    import topologic

    File "C:\Program Files\FreeCAD 0.21\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport__feature__.py", line 142, in _import

    return original_import(name, *args, **kwargs)

    ImportError: DLL load failed while importing topologic: The specified procedure could not be found.

    I posted this as an issue on FreeCAD's github: https://github.com/FreeCAD/FreeCAD/issues/8703

  21. P

    @yorik Any idea? Thanks.

    Discussion about test on Fedora 36 -

    https://community.osarch.org/discussion/131/topologic-redefining-bim-through-spatial-topology-information-and-grammars#latest

    import sys
    
    sys.path.append("/home/paullee/.local/lib/python3.10/site-packages")
    
    import topologicpy
    
    
    Traceback (most recent call last):
    
    File "", line 1, in
    
    File "/home/paullee/Downloads/FreeCAD_weekly-builds-31391-2022-12-22-conda-Linux-x86_64-py310/squashfs-root/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    
    return original_import(name, *args, **kwargs)
    
    File "/home/paullee/.local/lib/python3.10/site-packages/topologicpy/__init__.py", line 16, in
    
    import topologic
    
    File "/home/paullee/Downloads/FreeCAD_weekly-builds-31391-2022-12-22-conda-Linux-x86_64-py310/squashfs-root/usr/lib/python3.10> /site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    
    return original_import(name, *args, **kwargs)
    
    ImportError: /home/paullee/.local/lib/python3.10/site-packages/topologicpy/bin/linux/topologic/./libTopologicCore.so.0: undefined symbol: _ZN24BRepBuilderAPI_MakeShape5BuildEv
  22. T

    SOLVED!

    It turns out, I had my old Topologic Workbench in my C:\Users[username]\Appdata\Roaming\FreeCAD\Mod\ folder which was incompatible with FreeCAD 0.21.0 This was being loaded first before the newer topologic included in topologicpy.

    It is now working fine on Windows.

  23. Y

    yes i was going to say, version mismatch :)

  24. T

    Thankfully, with the DLL mangling step when building Topologic, DLL version mismatch should not be an issue moving forward.

  25. P

    @topologic said:

    Thankfully, with the DLL mangling step when building Topologic, DLL version mismatch should not be an issue moving forward.

    Congratulation! Hope RPM (or whatever) would be available on Linux (Fedora) so I can tes :D

  1. Page 1
  2. 2

Login or Register to reply.