mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 12:42:36 +00:00
add_application not to add deprecated IfcTelecomAddress in ifc4x3 #6806
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.api.owner
|
||||||
|
import ifcopenshell.api.pset
|
||||||
from typing import Optional, Any, Union
|
from typing import Optional, Any, Union
|
||||||
|
|
||||||
|
|
||||||
@@ -90,18 +92,32 @@ class Usecase:
|
|||||||
"Roles": [
|
"Roles": [
|
||||||
self.file.create_entity("IfcActorRole", **{"Role": "USERDEFINED", "UserDefinedRole": "CONTRIBUTOR"})
|
self.file.create_entity("IfcActorRole", **{"Role": "USERDEFINED", "UserDefinedRole": "CONTRIBUTOR"})
|
||||||
],
|
],
|
||||||
"Addresses": [
|
|
||||||
self.file.create_entity(
|
|
||||||
"IfcTelecomAddress",
|
|
||||||
**{
|
|
||||||
"Purpose": "USERDEFINED",
|
|
||||||
"UserDefinedPurpose": "WEBPAGE",
|
|
||||||
"WWWHomePageURL": "https://ifcopenshell.org",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
# 0 IfcOrganization.Identification / Id (IFC2X3).
|
# 0 IfcOrganization.Identification / Id (IFC2X3).
|
||||||
result[0] = "IfcOpenShell"
|
result[0] = "IfcOpenShell"
|
||||||
|
|
||||||
|
# 4 IfcOrganization.Addresses
|
||||||
|
if self.file.schema == "IFC4X3":
|
||||||
|
# IfcTelecomAddress is deprecated in IFC4X3.
|
||||||
|
actor = ifcopenshell.api.owner.add_actor(self.file, result)
|
||||||
|
pset = ifcopenshell.api.pset.add_pset(self.file, actor, "PEnum_AddressType")
|
||||||
|
ifcopenshell.api.pset.edit_pset(
|
||||||
|
self.file,
|
||||||
|
pset,
|
||||||
|
properties={
|
||||||
|
"Purpose": "OTHER",
|
||||||
|
"UserDefinedPurpose": "WEBPAGE",
|
||||||
|
"WWWHomePageURL": "https://ifcopenshell.org",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
result[4] = [
|
||||||
|
self.file.create_entity(
|
||||||
|
"IfcTelecomAddress",
|
||||||
|
Purpose="USERDEFINED",
|
||||||
|
UserDefinedPurpose="WEBPAGE",
|
||||||
|
WWWHomePageURL="https://ifcopenshell.org",
|
||||||
|
),
|
||||||
|
]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import test.bootstrap
|
import test.bootstrap
|
||||||
import ifcopenshell.api.owner
|
import ifcopenshell.api.owner
|
||||||
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
class TestAddApplication(test.bootstrap.IFC4):
|
class TestAddApplication(test.bootstrap.IFC4):
|
||||||
@@ -45,3 +46,32 @@ class TestAddApplication(test.bootstrap.IFC4):
|
|||||||
|
|
||||||
class TestAddApplicationIFC2X3(test.bootstrap.IFC2X3, TestAddApplication):
|
class TestAddApplicationIFC2X3(test.bootstrap.IFC2X3, TestAddApplication):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestAddApplicationIFC4X3(test.bootstrap.IFC4X3, TestAddApplication):
|
||||||
|
def test_adding_the_ifcopenshell_application(self):
|
||||||
|
application = ifcopenshell.api.owner.add_application(self.file)
|
||||||
|
developer = application.ApplicationDeveloper
|
||||||
|
assert application.Version == ifcopenshell.version
|
||||||
|
assert application.ApplicationFullName == "IfcOpenShell"
|
||||||
|
assert application.ApplicationIdentifier == "IfcOpenShell"
|
||||||
|
assert developer.is_a("IfcOrganization")
|
||||||
|
|
||||||
|
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
|
||||||
|
assert developer[0] == "IfcOpenShell"
|
||||||
|
assert developer.Name == "IfcOpenShell"
|
||||||
|
assert (
|
||||||
|
developer.Description
|
||||||
|
== "IfcOpenShell is an open source software library that helps users and software developers to work with IFC data."
|
||||||
|
)
|
||||||
|
assert developer.Roles[0].Role == "USERDEFINED"
|
||||||
|
assert developer.Roles[0].UserDefinedRole == "CONTRIBUTOR"
|
||||||
|
assert developer.Addresses == None
|
||||||
|
|
||||||
|
assert (actors := self.file.by_type("IfcActor"))
|
||||||
|
actor = actors[0]
|
||||||
|
assert actor.TheActor == developer
|
||||||
|
assert (pset_data := ifcopenshell.util.element.get_pset(actor, "PEnum_AddressType"))
|
||||||
|
assert pset_data["Purpose"] == "OTHER"
|
||||||
|
assert pset_data["UserDefinedPurpose"] == "WEBPAGE"
|
||||||
|
assert pset_data["WWWHomePageURL"] == "https://ifcopenshell.org"
|
||||||
|
|||||||
Reference in New Issue
Block a user