[Topologic] Redefining BIM through Spatial Topology, Information, and Grammars

12022242526

Comments

  • @brunopostle said:

    @paullee said:

    I searched and downloaded python3-topologicPy-0.5-0.1.20210615git.fc34.noarch .rpm (can't find again from where I downloaded).

    Can't find inside something similar to what are inside the topologicsverchok-2022-03-18-linux-x86_64.zip.

    This is an old cppyy version, you need the Topologic and Topologic-python3 packages: https://copr.fedorainfracloud.org/coprs/bpostle/IfcOpenShell/package/Topologic/

    @brunopostle Is it possible to remove that obsolete file from 2021 so others don’t fall into that problem? Thanks

  • @brunopostle said:
    This is an old cppyy version, you need the Topologic and Topologic-python3 packages: https://copr.fedorainfracloud.org/coprs/bpostle/IfcOpenShell/package/Topologic/

    I am not familiar with Fedora copr, seems there are a few directory with none content ?

    Nothing for Fedora 34 ?

    This is for Fedora 33 right ?

  • OK, finally with the Fedora33 package running on Fedora 34 :D

    topologic
  • Now this is fun :D

    Searching around to look for explanation on topologic methods, any idea ? (? https://topologic.app/learning/) Thanks

    topologic
  • The following is woefully out of date, but might give you some hints on how to start and then you can look at the python code classes for TopologicSverchok to glean what the methods should be. We need volunteers to document the API!
    https://topologic.app/developer_doc/html/

    paullee
  • @paullee said:

    I am not familiar with Fedora copr, seems there are a few directory with none content ?

    Basically, it is a 'package repository' in addition to the default fedora repositories, so it isn't intended for direct download, enable it like this:

    dnf copr enable bpostle/IfcOpenShell 
    

    After this, for example, you can install the IfcOpenShell-blenderbim package using the fedora software centre, this will pull-in all dependencies (including blender if you don't already have it installed), and will upgrade to the latest version each time you do a system update.

    Similarly, with the repository enabled, you can install Topologic-python3 just like any other default fedora package. The intention is to create a blender-Homemaker-addon package too, but I haven't gotten around to it.

    paullee
  • Anyone works purely on python mode of topologic? :D

    I watched a few YT video on Sverchok-Topologic and Doxygen output of API, but can't understand how it works. I work on FreeCAD python console, and for example trying to export the Brep representation of solid compound and importing into Topologic object, finding which faces are 'external' or 'internal'. Any idea ? Thanks !

    cc=Gui.Selection.getSelection()[0]
    built-in method exportBrepToString of Part.Compound object at 0x55e3ea99d498

    ccbs=cc.Shape.exportBrepToString()
    ccbs
    '\nCASCADE Topology V1, (c) Matra-Datavision\nLocations 7\n1\n 1 0 0 0 \n 0 1 0 0 \n 0 0 1 0 \n1\n 1 0 0 0 \n 0 1 0 0 \n 0 0 1 0 \n1\n 1 0 0 0 \n 0 1 0 0 \n 0 0 1 3000 \n2 2 1 3 1 0\n1\n 1 0 0 0 \n 0 1 0 0 \n 0 0 1 0 \n1\n 1 0 0 0 \n 0 1 0 0 \n 0 0 1 3000 \n2 5 1 6 1 0\nCurve2ds 0\nCurves 13\n1 0 2500 0 0 0 1 \n1 0 0 0 0 0 1 \n1 0 2500 0 0 -1 0 \n1 2417.8812109999999 2500 0 0 0 1 \n1 5000 2500 0 -1 0 0 \n1 2918.5437010000001 0 0 0 0 1 \n1 2918.5437010000001 0 0 -0.19636597175974246 0.9805306752645998 0 \n1 0 0 0 1 0 0 \n1 2918.5437010000001 0 0 0 0 1 \n1 2417.8812109999999 2500 0 0 0 1 \n1 5000 2500 0 0 0 1 \n1 5000 0 0 0 0 1 \n1 5000 0 0 0 1 0 \nPolygon3D 0\nPolygonOnTriangulations 0\nSurfaces 9\n1 0 2500 0 1 0 -0 0 -1 0 0 -0 -1 \n1 2417.8812109999999 2500 0 0 -1 0 -1 0 0 -0 -0 -1 \n1 2918.5437010000001 0 0 -0.9805306752645998 -0.19636597175974246 0 -0.19636597175974246 0.9805306752645998 0 -0 0 -1 \n1 0 0 0 0 1 0 1 0 0 0 0 -1 \n1 -5000 -5000 0 0 0 1 1 0 -0 -0 1 0 \n1 2918.5437010000001 0 0 -0.9805306752645998 -0.19636597175974246 0 -0.19636597175974246 0.9805306752645998 0 -0 0 -1 \n1 5000 2500 0 0 -1 0 -1 0 0 -0 -0 -1 \n1 5000 0 0 -1 0 0 0 1 0 0 0 -1 \n1 2918.5437010000001 0 0 0 1 0 1 0 0 0 0 -1 \nTriangulations 0\n\nTShapes 46\nVe\n1e-07\n0 2500 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 1 0 0 3000\n0\n\n0101000\n+46 2 -46 4 *\nVe\n1e-07\n0 0 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 2 0 0 3000\n0\n\n0101000\n+44 2 -44 4 \nEd\n 1e-07 1 1 0\n1 3 0 0 2500\n0\n\n0101000\n+46 0 -44 0 *\nWi\n\n0101100\n+45 0 -43 0 -42 2 +42 4 *\nFa\n0 1e-07 1 0\n\n0101000\n+41 0 *\nVe\n1e-07\n2417.881211 2500 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 4 0 0 3000\n0\n\n0101000\n+39 2 -39 4 \nEd\n 1e-07 1 1 0\n1 5 0 2582.118789 5000\n0\n\n0101000\n+39 0 -46 0 *\nWi\n\n0101100\n+38 0 -45 0 -37 2 +37 4 *\nFa\n0 1e-07 2 0\n\n0101000\n+36 0 *\nVe\n1e-07\n2918.543701 0 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 6 0 0 3000\n0\n\n0101000\n+34 2 -34 4 \nEd\n 1e-07 1 1 0\n1 7 0 0 2549.639764534\n0\n\n0101000\n+34 0 -39 0 *\nWi\n\n0101100\n+33 0 -38 0 -32 2 +32 4 *\nFa\n0 1e-07 3 0\n\n0101000\n+31 0 *\nEd\n 1e-07 1 1 0\n1 8 0 0 2918.543701\n0\n\n0101000\n+44 0 -34 0 *\nWi\n\n0101100\n+43 0 -33 0 -29 2 +29 4 *\nFa\n0 1e-07 4 0\n\n0101000\n+28 0 *\nWi\n\n0101100\n+42 0 +37 0 +32 0 +29 0 *\nFa\n0 1e-07 5 0\n\n0101000\n+26 0 *\nSh\n\n0101100\n+40 0 +35 0 +30 0 +27 0 +25 2 -25 4 *\nSo\n\n0100000\n-24 0 *\nEd\n 1e-07 1 1 0\n1 9 0 0 3000\n0\n\n0101000\n+34 5 -34 7 *\nEd\n 1e-07 1 1 0\n1 10 0 0 3000\n0\n\n0101000\n+39 5 -39 7 *\nWi\n\n0101100\n+22 0 -21 0 -32 5 +32 7 *\nFa\n0 1e-07 6 0\n\n0101000\n+20 0 *\nVe\n1e-07\n5000 2500 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 11 0 0 3000\n0\n\n0101000\n+18 5 -18 7 \nEd\n 1e-07 1 1 0\n1 5 0 0 2582.118789\n0\n\n0101000\n+18 0 -39 0 *\nWi\n\n0101100\n+17 0 -21 0 -16 5 +16 7 *\nFa\n0 1e-07 7 0\n\n0101000\n+15 0 *\nVe\n1e-07\n5000 0 0\n0 0\n\n0101101\n\nEd\n 1e-07 1 1 0\n1 12 0 0 3000\n0\n\n0101000\n+13 5 -13 7 *\nEd\n 1e-07 1 1 0\n1 13 0 0 2500\n0\n\n0101000\n+13 0 -18 0 *\nWi\n\n0101100\n+12 0 -17 0 -11 5 +11 7 *\nFa\n0 1e-07 8 0\n\n0101000\n+10 0 *\nEd\n 1e-07 1 1 0\n1 8 0 2918.543701 5000\n0\n\n0101000\n+34 0 -13 0 *\nWi\n\n0101100\n+22 0 -12 0 -8 5 +8 7 *\nFa\n0 1e-07 9 0\n\n0101000\n+7 0 *\nWi\n\n0101100\n-32 0 +16 0 +11 0 +8 0 *\nFa\n0 1e-07 5 0\n\n0101000\n+5 0 *\nSh\n\n0101100\n-19 0 +14 0 +9 0 +6 0 +4 5 -4 7 *\nSo\n\n0100000\n-3 0 *\nCo\n\n1100000\n+23 0 +2 0 *\n\n+1 1 '

    tcc=topologic.CellComplex
    tcc.ByString(ccbs)
    <topologic.Cluster object at 0x7fee6ec3c470>

    topologic
  • Your best source is the python code at:
    https://github.com/wassimj/TopologicSverchok/tree/main/nodes/Topologic
    You can look at the function “processItem” in each file and find out how Topologic Python works

    paullee
  • edited April 2022

    Pseudo code. Syntax may not be 100% correct (Sorry on my phone not computer):
    import topologic
    # get some object from scene. Call it obj
    cc = topologic.Topology.ByOCCTShape(obj)
    internal_faces = []
    external_faces = []
    all_faces = []
    _ = cc.Faces(None, all_faces)
    for face in all_faces:
    cells = []
    _ = face.Cells(cc, cells)
    if len(cells) > 1:
    internal_faces.append(face)
    else:
    external_faces.append(face)

    paullee
  • Test file - Rename the file to *.FCstd to open in FreeCAD

  • @topologic said:
    Your best source is the python code at:
    https://github.com/wassimj/TopologicSverchok/tree/main/nodes/Topologic
    You can look at the function “processItem” in each file and find out how Topologic Python works

    Thanks! Lots of reading available over the weekend :D

    topologic
  • Only work with ... topologic.Topology.ByString() in FreeCAD python console :)

    c=Gui.Selection.getSelection()[0]
    cbs=c.Shape.exportBrepToString()
    cc=topologic.Topology.ByString(cbs)

    topologic.Topology.ByOCCTShape(obj) seems not working

    # get some object from scene. Call it obj
    cc = topologic.Topology.ByOCCTShape(obj)
    

    c=Gui.Selection.getSelection()[0]
    cc=topologic.Topology.ByOcctShape(c)

    Traceback (most recent call last):
    File "", line 1, in
    TypeError: ByOcctShape(): incompatible function arguments. The following argument types are supported:
    1. (rkOcctShape: topologic.TopoDS_Shape, rkInstanceGuid: str = '') -> topologic.Topology
    Invoked with:

    Then _=cc.Faces(None, faces)

    faces=[]
    cc

    topologic.Cluster object at 0x7fee535841f0

    _=cc.Faces(None, faces)

    Traceback (most recent call last):
    File "", line 1, in
    TypeError: Faces(): incompatible function arguments. The following argument types are supported:
    1. (self: topologic.Cluster, rFaces: list) -> None
    Invoked with: <topologic.Cluster object at 0x7fee535841f0>, None, []

    Will go through more *.py in your github :D

  • In FreeCAD python console, how do you get an object and its shape from the scene?

  • edited April 2022

    Thanks.

    'Selection set 1st document object '
    s=Gui.Selection.getSelection()[0]

    'shape in FreeCad'
    ss=s.Shape

    'export the shape as Brep String'
    ssbs=s.Shape.exportBrepToString()

  • edited April 2022

    Gone through half of the *.py there, found no use of this as reference :D

    topologic.Topology.ByOCCTShape(obj)

    EDIT - seem no relevant info here either :
    https://topologic.app/user_doc/html/class_topologic_1_1_topology.html

    FURTHER EDIT -
    Noted there is :
    https://github.com/wassimj/TopologicSverchok/blob/main/nodes/Topologic/TopologyByOCCTShape.py

    Hmmm, but do not understand how the 'OCCTShape' is generated and pass to the method :D

  • Hi @paullee I don’t understand how you found 100s of the main python files that drive all of TopologicSverchok of no use! @brunopostle was able to rewrite homemaker using Topologic without documentation. Not ideal obviously, but achievable.
    In any case, I need resources/volunteers to write a set of documentation. I will investigate auto-generated documentation. Anyone willing to help?

    Note: OCCTShape is a DS_Shape. If it doesn’t work stick with the brep string method

  • edited April 2022

    @topologic said:
    Hi @paullee I don’t understand how you found 100s of the main python files that drive all of TopologicSverchok of no use! @brunopostle was able to rewrite homemaker using Topologic without documentation. Not ideal obviously, but achievable.
    In any case, I need resources/volunteers to write a set of documentation. I will investigate auto-generated documentation. Anyone willing to help?

    Note: OCCTShape is a DS_Shape. If it doesn’t work stick with the brep string method

    My problem in fact, not your codes :D

    I am just python beginner and no idea on Blender nor OCCT programming, so I find there are codes on topologic.Topology.ByOCCTShape(obj) but do not understand how similar 'obj' be generated in FreeCAD, not in Blender then I think I can just 'copy and paste' :D. I also find ' topologic.Topology.ByString(BRep String Output from FreeCAD - I find how to do this only) return no error, though still looking around to see how the returned object be used to verified if it is useful at all.

    The answers I am searching around are -
    1) how to export to 'OCCTShape' in FreeCAD, googling but find not solution yet
    2) is the object returned by topologic.Topology.ByString(BRep String Output from FreeCAD) useful and usage of methods

    Still googling, trial and errors, thanks again for the time taken :D

  • I am asking in FreeCAD forum how to export to 'OCCTShape' in FreeCAD after hours of my wild guess :D

  • I hope this helps. First create two cubes in FreeCAD and offset them as you see in the picture on the left. Then select both and run the code below.

    import topologic
    import Part
    s=Gui.Selection.getSelection()
    c1 = s[0]
    c2 = s[1]
    tc1 = topologic.Topology.ByString(c1.Shape.exportBrepToString())
    tc2 = topologic.Topology.ByString(c2.Shape.exportBrepToString())
    print(tc1, tc2)
    tc3 = tc1.Difference(tc2)
    print(tc3)
    tc3 = topologic.TopologyUtility.Translate(tc3, 15, 0, 0)
    shp3 = Part.Shape()
    shp3.importBrepFromString(tc3.String())
    Part.show(shp3)
    tc4 = tc1.Intersect(tc2)
    print(tc4)
    tc4 = topologic.TopologyUtility.Translate(tc4, 30, 0, 0)
    shp4 = Part.Shape()
    shp4.importBrepFromString(tc4.String())
    Part.show(shp4)
    tc5 = tc2.Difference(tc1)
    print(tc5)
    tc5 = topologic.TopologyUtility.Translate(tc5, 45, 0, 0)
    shp5 = Part.Shape()
    shp5.importBrepFromString(tc5.String())
    Part.show(shp5)
    tc6 = tc1.Merge(tc2)
    print(tc6)
    tc6 = topologic.TopologyUtility.Translate(tc6, 60, 0, 0)
    shp6 = Part.Shape()
    shp6.importBrepFromString(tc6.String())
    Part.show(shp6)

    paulleebrunopostle
  • edited April 2022

    @paullee And here is how you get the internal and external faces of a CellComplex. For this example, start by modelling two cubes and put them side by side where they exactly touch. Then run the script below. See the image at the bottom for more explanation.

    import topologic
    import Part

    def get_internal_faces(cellComplex):
    internal_faces = []
    faces = []
    _ = cellComplex.Faces(None, faces)
    for face in faces:
    cells = []
    _ = face.Cells(cellComplex, cells)
    if len(cells) > 1:
    internal_faces.append(face)
    return topologic.Cluster.ByTopologies(internal_faces)

    def get_external_faces(cellComplex):
    external_faces = []
    faces = []
    _ = cellComplex.Faces(None, faces)
    for face in faces:
    cells = []
    _ = face.Cells(cellComplex, cells)
    if len(cells) < 2:
    external_faces.append(face)
    return topologic.Cluster.ByTopologies(external_faces)

    s=Gui.Selection.getSelection()
    c1 = s[0]
    c2 = s[1]
    tc1 = topologic.Topology.ByString(c1.Shape.exportBrepToString())
    tc2 = topologic.Topology.ByString(c2.Shape.exportBrepToString())
    print(tc1, tc2)
    tc3 = tc1.Merge(tc2)
    print(tc3)
    tc3 = topologic.TopologyUtility.Translate(tc3, 25, 0, 0)
    shp3 = Part.Shape()
    shp3.importBrepFromString(tc3.String())
    obj3 = Part.show(shp3)
    obj3.Label = "CellComplex"
    obj3.ViewObject.Transparency=50

    tc4 = get_internal_faces(tc3)
    tc4 = topologic.TopologyUtility.Translate(tc4, 25, 0, 0)
    shp4 = Part.Shape()
    shp4.importBrepFromString(tc4.String())
    internal_faces = Part.show(shp4)
    internal_faces.Label = "Internal Faces"
    internal_faces.ViewObject.Transparency=50

    tc5 = get_external_faces(tc3)
    tc5 = topologic.TopologyUtility.Translate(tc5, 50, 0, 0)
    shp5 = Part.Shape()
    shp5.importBrepFromString(tc5.String())
    external_faces = Part.show(shp5)
    external_faces.Label = "External Faces"
    external_faces.ViewObject.Transparency=50

    paulleebrunopostle
  • edited April 2022

    @topologic said:
    tc1 = topologic.Topology.ByString(c1.Shape.exportBrepToString())
    shp3.importBrepFromString(tc3.String())

    This is really what is needed to start communication between FreeCAD and Topologic !

    In fact, Topologic should be built-in FreeCAD (within the Part API?) , all the methods seems exactly the same and both speaks Brep (as they both based on OpenCascade right?) :D

    • Topologic.Difference is FreeCAD.Part Shape1.cut(Shape2)
    • Topologic.Intersect is FreeCAD.Part Shape1.common(Shape2) ...

    Just did a roundtrip test between FreeCAD Part.Shape to Topologic, made a translation in Topologic and return to FreeCAD. These 2 methods are the keys.

    I can understand the rest of the codes by the way ! Thanks again for taking time mentoring !

    topologicbrunopostle
  • Yes. I have always said that whatever Topologic can do, can be achieved in FreeCAD. One can actually learn the methods we have in Topologic and re-implement them using the FreeCAD API. In fact, when we were developing Topologic, I would at times test the concept using python in FreeCAD, show it to the team and they would write it in C++ directly using the opencascade engine. We made a decision early on to reduce the dependencies and go directly to opencascade (because we wanted a base in C++). If I had time and resources, I can re-build Topologic completely using FreeCAD and, as you said, the Part workbench.

    paullee
  • @topologic said:
    ... If I had time and resources, I can re-build Topologic completely using FreeCAD and, as you said, the Part workbench.

    Time and resources are always the keys. It is a shame what is achievable in Blender, e.g. Sverchok-Topologic, is not present in FreeCAD, at the moment :D

    topologic
  • Stuck at this line at the moment.

    _ = cellComplex.Faces(None, faces)

    Can find the same line below, so it should be working, but why not in my FreeCAD ...?
    https://github.com/wassimj/TopologicSverchok/blob/main/nodes/Topologic/TopologyRemoveCoplanarFaces.py

    Trying to workaround by importing all individual faces from FC, instead of returning from the topology...

    tc5 = get_external_faces(tc3)
    Traceback (most recent call last):
    File "", line 1, in
    File "", line 4, in get_external_faces
    TypeError: Faces(): incompatible function arguments. The following argument types are supported:
    1. (self: topologic.CellComplex, rFaces: list) -> None
    Invoked with: <topologic.CellComplex object at 0x7f7518263030>, None, []

  • I believe you are still using an obsolete version of Topologic.
    If the following works then you are definitely using an obsolete version:
    faces = []
    _ = tc3.Faces(faces)

  • Hmm, not working either. Difference in versions of Python, OCC maybe.

    cells=[]
    tcc
    ... topologic.CellComplex object at 0x7f74f80ecd30
    tcc.Faces
    ... bound method PyCapsule.Faces of <topologic.CellComplex object at 0x7f74f80ecd30>

    tcc1sf1
    ... topologic.Face object at 0x7f74f80e8eb0

    _=tcc1sf1.Cells(tcc, cells)
    Traceback (most recent call last):
    File "", line 1, in
    TypeError: Cells(): incompatible function arguments. The following argument types are supported:
    1. (self: topologic.Face, rCells: list) -> None

    Invoked with: <topologic.Face object at 0x7f74f80e8eb0>, <topologic.CellComplex object at 0x7f74f80ecd30>, []

  • Now I am 100% convinced that you are using the obsolete version of Topologic. Has nothing to do with OCC or python. Just your Topologic version is several months old.

    paullee
  • Random test other some other methods, seems working

    tcc1s
    ... topologic.Cell object at 0x7f7518266a70
    tcc1s.Cells
    ... bound method PyCapsule.Cells of <topologic.Cell object at 0x7f7518266a70
    topologic.CellUtility.Volume(tcc1s)
    ... 999.9999999999998

  • Oh, should be this ?

    topologic.CellComplex.Faces(tcc, faces)
    faces
    [<topologic.Face object at 0x7f74f80eca30>, <topologic.Face object at 0x7f751825f670>, <topologic.Face object at 0x7f753e1496b0>, <topologic.Face object at 0x7f753e149f30>, <topologic.Face object at 0x7f753e149e30>, <topologic.Face object at 0x7f753e149470>, <topologic.Face object at 0x7f753e149fb0>, <topologic.Face object at 0x7f753e14a030>, <topologic.Face object at 0x7f753e14a070>, <topologic.Face object at 0x7f753e149bb0>, <topologic.Face object at 0x7f753e14a0b0>]

  • Now, similar error with this line.. trying CellUtility instead ... :)

       _ = face.Cells(cellComplex, cells)
    
Sign In or Register to comment.