mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Support datetime instances in edit_pset
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import datetime
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.pset
|
import ifcopenshell.util.pset
|
||||||
@@ -446,6 +447,11 @@ class Usecase:
|
|||||||
return "IfcBoolean"
|
return "IfcBoolean"
|
||||||
elif isinstance(new_value, int):
|
elif isinstance(new_value, int):
|
||||||
return "IfcInteger"
|
return "IfcInteger"
|
||||||
|
# @nb datetime is also a date, so needs to be checked first
|
||||||
|
elif isinstance(new_value, datetime.datetime):
|
||||||
|
return "IfcDateTime"
|
||||||
|
elif isinstance(new_value, datetime.date):
|
||||||
|
return "IfcDate"
|
||||||
|
|
||||||
def cast_value_to_primary_measure_type(self, value, primary_measure_type):
|
def cast_value_to_primary_measure_type(self, value, primary_measure_type):
|
||||||
type_str = self.file.create_entity(primary_measure_type).attribute_type(0)
|
type_str = self.file.create_entity(primary_measure_type).attribute_type(0)
|
||||||
@@ -464,6 +470,8 @@ class Usecase:
|
|||||||
return [float(i) for i in value]
|
return [float(i) for i in value]
|
||||||
elif type_str == "AGGREGATE OF INT":
|
elif type_str == "AGGREGATE OF INT":
|
||||||
return [int(i) for i in value]
|
return [int(i) for i in value]
|
||||||
|
elif isinstance(value, (datetime.date, datetime.datetime)):
|
||||||
|
return value.isoformat()
|
||||||
return type_fn(value)
|
return type_fn(value)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user