Skip to content

Commit

Permalink
add support rvt bbox elements
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 10, 2024
1 parent 2fb0de1 commit 148686c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion APSToolkitPython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="aps-toolkit",
version="1.0.1",
version="1.0.2",
author="chuong mep",
author_email="[email protected]",
description="A Toolkit Autodesk Platform Services for Python",
Expand Down
19 changes: 19 additions & 0 deletions APSToolkitPython/src/aps_toolkit/ProDbReaderRevit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .PropReader import PropReader
from .ManifestItem import ManifestItem
import warnings
from .SVFReader import SVFReader


class PropDbReaderRevit(PropReader):
Expand All @@ -42,6 +43,7 @@ class PropDbReaderRevit(PropReader):
Initializes the PropDbReaderRevit class with model URN, access token, region,
and optional manifest items.
"""

def __int__(self, urn, token, region="US", manifest_item: [ManifestItem] = None):
super().__init__(urn, token, region, manifest_item)

Expand Down Expand Up @@ -183,6 +185,23 @@ def get_all_data(self, is_get_sub_family: bool = False, display_unit: bool = Fal
dataframe["Family Name"] = dataframe["Name"].str.extract(r'(.*)\s\[')
return dataframe

def get_all_bounding_boxs(self) -> pd.DataFrame:
"""
Get bounding boxs all elements in model
:return: :class:`pandas.DataFrame` : Dataframe contains bounding boxs with dbId and bbox
:remark: bbox is a list of 6 value [minX, minY, minZ, maxX, maxY, maxZ]
"""
svf_reader = SVFReader(self.urn, self.token)
frags = svf_reader.read_fragments()
df_bbox = pd.DataFrame(columns=["dbId", "bbox"])
for k, v in frags.items():
for f in v:
df_bbox = pd.concat([df_bbox, pd.DataFrame([[f.dbID, f.bbox]], columns=["dbId", "bbox"])])
df_bbox.reset_index(drop=True, inplace=True)
df_bbox.sort_values(by="dbId", inplace=True)
df_bbox.drop_duplicates(subset="dbId", inplace=True)
return df_bbox

def get_all_families(self) -> dict:
"""
Get all families in model
Expand Down
7 changes: 5 additions & 2 deletions APSToolkitPython/src/test/test_prop_reader_revit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from unittest import TestCase
import os
from .context import PropDbReaderRevit
from .context import Auth

Expand Down Expand Up @@ -51,6 +50,10 @@ def test_get_all_data(self):
data = self.prop_reader.get_all_data(display_unit=True)
self.assertIsNotNone(data)

def test_get_bounding_boxs(self):
bounding_boxes = self.prop_reader.get_all_bounding_boxs()
self.assertNotEquals(len(bounding_boxes), 0)

def test_get_data_by_category(self):
df = self.prop_reader.get_data_by_category("Furniture", True, True, True)
# check if dataframe have rows = 1
Expand Down Expand Up @@ -85,7 +88,7 @@ def test_get_data_by_family_types(self):
def test_get_data_by_categories_and_params(self):
df = self.prop_reader.get_data_by_categories_and_params(["Doors", "Windows"],
["Name", "Category", "ElementId", "Width", "Height",
"IfcGUID","Family Name"], True, display_unit=False)
"IfcGUID", "Family Name"], True, display_unit=False)
self.assertNotEquals(df.empty, True)

def test_get_data_by_parameters(self):
Expand Down

0 comments on commit 148686c

Please sign in to comment.