mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
You can now clear the active user for ownership history. See #1790.
This commit is contained in:
@@ -48,6 +48,7 @@ class RemoveCsvAttribute(bpy.types.Operator):
|
|||||||
context.scene.CsvProperties.csv_attributes.remove(self.index)
|
context.scene.CsvProperties.csv_attributes.remove(self.index)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveAllCsvAttributes(bpy.types.Operator):
|
class RemoveAllCsvAttributes(bpy.types.Operator):
|
||||||
bl_idname = "bim.remove_all_csv_attributes"
|
bl_idname = "bim.remove_all_csv_attributes"
|
||||||
bl_label = "Remove all CSV Attributes"
|
bl_label = "Remove all CSV Attributes"
|
||||||
@@ -57,6 +58,7 @@ class RemoveAllCsvAttributes(bpy.types.Operator):
|
|||||||
context.scene.CsvProperties.csv_attributes.clear()
|
context.scene.CsvProperties.csv_attributes.clear()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ImportCsvAttributes(bpy.types.Operator):
|
class ImportCsvAttributes(bpy.types.Operator):
|
||||||
bl_idname = "bim.import_csv_attributes"
|
bl_idname = "bim.import_csv_attributes"
|
||||||
bl_label = "Import CSV Attributes"
|
bl_label = "Import CSV Attributes"
|
||||||
@@ -72,7 +74,7 @@ class ImportCsvAttributes(bpy.types.Operator):
|
|||||||
for attribute in csv_json:
|
for attribute in csv_json:
|
||||||
csv_attributes.add()
|
csv_attributes.add()
|
||||||
csv_attributes[i].name = attribute
|
csv_attributes[i].name = attribute
|
||||||
i +=1
|
i += 1
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -80,6 +82,7 @@ class ImportCsvAttributes(bpy.types.Operator):
|
|||||||
context.window_manager.fileselect_add(self)
|
context.window_manager.fileselect_add(self)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
class ExportCsvAttributes(bpy.types.Operator):
|
class ExportCsvAttributes(bpy.types.Operator):
|
||||||
bl_idname = "bim.export_csv_attributes"
|
bl_idname = "bim.export_csv_attributes"
|
||||||
bl_label = "Export CSV Attributes"
|
bl_label = "Export CSV Attributes"
|
||||||
@@ -102,7 +105,8 @@ class ExportCsvAttributes(bpy.types.Operator):
|
|||||||
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
||||||
WindowManager = context.window_manager
|
WindowManager = context.window_manager
|
||||||
WindowManager.fileselect_add(self)
|
WindowManager.fileselect_add(self)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
class ExportIfcCsv(bpy.types.Operator):
|
class ExportIfcCsv(bpy.types.Operator):
|
||||||
bl_idname = "bim.export_ifccsv"
|
bl_idname = "bim.export_ifccsv"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class BIM_PT_ifccsv(Panel):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "csv_ifc_file")
|
row.prop(props, "csv_ifc_file")
|
||||||
row.operator("bim.select_csv_ifc_file", icon="FILE_FOLDER", text="")
|
row.operator("bim.select_csv_ifc_file", icon="FILE_FOLDER", text="")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "ifc_selector")
|
row.prop(props, "ifc_selector")
|
||||||
row.operator("bim.eyedrop_ifccsv", icon="EYEDROPPER", text="")
|
row.operator("bim.eyedrop_ifccsv", icon="EYEDROPPER", text="")
|
||||||
@@ -66,8 +66,8 @@ class BIM_PT_ifccsv(Panel):
|
|||||||
row.operator("bim.remove_all_csv_attributes", icon="CANCEL", text="")
|
row.operator("bim.remove_all_csv_attributes", icon="CANCEL", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.export_csv_attributes", icon="EXPORT", text="Create Template")
|
row.operator("bim.export_csv_attributes", icon="EXPORT", text="Create Template")
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "csv_delimiter")
|
row.prop(props, "csv_delimiter")
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ classes = (
|
|||||||
operator.AddPersonAndOrganisation,
|
operator.AddPersonAndOrganisation,
|
||||||
operator.AddPersonAttribute,
|
operator.AddPersonAttribute,
|
||||||
operator.AddRole,
|
operator.AddRole,
|
||||||
|
operator.ClearUser,
|
||||||
operator.DisableEditingAddress,
|
operator.DisableEditingAddress,
|
||||||
operator.DisableEditingOrganisation,
|
operator.DisableEditingOrganisation,
|
||||||
operator.DisableEditingPerson,
|
operator.DisableEditingPerson,
|
||||||
|
|||||||
@@ -292,9 +292,19 @@ class RemovePersonAndOrganisation(bpy.types.Operator, Operator):
|
|||||||
|
|
||||||
class SetUser(bpy.types.Operator, Operator):
|
class SetUser(bpy.types.Operator, Operator):
|
||||||
bl_idname = "bim.set_user"
|
bl_idname = "bim.set_user"
|
||||||
bl_label = "set_user"
|
bl_label = "Set User"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
user: bpy.props.IntProperty()
|
user: bpy.props.IntProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.set_user(tool.Owner, user=tool.Ifc.get().by_id(self.user))
|
core.set_user(tool.Owner, user=tool.Ifc.get().by_id(self.user))
|
||||||
|
|
||||||
|
|
||||||
|
class ClearUser(bpy.types.Operator, Operator):
|
||||||
|
bl_idname = "bim.clear_user"
|
||||||
|
bl_label = "Clear User"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
user: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
core.clear_user(tool.Owner)
|
||||||
|
|||||||
@@ -218,8 +218,9 @@ class BIM_PT_owner(bpy.types.Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if user["is_active"]:
|
if user["is_active"]:
|
||||||
row.label(text=user["label"], icon="USER")
|
row.label(text=user["label"], icon="USER")
|
||||||
|
row.operator("bim.clear_user", icon="KEYFRAME", text="").user = user["id"]
|
||||||
else:
|
else:
|
||||||
row.label(text=user["label"])
|
row.label(text=user["label"])
|
||||||
row.operator("bim.set_user", icon="KEYFRAME_HLT", text="").user = user["id"]
|
row.operator("bim.set_user", icon="KEYFRAME_HLT", text="").user = user["id"]
|
||||||
op = row.operator("bim.remove_person_and_organisation", icon="X", text="")
|
op = row.operator("bim.remove_person_and_organisation", icon="X", text="")
|
||||||
op.person_and_organisation = user["id"]
|
op.person_and_organisation = user["id"]
|
||||||
|
|||||||
@@ -139,3 +139,7 @@ def set_user(owner, user=None):
|
|||||||
|
|
||||||
def get_user(owner):
|
def get_user(owner):
|
||||||
return owner.get_user()
|
return owner.get_user()
|
||||||
|
|
||||||
|
|
||||||
|
def clear_user(owner):
|
||||||
|
owner.clear_user()
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class Ifc(blenderbim.core.tool.Ifc):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
return IfcStore.get_file().schema
|
if IfcStore.get_file():
|
||||||
|
return IfcStore.get_file().schema
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_entity(cls, obj):
|
def get_entity(cls, obj):
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ class Owner(blenderbim.core.tool.Owner):
|
|||||||
def get_user(cls):
|
def get_user(cls):
|
||||||
if bpy.context.scene.BIMOwnerProperties.active_user_id:
|
if bpy.context.scene.BIMOwnerProperties.active_user_id:
|
||||||
return tool.Ifc.get().by_id(bpy.context.scene.BIMOwnerProperties.active_user_id)
|
return tool.Ifc.get().by_id(bpy.context.scene.BIMOwnerProperties.active_user_id)
|
||||||
|
elif tool.Ifc.get_schema() == "IFC2X3":
|
||||||
|
users = tool.Ifc.get().by_type("IfcPersonAndOrganization")
|
||||||
|
if users:
|
||||||
|
return users[0]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def clear_user(cls):
|
def clear_user(cls):
|
||||||
|
|||||||
@@ -233,3 +233,8 @@ Scenario: Set user
|
|||||||
And the variable "user" is "{ifc}.by_type('IfcPersonAndOrganization')[0].id()"
|
And the variable "user" is "{ifc}.by_type('IfcPersonAndOrganization')[0].id()"
|
||||||
And I press "bim.set_user(user={user})"
|
And I press "bim.set_user(user={user})"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Clear user
|
||||||
|
Given an empty IFC project
|
||||||
|
When I press "bim.clear_user(user={user})"
|
||||||
|
Then nothing happens
|
||||||
|
|||||||
@@ -219,3 +219,9 @@ class TestGetUser:
|
|||||||
def test_run(self, owner):
|
def test_run(self, owner):
|
||||||
owner.get_user().should_be_called().will_return("person_and_organisation")
|
owner.get_user().should_be_called().will_return("person_and_organisation")
|
||||||
assert subject.get_user(owner) == "person_and_organisation"
|
assert subject.get_user(owner) == "person_and_organisation"
|
||||||
|
|
||||||
|
|
||||||
|
class TestClearUser:
|
||||||
|
def test_run(self, owner):
|
||||||
|
owner.clear_user().should_be_called()
|
||||||
|
subject.clear_user(owner)
|
||||||
|
|||||||
@@ -45,6 +45,16 @@ class TestGetUser(test.bim.bootstrap.NewFile):
|
|||||||
user = tool.Ifc.get().by_type("IfcPersonAndOrganization")[0]
|
user = tool.Ifc.get().by_type("IfcPersonAndOrganization")[0]
|
||||||
assert subject.get_user() == user
|
assert subject.get_user() == user
|
||||||
|
|
||||||
|
def test_falling_back_to_any_available_user_ifc2x3(self):
|
||||||
|
assert subject.get_user() is None
|
||||||
|
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||||
|
tool.Ifc.set(ifc)
|
||||||
|
user = ifc.createIfcPersonAndOrganization()
|
||||||
|
assert subject.get_user() == user
|
||||||
|
user2 = ifc.createIfcPersonAndOrganization()
|
||||||
|
subject.set_user(user2)
|
||||||
|
assert subject.get_user() == user2
|
||||||
|
|
||||||
|
|
||||||
class TestClearUser(test.bim.bootstrap.NewFile):
|
class TestClearUser(test.bim.bootstrap.NewFile):
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user