topologicpy 0.7.3__py3-none-any.whl → 0.7.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
topologicpy/Face.py CHANGED
@@ -1909,7 +1909,7 @@ class Face():
1909
1909
  return Face.ByWire(wire)
1910
1910
 
1911
1911
  @staticmethod
1912
- def Star(origin= None, radiusA: float = 1.0, radiusB: float = 0.4, rays: int = 5, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
1912
+ def Star(origin= None, radiusA: float = 0.5, radiusB: float = 0.2, rays: int = 8, direction: list = [0, 0, 1], placement: str = "center", tolerance: float = 0.0001):
1913
1913
  """
1914
1914
  Creates a star.
1915
1915
 
topologicpy/Topology.py CHANGED
@@ -871,6 +871,7 @@ class Topology():
871
871
  See Topology.Boolean().
872
872
 
873
873
  """
874
+ from topologicpy.Cluster import Cluster
874
875
 
875
876
  if topologyA == None:
876
877
  return None
@@ -884,27 +885,24 @@ class Topology():
884
885
  topologyA = topologyB
885
886
  topologyB = temp
886
887
 
887
- if Topology.IsInstance(topologyB, "CellComplex") or Topology.IsInstance(topologyB, "Cluster"):
888
- merge = Topology.Merge(topologyA, topologyB)
889
- symdif = Topology.SymDif(topologyA, topologyB)
890
- return Topology.Difference(merge, symdif)
888
+ results = []
889
+ if Topology.IsInstance(topologyA, "CellComplex"):
890
+ cellsA = Topology.Cells(topologyA)
891
891
  else:
892
- # Vertex:
893
- if Topology.IsInstance(topologyA, "Vertex"):
894
- # Vertex:
895
- if Topology.IsInstance(topologyB, "Vertex"):
896
- if Vertex.Distance(topologyA, topologyB) < tolerance:
897
- return topologyA
898
- else:
899
- return None
900
- # Edge/Wire/Face/Shell/Cell:
901
- else:
902
- if Vertex.IsInternal(topologyA, topologyB):
903
- return topologyA
904
- else:
905
- return None
892
+ cellsA = [topologyA]
893
+ for cellA in cellsA:
894
+ if Topology.IsInstance(topologyB, "CellComplex"):
895
+ cellsB = Topology.Cells(topologyB)
906
896
  else:
907
- return topologyA.Intersect(topologyB)
897
+ cellsB = [topologyB]
898
+ for cellB in cellsB:
899
+ cellC = cellA.Intersect(cellB)
900
+ results.append(cellC)
901
+ results = [x for x in results if results is not None]
902
+ if len(results) == 1:
903
+ return results[0]
904
+ else:
905
+ return Topology.SelfMerge(Topology.SelfMerge(Cluster.ByTopologies(results)))
908
906
 
909
907
  @staticmethod
910
908
  def SymmetricDifference(topologyA, topologyB, tranDict=False, tolerance=0.0001):
@@ -1503,7 +1501,7 @@ class Topology():
1503
1501
  @staticmethod
1504
1502
  def ByBREPPath(path):
1505
1503
  """
1506
- IMports a topology from a BREP file path.
1504
+ Imports a topology from a BREP file path.
1507
1505
 
1508
1506
  Parameters
1509
1507
  ----------
@@ -1525,7 +1523,172 @@ class Topology():
1525
1523
  print("Topology.ByBREPPath - Error: the BREP file is not a valid file. Returning None.")
1526
1524
  return None
1527
1525
  return Topology.ByBREPFile(file)
1528
-
1526
+
1527
+ @staticmethod
1528
+ def ByDXFFile(file):
1529
+ """
1530
+ Imports a list of topologies from a DXF file.
1531
+ This is an experimental method with limited capabilities.
1532
+
1533
+ Parameters
1534
+ ----------
1535
+ file : a DXF file object
1536
+ The DXF file object.
1537
+
1538
+ Returns
1539
+ -------
1540
+ list
1541
+ The list of imported topologies.
1542
+
1543
+ """
1544
+ from topologicpy.Vertex import Vertex
1545
+ from topologicpy.Edge import Edge
1546
+ from topologicpy.Wire import Wire
1547
+ from topologicpy.Shell import Shell
1548
+ from topologicpy.Cell import Cell
1549
+ from topologicpy.CellComplex import CellComplex
1550
+ from topologicpy.Topology import Topology
1551
+
1552
+ try:
1553
+ import ezdxf
1554
+ except:
1555
+ print("Topology.ByDXFFile - Information: Installing required ezdxf library.")
1556
+ try:
1557
+ os.system("pip install ezdxf")
1558
+ except:
1559
+ os.system("pip install ezdxf --user")
1560
+ try:
1561
+ import ezdxf
1562
+ print("Topology.ByDXFFile - Information: ezdxf library installed successfully.")
1563
+ except:
1564
+ warnings.warn("Topology.ByDXFFile - Error: Could not import ezdxf library. Please install it manually. Returning None.")
1565
+ return None
1566
+
1567
+ if not file:
1568
+ print("Topology.ByDXFFile - Error: the input file parameter is not a valid file. Returning None.")
1569
+ return None
1570
+
1571
+ def convert_entity(entity):
1572
+ entity_type = entity.dxftype()
1573
+ converted_entity = None
1574
+
1575
+ if entity_type == 'POINT':
1576
+ x, y, z = entity.dxf.location.x, entity.dxf.location.y, entity.dxf.location.z
1577
+ converted_entity = Vertex.ByCoordinates(x, y, z)
1578
+
1579
+ elif entity_type == 'LINE':
1580
+ start = Vertex.ByCoordinates(entity.dxf.start.x, entity.dxf.start.y, entity.dxf.start.z)
1581
+ end = Vertex.ByCoordinates(entity.dxf.end.x, entity.dxf.end.y, entity.dxf.end.z)
1582
+ converted_entity = Edge.ByVertices(start, end)
1583
+
1584
+ elif entity_type == 'CIRCLE':
1585
+ origin = Vertex.ByCoordinates(entity.dxf.center.x, entity.dxf.center.y, entity.dxf.center.z)
1586
+ radius = entity.dxf.radius
1587
+ converted_entity = Wire.Circle(origin, radius)
1588
+
1589
+ elif entity_type in ['POLYLINE', 'LWPOLYLINE']:
1590
+ vertices = [Vertex.ByCoordinates(p[0], p[1], p[2]) for p in entity.points()]
1591
+ converted_entity = Wire.ByVertices(vertices)
1592
+
1593
+ elif entity_type == 'ARC':
1594
+ vertices = [Vertex.ByCoordinates(p.x, p.y, p.z) for p in entity.vertices()]
1595
+ converted_entity = Wire.ByVertices(vertices)
1596
+
1597
+ elif entity_type == 'MESH':
1598
+ vertices = [list(v) for v in entity.vertices]
1599
+ faces = [list(face) for face in entity.faces]
1600
+ converted_entity = Topology.SelfMerge(Topology.ByGeometry(vertices=vertices, faces=faces))
1601
+ # Try Cell
1602
+ temp = Cell.ByFaces(Topology.Faces(converted_entity), silent=True)
1603
+ if not Topology.IsInstance(temp, "Cell"):
1604
+ temp = CellComplex.ByFaces(Topology.Faces(converted_entity))
1605
+ if not Topology.IsInstance(temp, "CellComplex"):
1606
+ temp = Shell.ByFaces(Topology.Faces(converted_entity))
1607
+ if not Topology.IsInstance(temp, "Shell"):
1608
+ temp = converted_entity
1609
+ converted_entity = temp
1610
+ return converted_entity
1611
+
1612
+ def convert_insert(entity, file):
1613
+ block_name = entity.dxf.name
1614
+ block = file.blocks.get(block_name)
1615
+ converted_entities = []
1616
+
1617
+ for block_entity in block:
1618
+ converted_entity = convert_entity(block_entity)
1619
+ if converted_entity is not None:
1620
+ converted_entities.append(converted_entity)
1621
+
1622
+ x, y, z = [entity.dxf.insert.x, entity.dxf.insert.y, entity.dxf.insert.z]
1623
+ return [Topology.Translate(obj, x, y, z) for obj in converted_entities]
1624
+
1625
+ def convert_dxf_to_custom_types(file):
1626
+ # Read the DXF file
1627
+ msp = file.modelspace()
1628
+
1629
+ # Store the converted entities
1630
+ converted_entities = []
1631
+
1632
+ # Process each entity in the model space
1633
+ for entity in msp:
1634
+ entity_type = entity.dxftype()
1635
+ if entity_type in ['TEXT', 'MTEXT']:
1636
+ continue # Ignore TEXT and MTEXT
1637
+
1638
+ if entity_type == 'INSERT':
1639
+ converted_entities.extend(convert_insert(entity, file))
1640
+ else:
1641
+ converted_entity = convert_entity(entity)
1642
+ if converted_entity is not None:
1643
+ converted_entities.append(converted_entity)
1644
+
1645
+ return converted_entities
1646
+ converted_entities = convert_dxf_to_custom_types(file)
1647
+ return converted_entities
1648
+
1649
+ @staticmethod
1650
+ def ByDXFPath(path):
1651
+ """
1652
+ Imports a list of topologies from a DXF file path.
1653
+ This is an experimental method with limited capabilities.
1654
+
1655
+ Parameters
1656
+ ----------
1657
+ path : str
1658
+ The path to the DXF file.
1659
+
1660
+ Returns
1661
+ -------
1662
+ list
1663
+ The list of imported topologies.
1664
+
1665
+ """
1666
+ try:
1667
+ import ezdxf
1668
+ except:
1669
+ print("Topology.ExportToDXF - Information: Installing required ezdxf library.")
1670
+ try:
1671
+ os.system("pip install ezdxf")
1672
+ except:
1673
+ os.system("pip install ezdxf --user")
1674
+ try:
1675
+ import ezdxf
1676
+ print("Topology.ByDXFPath - Information: ezdxf library installed successfully.")
1677
+ except:
1678
+ warnings.warn("Topology.ByDXFPath - Error: Could not import ezdxf library. Please install it manually. Returning None.")
1679
+ return None
1680
+ if not path:
1681
+ print("Topology.ByDXFPath - Error: the input path parameter is not a valid path. Returning None.")
1682
+ return None
1683
+ try:
1684
+ file = ezdxf.readfile(path)
1685
+ except:
1686
+ file = None
1687
+ if not file:
1688
+ print("Topology.ByDXFPath - Error: the input file parameter is not a valid file. Returning None.")
1689
+ return None
1690
+ return Topology.ByDXFFile(file)
1691
+
1529
1692
  @staticmethod
1530
1693
  def ByIFCFile(file, transferDictionaries=False, includeTypes=[], excludeTypes=[]):
1531
1694
  """
@@ -1648,7 +1811,6 @@ class Topology():
1648
1811
  try:
1649
1812
  file = ifcopenshell.open(path)
1650
1813
  except:
1651
- print("Topology.ByIFCPath - Error: the input file parameter is not a valid file. Returning None.")
1652
1814
  file = None
1653
1815
  if not file:
1654
1816
  print("Topology.ByIFCPath - Error: the input file parameter is not a valid file. Returning None.")
topologicpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.7.3'
1
+ __version__ = '0.7.5'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: topologicpy
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -8,7 +8,7 @@ topologicpy/DGL.py,sha256=RpkLnAzjg6arY7cEMs2pDFYzRdkerVg1Wbm9hcE3QaM,138991
8
8
  topologicpy/Dictionary.py,sha256=pMbfE2RYGCNpVr2x58qiHRc-aBWnp1jLlyzwS9nz6-w,25891
9
9
  topologicpy/Edge.py,sha256=jbJHyPHlLF94RkUKL479B4dPC202K0Xd7bQsPcFwoHc,51296
10
10
  topologicpy/EnergyModel.py,sha256=UBLim01lZLikVQmJAHEeja-KvF4tgzTxsSxwNDaezz4,52500
11
- topologicpy/Face.py,sha256=BOU6hN-4uCaXW_lbvuOlntrz_Q0jEiL5tIHAFuqWw_U,97195
11
+ topologicpy/Face.py,sha256=clf0qf8c0SnzOUOHw11Z4e_Y4ovhRmSOGmPd5_50Fa8,97195
12
12
  topologicpy/Graph.py,sha256=GsWySXL-cTd7bl-QWpl3Aw9Hr0KyACzIa4iRenTB63s,368030
13
13
  topologicpy/Grid.py,sha256=XM0iQtQbMQoYHf7S0ppSe-dxy93Y9VpI_vUkElWqnYA,17050
14
14
  topologicpy/Helper.py,sha256=07V9IFu5ilMpvAdZVhIbdBOjBJSRTtJ0BfR1IoRaRXU,17743
@@ -20,14 +20,14 @@ topologicpy/Polyskel.py,sha256=MYHKFOQBlUNqoUhAdOcKRIHpSk0dWWVrZgXK34NkvFM,15936
20
20
  topologicpy/Shell.py,sha256=6hidTQ6MW5q_es-WbTeI_yt7Sd7BMxWU_qfoherVZhE,74343
21
21
  topologicpy/Speckle.py,sha256=rUS6PCaxIjEF5_fUruxvMH47FMKg-ohcoU0qAUb-yNM,14267
22
22
  topologicpy/Sun.py,sha256=3tYb8kssU882lE1gEWg2mxDvCCY_LAVElkyUT6wa-ZU,36935
23
- topologicpy/Topology.py,sha256=limcBROvZgD5xanXLi57WgOvR9e93-MkYZcFtFgctu0,298938
23
+ topologicpy/Topology.py,sha256=VShlTik3ggY4Ch4649p3SGZ8UyXIsQ7t3KQO7bjRN8A,305176
24
24
  topologicpy/Vector.py,sha256=FHbrCb9GVLOUV_kqcplh4D88CVxlID6qX_wEQOw4rD0,29565
25
25
  topologicpy/Vertex.py,sha256=YgbbCcqABvb97z2-yEytpp5T3yoZPlQplR_vMQkQ9OA,65180
26
26
  topologicpy/Wire.py,sha256=MUEboxo11kMgwnZySSkwiyzBG2wv0wPiinf2cW4UVv8,138424
27
27
  topologicpy/__init__.py,sha256=D7ky87CAQMiS2KE6YLvcTLkTgA2PY7rASe6Z23pjp9k,872
28
- topologicpy/version.py,sha256=i5zhgfscuWC8vabp6pP1S6z_O5355x2aIv0so00_cmo,22
29
- topologicpy-0.7.3.dist-info/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
30
- topologicpy-0.7.3.dist-info/METADATA,sha256=TdJMT-64j4LX5i_DSX8qg-5jNgUSETUla-Mi9AMjkic,46950
31
- topologicpy-0.7.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
32
- topologicpy-0.7.3.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
33
- topologicpy-0.7.3.dist-info/RECORD,,
28
+ topologicpy/version.py,sha256=YGgeu1tBDTiiHbKl1TkbKHeb7CjnrObEQKS9Miv1iBU,22
29
+ topologicpy-0.7.5.dist-info/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
30
+ topologicpy-0.7.5.dist-info/METADATA,sha256=pTjF0iR8gLPPQ8E7s7A0-fDMrm5vepTlMF88sjztM2M,46950
31
+ topologicpy-0.7.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
32
+ topologicpy-0.7.5.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
33
+ topologicpy-0.7.5.dist-info/RECORD,,