mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
Add support for editing ref latitude/longitude
This commit is contained in:
@@ -50,7 +50,20 @@ class EnableEditingAttributes(bpy.types.Operator):
|
|||||||
oprops = obj.BIMObjectProperties
|
oprops = obj.BIMObjectProperties
|
||||||
props = obj.BIMAttributeProperties
|
props = obj.BIMAttributeProperties
|
||||||
props.attributes.clear()
|
props.attributes.clear()
|
||||||
blenderbim.bim.helper.import_attributes2(tool.Ifc.get().by_id(oprops.ifc_definition_id), props.attributes)
|
|
||||||
|
def callback(name, prop, data):
|
||||||
|
if name in ("RefLatitude", "RefLongitude"):
|
||||||
|
new = props.attributes.add()
|
||||||
|
new.name = name
|
||||||
|
new.is_null = data[name] is None
|
||||||
|
new.is_optional = True
|
||||||
|
new.data_type = "string"
|
||||||
|
new.ifc_class = data["type"]
|
||||||
|
new.string_value = "" if new.is_null else json.dumps(data[name])
|
||||||
|
|
||||||
|
blenderbim.bim.helper.import_attributes2(
|
||||||
|
tool.Ifc.get().by_id(oprops.ifc_definition_id), props.attributes, callback=callback
|
||||||
|
)
|
||||||
props.is_editing_attributes = True
|
props.is_editing_attributes = True
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -87,7 +100,19 @@ class EditAttributes(bpy.types.Operator, Operator):
|
|||||||
obj = bpy.data.materials.get(self.obj)
|
obj = bpy.data.materials.get(self.obj)
|
||||||
props = obj.BIMAttributeProperties
|
props = obj.BIMAttributeProperties
|
||||||
product = tool.Ifc.get_entity(obj)
|
product = tool.Ifc.get_entity(obj)
|
||||||
attributes = blenderbim.bim.helper.export_attributes(props.attributes)
|
|
||||||
|
def callback(attributes, prop):
|
||||||
|
if prop.name in ("RefLatitude", "RefLongitude"):
|
||||||
|
if prop.is_null:
|
||||||
|
attributes[prop.name] = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
attributes[prop.name] = json.loads(prop.string_value)
|
||||||
|
except:
|
||||||
|
attributes[prop.name] = None
|
||||||
|
return True
|
||||||
|
|
||||||
|
attributes = blenderbim.bim.helper.export_attributes(props.attributes, callback=callback)
|
||||||
ifcopenshell.api.run("attribute.edit_attributes", self.file, product=product, attributes=attributes)
|
ifcopenshell.api.run("attribute.edit_attributes", self.file, product=product, attributes=attributes)
|
||||||
bpy.ops.bim.disable_editing_attributes(obj=obj.name, obj_type=self.obj_type)
|
bpy.ops.bim.disable_editing_attributes(obj=obj.name, obj_type=self.obj_type)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -1,6 +1,39 @@
|
|||||||
@attribute
|
@attribute
|
||||||
Feature: Attribute
|
Feature: Attribute
|
||||||
|
|
||||||
|
Scenario: Enable editing attributes
|
||||||
|
Given an empty IFC project
|
||||||
|
And the object "IfcSite/My Site" is selected
|
||||||
|
When I press "bim.enable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Disable editing attributes
|
||||||
|
Given an empty IFC project
|
||||||
|
And the object "IfcSite/My Site" is selected
|
||||||
|
And I press "bim.enable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
When I press "bim.disable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Edit attributes
|
||||||
|
Given an empty IFC project
|
||||||
|
And the object "IfcSite/My Site" is selected
|
||||||
|
And I press "bim.enable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
And I set "active_object.BIMAttributeProperties.attributes[1].string_value" to "Name"
|
||||||
|
When I press "bim.edit_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
Then the object "IfcSite/Name" is an "IfcSite"
|
||||||
|
And the object "IfcSite/My Site" does not exist
|
||||||
|
|
||||||
|
Scenario: Edit attributes - longitude / latitude
|
||||||
|
Given an empty IFC project
|
||||||
|
And the object "IfcSite/My Site" is selected
|
||||||
|
And I press "bim.enable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
Then "active_object.BIMAttributeProperties.attributes[6].name" is "RefLatitude"
|
||||||
|
When I set "active_object.BIMAttributeProperties.attributes[6].string_value" to "[1,2]"
|
||||||
|
And I press "bim.edit_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
And I press "bim.enable_editing_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
And I press "bim.edit_attributes(obj='IfcSite/My Site', obj_type='Object')"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
Scenario: Copy attribute to selected
|
Scenario: Copy attribute to selected
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
And I add a cube
|
And I add a cube
|
||||||
|
|||||||
Reference in New Issue
Block a user