topologicpy 0.7.36__py3-none-any.whl → 0.7.37__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/Topology.py +128 -30
- topologicpy/version.py +1 -1
- {topologicpy-0.7.36.dist-info → topologicpy-0.7.37.dist-info}/METADATA +1 -1
- {topologicpy-0.7.36.dist-info → topologicpy-0.7.37.dist-info}/RECORD +7 -7
- {topologicpy-0.7.36.dist-info → topologicpy-0.7.37.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.36.dist-info → topologicpy-0.7.37.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.36.dist-info → topologicpy-0.7.37.dist-info}/top_level.txt +0 -0
topologicpy/Topology.py
CHANGED
@@ -1893,7 +1893,7 @@ class Topology():
|
|
1893
1893
|
return Topology.ByBREPFile(file)
|
1894
1894
|
|
1895
1895
|
@staticmethod
|
1896
|
-
def ByDXFFile(file):
|
1896
|
+
def ByDXFFile(file, sides: int = 16):
|
1897
1897
|
"""
|
1898
1898
|
Imports a list of topologies from a DXF file.
|
1899
1899
|
This is an experimental method with limited capabilities.
|
@@ -1902,6 +1902,8 @@ class Topology():
|
|
1902
1902
|
----------
|
1903
1903
|
file : a DXF file object
|
1904
1904
|
The DXF file object.
|
1905
|
+
sides : int , optional
|
1906
|
+
The desired number of sides of splines. The default is 16.
|
1905
1907
|
|
1906
1908
|
Returns
|
1907
1909
|
-------
|
@@ -1916,6 +1918,8 @@ class Topology():
|
|
1916
1918
|
from topologicpy.Cell import Cell
|
1917
1919
|
from topologicpy.CellComplex import CellComplex
|
1918
1920
|
from topologicpy.Topology import Topology
|
1921
|
+
from topologicpy.Dictionary import Dictionary
|
1922
|
+
|
1919
1923
|
|
1920
1924
|
try:
|
1921
1925
|
import ezdxf
|
@@ -1936,34 +1940,123 @@ class Topology():
|
|
1936
1940
|
print("Topology.ByDXFFile - Error: the input file parameter is not a valid file. Returning None.")
|
1937
1941
|
return None
|
1938
1942
|
|
1939
|
-
|
1940
|
-
entity_type = entity.dxftype()
|
1941
|
-
converted_entity = None
|
1943
|
+
import ezdxf
|
1942
1944
|
|
1943
|
-
if entity_type == 'POINT':
|
1944
|
-
x, y, z = entity.dxf.location.x, entity.dxf.location.y, entity.dxf.location.z
|
1945
|
-
converted_entity = Vertex.ByCoordinates(x, y, z)
|
1946
1945
|
|
1947
|
-
elif entity_type == 'LINE':
|
1948
|
-
start = Vertex.ByCoordinates(entity.dxf.start.x, entity.dxf.start.y, entity.dxf.start.z)
|
1949
|
-
end = Vertex.ByCoordinates(entity.dxf.end.x, entity.dxf.end.y, entity.dxf.end.z)
|
1950
|
-
converted_entity = Edge.ByVertices(start, end)
|
1951
1946
|
|
1947
|
+
def get_layer_color(layers, layer_name):
|
1948
|
+
# iteration
|
1949
|
+
for layer in layers:
|
1950
|
+
if layer_name == layer.dxf.name:
|
1951
|
+
r,g,b = layer.rgb
|
1952
|
+
return [r,g,b]
|
1953
|
+
return
|
1954
|
+
|
1955
|
+
def convert_entity(entity, file, sides=36):
|
1956
|
+
entity_type = entity.dxftype()
|
1957
|
+
python_dict = entity.dxf.all_existing_dxf_attribs()
|
1958
|
+
keys = python_dict.keys()
|
1959
|
+
for key in keys:
|
1960
|
+
if python_dict[key].__class__ == ezdxf.acc.vector.Vec3:
|
1961
|
+
python_dict[key] = list(python_dict[key])
|
1962
|
+
try:
|
1963
|
+
r,g,b = entity.rgb
|
1964
|
+
except:
|
1965
|
+
rgb_list = get_layer_color(file.layers, entity.dxf.layer)
|
1966
|
+
if rgb_list == None:
|
1967
|
+
rgb_list = [0,0,0]
|
1968
|
+
python_dict['color'] = rgb_list
|
1969
|
+
python_dict['type'] = entity_type
|
1970
|
+
d = Dictionary.ByPythonDictionary(python_dict)
|
1971
|
+
|
1972
|
+
if entity_type == 'POINT':
|
1973
|
+
point = entity.dxf.location.xyz
|
1974
|
+
e = Vertex.ByCoordinates(point[0], point[1], point[2])
|
1975
|
+
e = Topology.SetDictionary(e, d)
|
1976
|
+
|
1977
|
+
elif entity_type == 'LINE':
|
1978
|
+
sp = entity.dxf.start.xyz
|
1979
|
+
ep = entity.dxf.end.xyz
|
1980
|
+
sv = Vertex.ByCoordinates(sp[0], sp[1], sp[2])
|
1981
|
+
ev = Vertex.ByCoordinates(ep[0], ep[1], ep[2])
|
1982
|
+
e = Edge.ByVertices(sv,ev)
|
1983
|
+
e = Topology.SetDictionary(e, d)
|
1984
|
+
|
1985
|
+
elif entity_type == 'POLYLINE':
|
1986
|
+
if entity.dxf.flags == 1:
|
1987
|
+
closed = True
|
1988
|
+
else:
|
1989
|
+
closed = False
|
1990
|
+
vertices = []
|
1991
|
+
for vertex in entity.vertices:
|
1992
|
+
point = vertex.dxf.location.xyz
|
1993
|
+
vertices.append(Vertex.ByCoordinates(point[0], point[1], point[2]))
|
1994
|
+
if entity.dxf.hasattr("closed"):
|
1995
|
+
closed = entity.closed
|
1996
|
+
e = Wire.ByVertices(vertices, close=closed)
|
1997
|
+
e = Topology.SetDictionary(e, d)
|
1998
|
+
|
1999
|
+
elif entity_type == 'LWPOLYLINE':
|
2000
|
+
vertices = []
|
2001
|
+
for point in entity.get_points():
|
2002
|
+
vertices.append(Vertex.ByCoordinates(point[0], point[1], 0))
|
2003
|
+
if entity.dxf.hasattr("closed"):
|
2004
|
+
close = entity.closed
|
2005
|
+
else:
|
2006
|
+
close = False
|
2007
|
+
e = Wire.ByVertices(vertices, close=close)
|
2008
|
+
e = Topology.SetDictionary(e, d)
|
2009
|
+
|
1952
2010
|
elif entity_type == 'CIRCLE':
|
1953
|
-
|
2011
|
+
center = entity.dxf.center.xyz
|
1954
2012
|
radius = entity.dxf.radius
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
2013
|
+
num_points = 36 # Approximate the circle with 36 points
|
2014
|
+
vertices = []
|
2015
|
+
for i in range(sides):
|
2016
|
+
angle = 2 * np.pi * i / num_points
|
2017
|
+
x = center[0] + radius * np.cos(angle)
|
2018
|
+
y = center[1] + radius * np.sin(angle)
|
2019
|
+
z = center[2]
|
2020
|
+
vertices.append(Vertex.ByCoordinates(x,y,z))
|
2021
|
+
e = Wire.ByVertices(vertices, close=True)
|
2022
|
+
e = Topology.SetDictionary(e, d)
|
2023
|
+
|
1962
2024
|
elif entity_type == 'ARC':
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
2025
|
+
center = entity.dxf.center.xyz
|
2026
|
+
radius = entity.dxf.radius
|
2027
|
+
start_angle = np.deg2rad(entity.dxf.start_angle)
|
2028
|
+
end_angle = np.deg2rad(entity.dxf.end_angle)
|
2029
|
+
vertices = []
|
2030
|
+
for i in range(sides+1):
|
2031
|
+
angle = start_angle + (end_angle - start_angle) * i / (num_points - 1)
|
2032
|
+
x = center[0] + radius * np.cos(angle)
|
2033
|
+
y = center[1] + radius * np.sin(angle)
|
2034
|
+
z = center[2]
|
2035
|
+
vertices.append(Vertex.ByCoordinates(x,y,z))
|
2036
|
+
e = Wire.ByVertices(vertices, close=False)
|
2037
|
+
e = Topology.SetDictionary(e, d)
|
2038
|
+
|
2039
|
+
elif entity_type == 'SPLINE':
|
2040
|
+
# draw the curve tangents as red lines:
|
2041
|
+
ct = entity.construction_tool()
|
2042
|
+
vertices = []
|
2043
|
+
for t in np.linspace(0, ct.max_t, 64):
|
2044
|
+
point, derivative = ct.derivative(t, 1)
|
2045
|
+
vertices.append(Vertex.ByCoordinates(list(point)))
|
2046
|
+
converted_entity = Wire.ByVertices(vertices, close=entity.closed)
|
2047
|
+
vertices = []
|
2048
|
+
for i in range(sides+1):
|
2049
|
+
if i == 0:
|
2050
|
+
u = 0
|
2051
|
+
elif i == sides:
|
2052
|
+
u = 1
|
2053
|
+
else:
|
2054
|
+
u = float(i)/float(sides)
|
2055
|
+
vertices.append(Wire.VertexByParameter(converted_entity, u))
|
1966
2056
|
|
2057
|
+
e = Wire.ByVertices(vertices, close=entity.closed)
|
2058
|
+
e = Topology.SetDictionary(e, d)
|
2059
|
+
|
1967
2060
|
elif entity_type == 'MESH':
|
1968
2061
|
vertices = [list(v) for v in entity.vertices]
|
1969
2062
|
faces = [list(face) for face in entity.faces]
|
@@ -1976,16 +2069,17 @@ class Topology():
|
|
1976
2069
|
temp = Shell.ByFaces(Topology.Faces(converted_entity))
|
1977
2070
|
if not Topology.IsInstance(temp, "Shell"):
|
1978
2071
|
temp = converted_entity
|
1979
|
-
|
1980
|
-
|
2072
|
+
e = temp
|
2073
|
+
e = Topology.SetDictionary(e, d)
|
2074
|
+
return e
|
1981
2075
|
|
1982
|
-
def convert_insert(entity, file):
|
2076
|
+
def convert_insert(entity, file, sides=16):
|
1983
2077
|
block_name = entity.dxf.name
|
1984
2078
|
block = file.blocks.get(block_name)
|
1985
2079
|
converted_entities = []
|
1986
2080
|
|
1987
2081
|
for block_entity in block:
|
1988
|
-
converted_entity = convert_entity(block_entity)
|
2082
|
+
converted_entity = convert_entity(block_entity, sides=sides)
|
1989
2083
|
if converted_entity is not None:
|
1990
2084
|
converted_entities.append(converted_entity)
|
1991
2085
|
|
@@ -2006,9 +2100,9 @@ class Topology():
|
|
2006
2100
|
continue # Ignore TEXT and MTEXT
|
2007
2101
|
|
2008
2102
|
if entity_type == 'INSERT':
|
2009
|
-
converted_entities.extend(convert_insert(entity, file))
|
2103
|
+
converted_entities.extend(convert_insert(entity, file, sides=sides))
|
2010
2104
|
else:
|
2011
|
-
converted_entity = convert_entity(entity)
|
2105
|
+
converted_entity = convert_entity(entity, file, sides=sides)
|
2012
2106
|
if converted_entity is not None:
|
2013
2107
|
converted_entities.append(converted_entity)
|
2014
2108
|
|
@@ -2017,7 +2111,7 @@ class Topology():
|
|
2017
2111
|
return converted_entities
|
2018
2112
|
|
2019
2113
|
@staticmethod
|
2020
|
-
def ByDXFPath(path):
|
2114
|
+
def ByDXFPath(path, sides: int = 16):
|
2021
2115
|
"""
|
2022
2116
|
Imports a list of topologies from a DXF file path.
|
2023
2117
|
This is an experimental method with limited capabilities.
|
@@ -2026,6 +2120,8 @@ class Topology():
|
|
2026
2120
|
----------
|
2027
2121
|
path : str
|
2028
2122
|
The path to the DXF file.
|
2123
|
+
sides : int , optional
|
2124
|
+
The desired number of sides of splines. The default is 16.
|
2029
2125
|
|
2030
2126
|
Returns
|
2031
2127
|
-------
|
@@ -2057,7 +2153,7 @@ class Topology():
|
|
2057
2153
|
if not file:
|
2058
2154
|
print("Topology.ByDXFPath - Error: the input file parameter is not a valid file. Returning None.")
|
2059
2155
|
return None
|
2060
|
-
return Topology.ByDXFFile(file)
|
2156
|
+
return Topology.ByDXFFile(file, sides=sides)
|
2061
2157
|
|
2062
2158
|
@staticmethod
|
2063
2159
|
def ByIFCFile(file, transferDictionaries=False, includeTypes=[], excludeTypes=[]):
|
@@ -6989,6 +7085,8 @@ class Topology():
|
|
6989
7085
|
if isinstance(colorKey, str):
|
6990
7086
|
f_color = Dictionary.ValueAtKey(d, colorKey)
|
6991
7087
|
if f_color:
|
7088
|
+
vertexColor = Color.PlotlyColor(f_color, alpha=1.0, useAlpha=False)
|
7089
|
+
edgeColor = Color.PlotlyColor(f_color, alpha=1.0, useAlpha=False)
|
6992
7090
|
faceColor = Color.PlotlyColor(f_color, alpha=1.0, useAlpha=False)
|
6993
7091
|
faceOpacity = Dictionary.ValueAtKey(d, opacityKey) or faceOpacity
|
6994
7092
|
data += Plotly.DataByTopology(topology=topology,
|
topologicpy/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.7.
|
1
|
+
__version__ = '0.7.37'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: topologicpy
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.37
|
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: MIT License
|
@@ -21,14 +21,14 @@ topologicpy/Polyskel.py,sha256=4R5_DEdfrmi-4gR6axHNoHTCSAE2TCekOyN8jvb7bHQ,19722
|
|
21
21
|
topologicpy/Shell.py,sha256=bJ8zu5gj-TSOADR-p3YQ9yLPHFTffnv-29uD5b6Zvuc,79912
|
22
22
|
topologicpy/Speckle.py,sha256=rUS6PCaxIjEF5_fUruxvMH47FMKg-ohcoU0qAUb-yNM,14267
|
23
23
|
topologicpy/Sun.py,sha256=_gZfVyH0SDLQmmt775UeeAJ_BtwXO1STQnUMV1qkU0s,37161
|
24
|
-
topologicpy/Topology.py,sha256=
|
24
|
+
topologicpy/Topology.py,sha256=Sfw0C5Sd1m3ndLyM_zrCLzegfMd6ytnaK82J_ToK5lQ,366264
|
25
25
|
topologicpy/Vector.py,sha256=WQQUbwrg7VKImtxuBUi2i-FRiPT77WlrzLP05gdXKM8,33079
|
26
26
|
topologicpy/Vertex.py,sha256=EQdVYHmW85_pZdHZB3N8pEi0GiadCCkF3z_oqohA7B0,71161
|
27
27
|
topologicpy/Wire.py,sha256=Ls2ItdNQ_qbC1RUc8bAtGbM5B5A-uShjHdiOFVVwx-8,153711
|
28
28
|
topologicpy/__init__.py,sha256=D7ky87CAQMiS2KE6YLvcTLkTgA2PY7rASe6Z23pjp9k,872
|
29
|
-
topologicpy/version.py,sha256=
|
30
|
-
topologicpy-0.7.
|
31
|
-
topologicpy-0.7.
|
32
|
-
topologicpy-0.7.
|
33
|
-
topologicpy-0.7.
|
34
|
-
topologicpy-0.7.
|
29
|
+
topologicpy/version.py,sha256=ELkwc8QfDXR6OC99fHNSgYmlBjnbBmo_0j-69MXQmNA,23
|
30
|
+
topologicpy-0.7.37.dist-info/LICENSE,sha256=BRNw73R2WdDBICtwhI3wm3cxsaVqLTAGuRwrTltcfxs,1068
|
31
|
+
topologicpy-0.7.37.dist-info/METADATA,sha256=ZOohbLJX-LIHwG-aIFZUdZbgYqxppOt5uroiZvyoobU,10916
|
32
|
+
topologicpy-0.7.37.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
33
|
+
topologicpy-0.7.37.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
|
34
|
+
topologicpy-0.7.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|