mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Fix #1908. Extracting elements using IfcPatch now includes all properties.
This commit is contained in:
@@ -120,7 +120,6 @@ class IfcHeaderExtractor:
|
|||||||
line = next(ifc_file)
|
line = next(ifc_file)
|
||||||
if isinstance(line, bytes):
|
if isinstance(line, bytes):
|
||||||
line = line.decode("utf-8")
|
line = line.decode("utf-8")
|
||||||
print(line)
|
|
||||||
if line.startswith("FILE_DESCRIPTION"):
|
if line.startswith("FILE_DESCRIPTION"):
|
||||||
for i, part in enumerate(line.split("'")):
|
for i, part in enumerate(line.split("'")):
|
||||||
if i == 1:
|
if i == 1:
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ class RunMigratePatch(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
core.run_migrate_patch(tool.Patch, infile=self.infile, outfile=self.outfile, schema=self.schema)
|
core.run_migrate_patch(tool.Patch, infile=self.infile, outfile=self.outfile, schema=self.schema)
|
||||||
bpy.ops.file.refresh()
|
try:
|
||||||
|
bpy.ops.file.refresh()
|
||||||
|
except:
|
||||||
|
pass # Probably running in headless mode
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import blenderbim.core.owner as subject
|
import blenderbim.core.patch as subject
|
||||||
from test.core.bootstrap import patch
|
from test.core.bootstrap import patch
|
||||||
|
|
||||||
|
|
||||||
class TestRunMigratePatch:
|
class TestRunMigratePatch:
|
||||||
def test_run(self, patch):
|
def test_run(self, patch):
|
||||||
patch.run_migrate_patch("infile", "outfile", "schema").should_be_called()
|
patch.run_migrate_patch("infile", "outfile", "schema").should_be_called()
|
||||||
assert subject.run_migrate_patch(patch, infile="infile", outfile="outfile", schema="schema")
|
subject.run_migrate_patch(patch, infile="infile", outfile="outfile", schema="schema")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
# along with IfcPatch. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcPatch. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
|
|
||||||
|
|
||||||
@@ -49,18 +50,17 @@ class Patcher:
|
|||||||
self.file = self.new
|
self.file = self.new
|
||||||
|
|
||||||
def add_element(self, element):
|
def add_element(self, element):
|
||||||
new_element = self.new.add(element)
|
new_element = ifcopenshell.api.run("project.append_asset", self.new, library=self.file, element=element)
|
||||||
|
if not new_element:
|
||||||
|
return
|
||||||
for rel in element.ContainedInStructure:
|
for rel in element.ContainedInStructure:
|
||||||
spatial_element = rel.RelatingStructure
|
spatial_element = rel.RelatingStructure
|
||||||
new_spatial_element = self.new.add(spatial_element)
|
new_spatial_element = self.new.add(spatial_element)
|
||||||
self.contained_ins.setdefault(spatial_element.GlobalId, set()).add(new_element)
|
self.contained_ins.setdefault(spatial_element.GlobalId, set()).add(new_element)
|
||||||
self.add_spatial_tree(spatial_element, new_spatial_element)
|
self.add_spatial_tree(spatial_element, new_spatial_element)
|
||||||
for rel in element.Decomposes:
|
for rel in element.Decomposes:
|
||||||
self.new.add(rel.RelatingObject)
|
ifcopenshell.api.run("project.append_asset", self.new, library=self.file, element=rel.RelatingObject)
|
||||||
self.aggregates.setdefault(rel.RelatingObject.GlobalId, set()).add(new_element)
|
self.aggregates.setdefault(rel.RelatingObject.GlobalId, set()).add(new_element)
|
||||||
for opening in element.HasOpenings:
|
|
||||||
self.new.add(opening)
|
|
||||||
self.new.add(opening.RelatedOpeningElement)
|
|
||||||
|
|
||||||
def add_spatial_tree(self, spatial_element, new_spatial_element):
|
def add_spatial_tree(self, spatial_element, new_spatial_element):
|
||||||
for rel in spatial_element.Decomposes:
|
for rel in spatial_element.Decomposes:
|
||||||
|
|||||||
Reference in New Issue
Block a user