Compare commits

...

876 Commits

Author SHA1 Message Date
Andrej730 e3a7f76276 Avoid ui errors after 2dc9dc200 2023-06-24 10:19:35 +05:00
Andrej730 6dab4501ad Unhide in render for not excluded objects #3338
Objects were hidden in render but never unhidden if they were no more in drawing's .Exlcude
2023-06-23 18:19:33 +05:00
Andrej730 2dc9dc2000 Generating IFC compatible shader graphs
Added new panel. in shader graph N-panel that allows you to create fully GLTF and IFC compatible shader graphs by just tweaking parameters from the panel. Note that it's still saved to IFC only when you hit "Save Current Style", before that it's still just stored in blender.

https://imgur.com/a/vmkoLPH

The premise is that if you want to have non-external style you'd be able to create it entirely from this panel - so there will no need to guess or to remember which parameters from the graph are supported by IFC and which are not.

It's still work in progress, still need to polish it, add support for more reflectance methods and add suport for textures (need to be able to import/export it with .ifc and set them from this panel).
2023-06-23 18:04:32 +05:00
Andrej730 addce9f0ea Fixed #3342 2023-06-23 17:15:10 +05:00
Andrej730 4a368938c3 Set shading flat by default to solve #3336
Before blender 3.6 it was setting flat shading by default, so we just keeping the same behaviour.
2023-06-22 22:00:42 +05:00
Thomas Krijnen a0f68baefc #2805 syntax 2023-06-22 16:23:32 +02:00
Thomas Krijnen 3decb48ed0 #2805 template keyword for gcc 2023-06-22 14:30:11 +02:00
Thomas Krijnen 2d330f4c90 #2805 IFC4X3 codegen 2023-06-22 14:10:55 +02:00
Thomas Krijnen 1c996013b6 #2805 Further fixes for aggregates of select 2023-06-22 14:10:55 +02:00
Thomas Krijnen 65cb47e2d8 #2805 IfcGeom dynamic casting updates 2023-06-22 14:07:34 +02:00
Thomas Krijnen e9d0b8ab66 #2805 IfcGeom updates 2023-06-22 12:07:10 +02:00
Thomas Krijnen 0bb9bcd9fb #2805 Pasta errors 2023-06-22 11:03:06 +02:00
Thomas Krijnen 997ebe48df #2805 template keyword for gcc 2023-06-22 10:48:19 +02:00
Thomas Krijnen 0cdf72fde1 #2805 Rerun codegen 2023-06-22 10:30:57 +02:00
Thomas Krijnen 97c6b99d57 #2805 Use dynamic cast for generalize() due to virtual inheritance of selects 2023-06-22 10:30:42 +02:00
Thomas Krijnen ed5d28de54 #2805 update hierarchy helper 2023-06-22 10:08:58 +02:00
Thomas Krijnen f5c102402f #2805 rerun codegen 2023-06-22 10:07:27 +02:00
Thomas Krijnen 7aa04611a1 #2805 provide aggregate typedef for select types 2023-06-22 10:07:26 +02:00
Andrej730 5c7f14cc3c option to keep the viewport position on activating drawing #3333
currently it works with alt clicking activate drawing button
https://i.imgur.com/lgvP4QA.png
2023-06-22 10:15:39 +05:00
Andrej730 9e1249d8ee Fixed #3335 caused by 36b746d 2023-06-22 09:33:40 +05:00
Bruno Postle 6cb7234cb5 BBIM fix Git panel polling repo on refresh (#3096)
Just scrolling Git panel shouldn't do any Git IO
2023-06-21 21:42:50 +01:00
Thomas Krijnen aab6a21bf3 #2805 rerun codegen 2023-06-21 19:25:05 +02:00
Thomas Krijnen c72f960ed4 #2805 statically typed select types as aggregates 2023-06-21 19:25:04 +02:00
Massimo Fabbro b63b4ce326 Add toggle space visibiity button into spatial tool menu 2023-06-21 18:57:41 +02:00
Andrej730 71113b56bf refactor with SKIP_SAVE option on operator props
Co-Authored-By: Gorgious56 <25156105+Gorgious56@users.noreply.github.com>
2023-06-21 17:49:16 +05:00
Andrej730 ef57c209a0 More options to save .ifc as relative path in blender 2023-06-21 17:39:57 +05:00
Andrej730 e99c154cb2 Fixed tests after a4a6dce 2023-06-21 14:19:26 +05:00
Andrej730 520860bdb9 Fixed test after b035129 2023-06-21 14:19:25 +05:00
Andrej730 103e8a545b Fixed test after c8c0c9a
Taking into account that now we have error messages if user will try to remove the last material layer which would make layer set invalid ifc.

FAILED test/bim/test_feature.py::test_remove_material_set_layer - AssertionError: Failed to run operator bpy.ops.bim.remove_layer(layer=IfcStore.get_file().by_id(93).MaterialLayers[...
2023-06-21 14:19:25 +05:00
Andrej730 d35c5c433f Fixed missing ifc file in api call after 28cc168
Some bim test was failing because of it

FAILED test/bim/test_feature.py::test_assign_material__material_profile_set - AssertionError: No material Default found in profiled materials: []
2023-06-21 14:19:25 +05:00
Andrej730 7dc98612e4 Fixed void tests after d3d2c36 2023-06-21 11:04:22 +05:00
Andrej730 3853258b27 Fixing test after 1c12a98
FAILED test/bim/test_feature.py::test_export_ifc__with_basic_contents_and_saving_as_a_relative_path - AssertionError: Value is C:\IfcOpenShell\src\blenderbim\test\files\temp\export.ifc
2023-06-21 10:16:03 +05:00
Andrej730 6825d26700 Small fix related to 5c2ae98c0 and a bit more descriptive operator error
FAILED test/bim/test_feature.py::test_create_project__ifc2x3 - AssertionError: Failed to run operator bpy.ops.bim.create_project
2023-06-21 09:58:41 +05:00
Andrej730 900c35e9fe Fixing collections tests related to 99d9c0f5b
FAILED test/bim/test_feature.py::test_remove_drawing - AssertionError: The collection "IfcGroup/PLAN_VIEW" does not exist
2023-06-21 09:46:44 +05:00
Bruno Postle 7aafa87b52 BlenderBIM push Git tags to remote
Shows error message if push fails
2023-06-20 16:58:55 +01:00
Andrej730 e719055d9a Fixed duplicated objects collections issue after 586707dd2
Duplicated objects were not able to have their own collection after 586707dd2

Also fixed bim test
FAILED test/bim/test_feature.py::test_copy_a_storey - AssertionError: assert 'IfcBuildingStorey/My Storey.001' in ['IfcBuildingStorey/My Storey']
2023-06-20 19:42:31 +05:00
Andrej730 a956038bfc Preserving original name on unlinking
Unlinking was using copied object name for the unlinked object instead of the original one.
So it worked like Cube -> IfcWall/Cube -> Cube.001 and bim test was failing:
FAILED test/bim/test_feature.py::test_unlink_object - AssertionError: The object "Cube" does not exist
2023-06-20 19:18:40 +05:00
Andrej730 5c2ae98c09 Fixed couple bugs in test_feature
1) Explicitly set empty ifc project not to load demo library - was still loading because it was using my default scene which caused errors.
2) typo in dimension check assertion message
2023-06-20 19:18:39 +05:00
Andrej730 99d9c0f5bf Fixing collectors tests after 1f43ec8 2023-06-20 17:50:30 +05:00
Andrej730 2fbb9c569b Fixing tool tests 2023-06-20 17:30:01 +05:00
Andrej730 4a9d1ff038 Fixing core tests 2023-06-20 16:31:10 +05:00
Andrej730 6cd9161986 Fixed import error with filtering out IfcGrid's spatial element #3283
Fixed error that was occuring if you try to import .ifc file where spatial element contains only grid and will use advanced mode, filter mode = "IFC Class" and check "Filter Spatial Elements".

Error occured because spatial element was filtered out but then when ifc grid was created and importer to find a spatial element based collection for the grid it couldn't find it.

Traceback:
Error: Python: Traceback (most recent call last):
  File "\blenderbim\bim\module\project\operator.py", line 595, in execute
    ifc_importer.execute()
  File "\blenderbim\bim\import_ifc.py", line 260, in execute
    self.place_objects_in_collections()
  File "\blenderbim\bim\import_ifc.py", line 1494, in place_objects_in_collections
    self.place_object_in_collection(self.file.by_id(ifc_definition_id), obj)
  File "\blenderbim\bim\import_ifc.py", line 1498, in place_object_in_collection
    self.place_object_in_decomposition_collection(element, obj)
  File "\blenderbim\bim\import_ifc.py", line 1517, in place_object_in_decomposition_collection
    return self.place_object_in_spatial_decomposition_collection(element, obj)
  File "\blenderbim\bim\import_ifc.py", line 1545, in place_object_in_spatial_decomposition_collection
    self.collections[container.GlobalId].children.link(grid_collection)
KeyError: '33AiKftFj2aAf2MqQr5Gs7'
2023-06-19 19:04:51 +05:00
Andrej730 982f4a4965 Fixed getting filtered spatial elements at import for ifc2x3 #3283
In ifc2x3 IfcProject is not IfcContext because there is no IfcContext in ifc2x3 and it was causing the error below on .ifc import with filtered spatial elements.
Also added small refactor

Traceback:
Error: Python: Traceback (most recent call last):
  File "\blenderbim\bim\module\project\operator.py", line 595, in execute
    ifc_importer.execute()
  File "\blenderbim\bim\import_ifc.py", line 253, in execute
    self.create_spatial_elements()
  File "\blenderbim\bim\import_ifc.py", line 688, in create_spatial_elements
    self.create_generic_elements(self.spatial_elements)
  File "\blenderbim\bim\import_ifc.py", line 698, in create_generic_elements
    products = self.create_products(elements)
  File "\blenderbim\bim\import_ifc.py", line 717, in create_products
    iterator = ifcopenshell.geom.iterator(settings, self.file, multiprocessing.cpu_count(), include=products)
  File "\blenderbim\libs\site\packages\ifcopenshell\geom\main.py", line 99, in __init__
    raise ValueError("include and exclude need to be an aggregate of IfcProduct?")
ValueError: include and exclude need to be an aggregate of IfcProduct?
2023-06-19 19:03:18 +05:00
Thomas Krijnen c5aab16696 Remove dependency on bootstrap 2023-06-19 14:34:14 +02:00
Thomas Krijnen 6e1b18ba33 #3120 item_id vector test case 2023-06-19 13:48:35 +02:00
Thomas Krijnen 2b3d547c99 #3120 item_id vector 2023-06-19 13:47:55 +02:00
Andrej730 a34be6ae5d Getting shader graph nodes by type rather than name #3316
Because relying on names doesn't work for non english users
2023-06-19 16:17:37 +05:00
Andrej730 dfc5a280a4 Fixed error on disabling editing window 2023-06-19 15:51:01 +05:00
Andrej730 6a2bbfa85c Added button to update current style #3293
Example - https://i.imgur.com/f4Yi3MR.png
Now changing style type should be a bit more intuitive - previously there were no button and it wasn't possible to change style type for all selected objects / changing style type for the entire scene were hidden in N-panel Miscellaneous section.

Now it also able to change style type for all blender materials, even the ones that don't have any objects using them (wasn't possible before 7c0c934b4)
2023-06-19 11:02:42 +05:00
Bruno Postle ddef4820d0 BlenderBIM Git merge asymmetry heuristic (#3096)
`ifcmerge` is asymmetrical. When both branches have new entities, either
local or remote step Ids need to be renumbered to resolve the merge
conflict.

If the remote branch is 'origin/main' or 'main' we preserve remote Ids,
otherwise we preserve local Ids.

This should support a workflow where a local 'main' branch is kept
pristine, but other local branches are treated as disposable; it should
also support a workflow where multiple authors access a shared 'origin'.
2023-06-16 19:42:57 +01:00
Thomas Krijnen e6b05b547b Further defer sql.py imports for ifcopenbot to succeed 2023-06-16 20:32:40 +02:00
Thomas Krijnen 5e8ec48d98 Comment out import mysql.connector 2023-06-16 14:16:17 +02:00
Thomas Krijnen 9c21304629 Correct if-clause 2023-06-16 14:08:48 +02:00
Thomas Krijnen 1278f98df6 Add test 2023-06-16 14:08:48 +02:00
Totally a booplicate d31b470e83 smol fix 2023-06-16 14:08:48 +02:00
Totally a booplicate 1ecb25684e fix missing else clause 2023-06-16 14:08:48 +02:00
Totally a booplicate 5999976d37 raise TypeError on invalid pset 2023-06-16 14:08:48 +02:00
Totally a booplicate 51e5f843ba rework unpack_unit_value
handle the `None` case, simplify logic
2023-06-16 14:08:48 +02:00
Totally a booplicate 3d787338fb improve naming of the new method 2023-06-16 14:08:48 +02:00
Totally a booplicate de67648f3e improve update_existing_properties
explicit class check
error out on a not supported type
better methods names
2023-06-16 14:08:48 +02:00
Totally a booplicate afa803ea62 implement _try_purge
per review comment about repeating code
2023-06-16 14:08:48 +02:00
Totally a booplicate 3a0aaee03b restructure if/elif/else chain 2023-06-16 14:08:48 +02:00
Totally a booplicate a5353e02b5 support tuples 2023-06-16 14:08:48 +02:00
Totally a booplicate 1acc743370 move prop check 2023-06-16 14:08:48 +02:00
Totally a booplicate 375f4f2a86 per review
change exception message
remove TODO
pass `Unit`
raise `NotImplementedError` when no template was found
2023-06-16 14:08:48 +02:00
Totally a booplicate d4b88fd422 resolve TODO
This is being fixed, we should always have a class to use
2023-06-16 14:08:48 +02:00
Totally a booplicate df6cc74a87 attempt to improve pset support
1. Adds support to directly passed in property entities
2. Adds support for tuples
3. Adds support for P_LISTVALUE
2023-06-16 14:08:48 +02:00
Balázs Dukai 80846061f2 Don't use importlib for version 2023-06-16 13:29:24 +02:00
Balázs Dukai 80f9590410 Get package version from pyproject.toml 2023-06-16 13:29:24 +02:00
Balázs Dukai 16cda28d16 Include GenericCityObject extension 2023-06-16 13:29:24 +02:00
Balázs Dukai 24ea024a0d Add parameters 2023-06-16 13:29:24 +02:00
Balázs Dukai e90d7ccdb1 Init package 2023-06-16 13:29:24 +02:00
Vasile-Corjan 1a3bf513a7 Update README.md 2023-06-16 08:34:05 +02:00
Vasile-Corjan a855c40426 Update README.md
I have added the parameters "minOccurs" and "maxOccurs"
2023-06-16 08:34:05 +02:00
Dion Moult c8ede38edb Run black on existing entity_instance 2023-06-16 16:17:17 +10:00
Dion Moult 704e27ecca Build testing prototype of an SQLite based file / entity_instance. 2023-06-16 16:16:22 +10:00
Dion Moult 438ddc17f5 Document two answers to frequently reported bugs: missing numpy and blend / ifc out of sync. 2023-06-16 14:13:15 +10:00
Dion Moult a8dfed50e4 Minor geometry processing documentation fix 2023-06-16 13:32:33 +10:00
Dion Moult 8cb99a77cf Convert Ifc2Sql script to IfcPatch recipe and add geometry support 2023-06-16 13:32:33 +10:00
Dion Moult f9b6e6f098 Fetch pset and qto names via pset data instead of real time to prevent UI lag on larger models. 2023-06-16 13:32:33 +10:00
Dion Moult 1365b76149 Lazily check for BBIM_Railing psets to prevent unnecessarily fetching psets for every element when loading models. 2023-06-16 13:32:33 +10:00
Dion Moult 47cc3158fd IfcPatch can now support patches that write to arbitrary files or have no output. 2023-06-16 13:32:33 +10:00
Dion Moult bac683e105 Fix bug for getting psets of materials and profiles in IFC2X3 2023-06-16 13:32:33 +10:00
Thomas Krijnen 840818d681 #3308 add assert 2023-06-15 21:27:42 +02:00
Thomas Krijnen 206933a2f2 #2819 Handle periodic bspline curves in serialization 2023-06-15 16:19:05 +02:00
Thomas Krijnen ff209b4c11 #2819 Mark rep id as AdvancedBrep 2023-06-15 16:18:29 +02:00
Sigma Dimensions 4bc987924d enable activating object type when trying to select type from an object ( whilst the type is hidden from view layer) 2023-06-14 13:11:17 +01:00
Massimo Fabbro f26cfc93ea Now generate spaces from walls considers also columns in order to create the contours 2023-06-14 12:58:39 +02:00
Thomas Krijnen 4bbb6cd2df #3305 Less pessimistic tolerance comparison in newells method 2023-06-14 11:47:24 +02:00
Thomas Krijnen 9411a1d94b #3305 one more iteration on lower fuzziness level for boolean ops 2023-06-14 11:47:24 +02:00
Sigma Dimensions 6a287ced7c temporarily hide IFC Spatial Manager for IFC2X3 models 2023-06-14 10:47:00 +01:00
Sigma Dimensions fb02ac34d4 Enable selecting group elements 2023-06-14 09:35:54 +01:00
Sigma Dimensions 81fd84223a Enable selecting a container's children from the IFC Spatial Manager panel 2023-06-13 21:17:02 +01:00
Sigma Dimensions a8f1a28ac2 fix replacing material with material profile 2023-06-13 14:04:28 +01:00
Sigma Dimensions d2f4f0d8c2 experimental patch of non parametric mep segments 2023-06-13 13:26:53 +01:00
Sigma Dimensions 1c17cccc45 fix missing import 2023-06-13 10:34:21 +01:00
Sigma Dimensions 061930bc8e Move Spatial Manager UI to "IFC Project Set-up" 2023-06-13 10:32:25 +01:00
Sigma Dimensions 28cc168b3b split material assign/unassign operators into tool and core 2023-06-13 10:28:31 +01:00
Sigma Dimensions 88f53f7931 fix delete material operator 2023-06-12 15:24:51 +01:00
Sigma Dimensions 755fa81817 Fix displaying connections for selected distribution ports 2023-06-12 15:23:24 +01:00
Sigma Dimensions 36fab12847 Refactor and re-use common spatial_tool.select_products 2023-06-12 15:21:33 +01:00
Andrej730 32393136d2 Support external shaders from currently opened blend file
Previously it was crashing if you try use shader from current .blend file as external.
I guess we now kind of support external internal shaders 🙃
2023-06-12 17:28:52 +05:00
Andrej730 c7b3331496 switch to external styles for rendered shading in viewport
Unfortunately I couldn't find a way to make it work with areas that user created during current blender session. But new areas will have this feature too after blender restart
2023-06-12 17:28:52 +05:00
Andrej730 7c0c934b4f prioritize external styles on ifc import
also found a way to switch shade graph for two materials without juggling active materials and active objects - it was necessary to make it work on import without adding temporary active object
2023-06-12 17:28:51 +05:00
johanrd 62944e04e9 fix typo in README.md 2023-06-12 11:22:31 +02:00
Bruno Postle 3a93b15b55 BBIM show all fetched remote Git branches (#3096) 2023-06-11 20:49:55 +01:00
Gorgious 83cd00271b Fix #3142 : Use Tab hotkey to edit horizontally layered objects 2023-06-11 18:17:03 +02:00
Ahmad Saleem Z 820686a39b added link to aws/lambda guide in installation guide 2023-06-11 18:04:34 +02:00
Ahmad Saleem Z 4fe896a3b6 fix ARG in Dockerfile 2023-06-11 18:04:34 +02:00
Ahmad Saleem Z 975b1c444c documentation 2023-06-11 18:04:34 +02:00
Ahmad Saleem Z c3f2046491 example fixes 2023-06-11 18:04:34 +02:00
Ahmad Saleem Z 3a1557bedc added aws/lambda sample 2023-06-11 18:04:34 +02:00
Bruno Postle a71b5e1f11 BlenderBIM operator to add remote repo (#3096)
Procedure to merge a pull request would be: Add Remote, select the added
remote in the pull-down, Fetch from remote, select the added remote
branch in the pull-down, Merge, delete remote
2023-06-10 22:04:01 +01:00
Dion Moult 4806b9a260 Toggle between full schema (i.e. all tables for every declaration) and partial schema dump into SQL 2023-06-10 23:14:32 +10:00
Bruno Postle 0d67c43e16 BlenderBIM operator to delete a Git remote (#3096) 2023-06-10 11:08:49 +01:00
Bruno Postle e2b52e7ed9 BlenderBIM fix warning writing .git/config (#3096) 2023-06-10 10:07:17 +01:00
Balázs Dukai 3c53067567 Add copyright 2023-06-10 15:39:49 +10:00
Balázs Dukai 5ad7d4bb2a Update to ifcopenshell 0.7.0 and cjio 0.8
LoD is string in v1.1
2023-06-10 15:39:49 +10:00
Balázs Dukai 3803942c5f Update to v1.1 CityObject types 2023-06-10 15:39:49 +10:00
Andrej730 678f50f17d IfcGitData update to ifcgit operators poll() methods
Added loading IfcGitData to ifcgit operator's poll() methods because it was getting a bit spammy in console if you don't use git.

Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 255, in poll
    if IfcGitData.data["ifcmerge_exe"]:
KeyError: 'ifcmerge_exe'
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 147, in poll
    repo = IfcGitData.data["repo"]
KeyError: 'repo'
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 18, in poll
    path_ifc = IfcGitData.data["path_ifc"]
KeyError: 'path_ifc'
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 45, in poll
    path_ifc = IfcGitData.data["path_ifc"]
KeyError: 'path_ifc'
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 190, in poll
    repo = IfcGitData.data["repo"]
KeyError: 'repo'
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 111, in poll
    repo = IfcGitData.data["repo"]
KeyError: 'repo'
2023-06-09 19:38:16 +05:00
Andrej730 04fe2bdf2e External Styles
Added support for external blender styles that will be saved to ifc.
What it basically means that you can append material from external .blend file as a style that can be loaded in your blender material anytime.

1) External style can be added in Material Tab
https://i.imgur.com/BYfesi5.png

Note that you select material name at the right side of file selecting panel:
https://i.imgur.com/mvqaaod.png

2) After adding external style you can switch between external and other surface styles:
https://i.imgur.com/YtCz8an.png

3) There is also option to switch styles to External for all objects in the scene:
https://i.imgur.com/u3zTcX9.png

Some other changes:
- some ui adjustments
- moved functions that create blender shaders to tool.Loader (they also reset shader graph now so it's possible to use them on non-default blender materials)
- some new tools for copying node graph from one material to another, appending data blocks
- new operator for browsing external styles can be reused later to append other data blocks
2023-06-09 18:40:53 +05:00
Dion Moult ed990c3e83 Experimental support for storage of IFC in MySQL and SQLite 2023-06-09 22:16:54 +10:00
D4ve-R 741c78cd6c Revert "build scripts"
This reverts commit 6c1218d352.
2023-06-09 13:28:25 +02:00
D4ve-R 2b88c542aa build scripts 2023-06-09 13:28:25 +02:00
D4ve-R 1f6b55e639 prepare for referencing 2023-06-09 13:28:25 +02:00
D4ve-R 9f3fb13cde metersPerUnit 2023-06-09 13:28:25 +02:00
D4ve-R 42f1d9c160 usd rotateXYZop 2023-06-09 13:28:25 +02:00
D4ve-R f0875835c1 Update submodule 2023-06-09 13:28:25 +02:00
D4ve-R 0828a89b66 fix typo 2023-06-09 13:28:25 +02:00
D4ve-R a8ca66b425 refactor 2023-06-09 13:28:25 +02:00
D4ve-R 92b03c6b59 stage up axis 2023-06-09 13:28:25 +02:00
D4ve-R d316efe902 fix filename bug 2023-06-09 13:28:25 +02:00
D4ve-R 77e4e939ce filename bug 2023-06-09 13:28:25 +02:00
D4ve-R fe7504edf2 cmake warnings 2023-06-09 13:28:25 +02:00
D4ve-R a8f1ab1923 material subsets 2023-06-09 13:28:25 +02:00
D4ve-R 1b5f9497d4 works fine 2023-06-09 13:28:25 +02:00
D4ve-R a7bbb35c5e compile & link successful 2023-06-09 13:28:25 +02:00
D4ve-R 1787f064f6 materials 2023-06-09 13:28:25 +02:00
D4ve-R d1c24ebba4 Add USDSerializer to IfcConvert 2023-06-09 13:28:25 +02:00
D4ve-R cc6dacb286 Add USDSerializer write-only 2023-06-09 13:28:25 +02:00
Thomas Krijnen c67eb60fd5 #2942 Escape SVG text labels 2023-06-09 11:34:50 +02:00
Sigma Dimensions 59c482489f Merge pull request #3279 from nelsonhp3/v0.7.0
implements fileselect to export_cost_schedules
2023-06-08 23:48:30 +01:00
Andrej730 7a0963617e Fixed small error on disabling editing extrusion axis 2023-06-08 17:58:06 +05:00
Chetan e4ec1dc457 If an IFC file has an IFCRELASSOCIATESMATERIAL but did not supply an IFCMATERIAL, IfcConvert will crash. This commit prevents the crash, catches the exception and prints an error on the terminal 2023-06-08 10:01:24 +02:00
Dion Moult b035129788 Fix bug where you couldn't unassign inherited materials. 2023-06-08 16:00:31 +10:00
Dion Moult 78be8114ac Fix sync bug where unused styles would be purged when reloading a blender file. 2023-06-08 16:00:31 +10:00
Nelson Henrique 18ad025c5d implements fileselect to export_cost_schedules 2023-06-08 00:24:48 +00:00
Martin15135215 5825e0c71b CITATION.cff for BIMTester 2023-06-08 09:45:54 +10:00
Martin15135215 df64ca4cfb CITATION.cff for ifc5d 2023-06-08 09:45:54 +10:00
Martin15135215 fc1f5496a0 CITATION.cff for ifc4d 2023-06-08 09:45:54 +10:00
Martin15135215 5a9dbc5a36 CITATION.cff for ifc2ca 2023-06-08 09:45:54 +10:00
Martin15135215 eaeeede287 CITATION.cff for bsdd 2023-06-08 09:45:54 +10:00
Martin15135215 e78b3a3977 CITATION.cff for bcf 2023-06-08 09:45:54 +10:00
Bruno Postle a8ca8217ea BlenderBIM fix Git error on simple merge (#3096)
Running git commit after a simple merge (that hasn't required conflict
resolution) is a noop, but generates an annoying message anyway.
2023-06-07 22:50:20 +01:00
Dion Moult 77c2e30733 Fix #3272. See #3069. Fix incorrect refactoring when I was decoupling collections. 2023-06-07 22:13:38 +10:00
Gorgious56 5a3a387b8c Fix error when going out of edit mode with TAB when editing an arbitrary profile 2023-06-07 11:22:06 +02:00
Gorgious56 f68f60832c Fix profile based geometry not re-generating properly when exiting edit mode and the profile geometry wasn't modified 2023-06-07 11:21:43 +02:00
Martin15135215 b05417a4d8 Update author in CITATION.cff 2023-06-07 10:54:47 +02:00
Martin15135215 c2a4e30fae CITATION.cff file for BlenderBIM 2023-06-07 10:54:47 +02:00
Thomas Krijnen 1a0280928b #3201 take into account edge orientation correctly 2023-06-07 08:43:08 +02:00
Andrej730 dda16c847d ids/classes namespaces for drawings in the sheet #3047
Now we add some prefix based on drawing id to each id in the drawing and also add this prefix as a class and add it to all css selectors.
Reason for that so each drawing on the sheet can have it's own set of styles that won't be affecting other drawings.
Example - https://i.imgur.com/kqRCwJW.png
2023-06-07 11:07:48 +05:00
Dion Moult 47c6c2ce9a See #3266. Write documentation on how to use IfcCSV. 2023-06-07 16:00:12 +10:00
Dion Moult 3758c454c9 Add support for Pandas DataFrames in IfcCSV and clean up function signatures 2023-06-07 15:59:20 +10:00
Dion Moult 4b6424e0e1 Fix #3264. Describe IFC to JSON conversion (and other formats) in documentation. 2023-06-07 14:30:48 +10:00
Bruno Postle d71887d846 BlenderBIM fix Git merge log history (#3096)
The GitPython commit() method isn't suitable for completing a merge as
it only sets one parent, losing all history from the merged branch.
2023-06-07 00:45:01 +01:00
Thomas Krijnen d61945a575 #3255 unreferened param 2023-06-06 13:25:13 +02:00
Gorgious56 45e6ae6708 Revert unselect non-ifc object using TAB 2023-06-06 11:59:05 +02:00
Gorgious56 ebbf30a88c Fix wall mounted handrail railing modifier not regenerating properly when going out of edit mode with the tab key if the path wasn't modified 2023-06-06 09:57:00 +02:00
Dion Moult e5769766af Fix #3226. There is now a faster deletion mode that kicks in for large models and large geometry deletions. 2023-06-06 17:40:31 +10:00
Dion Moult 64b9d2e5e3 See #3226. New batched remove_deep2() which uses serialisation for faster removal performance on large graphs. 2023-06-06 17:40:31 +10:00
Andrej730 3213ffe760 Fixed #3259 2023-06-06 10:44:27 +05:00
Bruno Postle a851689bca BlenderBIM use git shortlog to summarise merge log 2023-06-05 21:22:16 +01:00
Gorgious56 98f2bd66b6 Edit profile based representations with TAB (#3142)
* You can now edit profile based representations with TAB

* Minor fix

* Minor fix

* You can now edit parametric railing paths with TAB
Still not sure about the implementation though

* use shortcut instead of direct link to railing edition

* Add utility to check if a mesh is profile based or its representation is a swept solid

* Fix bug when trying to edit an empty object

* Prevent editing door, window and stair modifiers since they're fully parameterized by the modifier properties

* You can now edit roof modifier, railing modifier and various profile based objects

* You can now edit axis profile based objects
2023-06-05 18:07:25 +02:00
Andrej730 1c12a98b68 Solved #3219 2023-06-05 18:45:02 +05:00
Andrej730 a3859385c4 Blender curves to IfcIndexedPolyCurve #3233
Now blender curves segments saved in IfcIndexedPolyCurves instead of creating individual polygons.
Also changed ShapeBuilder.polyline - now it will try to store points in IfcLineIndex where it's possible (previously it was storing just 2).
2023-06-05 17:21:27 +05:00
Andrej730 c7394faf51 Display units for more pset/qset props #3235
Now current project units displayed for area and volume properties too.
https://i.imgur.com/7dgl1pC.png
Also added support for imperial units symbols.
2023-06-05 14:54:41 +05:00
Andrej730 3907ae656c small note for unsupported pset prop types 2023-06-05 12:44:50 +05:00
Andrej730 5fc31be8aa Add to scene properties whether we use relative path to .ifc #3251
Previously it was stored as operator's prop which is (turned out) reseted on reopening .blend.
2023-06-05 12:09:59 +05:00
Andrej730 7976fb4d09 Small fix for 1f43ec870
Was getting this error at project start:

Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\project\operator.py", line 332, in execute
    return IfcStore.execute_ifc_operator(self, context)
  File "\scripts\addons\blenderbim\bim\ifc.py", line 410, in execute_ifc_operator
    result = getattr(operator, "_execute")(context)
  File "\scripts\addons\blenderbim\bim\module\project\operator.py", line 345, in _execute
    self.import_type_from_ifc(element, context)
  File "\scripts\addons\blenderbim\bim\module\project\operator.py", line 374, in import_type_from_ifc
    collection_obj = collection.BIMCollectionProperties.obj
AttributeError: 'LayerCollection' object has no attribute 'BIMCollectionProperties'
2023-06-05 11:50:27 +05:00
Andrej730 01635ecd8a small fix for syntax warning after 4865b62ea
SyntaxWarning: "is not" with a literal. Did you mean "!="?
2023-06-05 11:42:28 +05:00
Andrej730 f6657113b6 Spatial/Structural Tools icons 2023-06-05 11:18:52 +05:00
Andrej730 480f1a91a6 Moving operators to Spatial Tool
Changes:
- Moved Shift A "Add boundary" from BIM Tool to Spatial Tool
- Moved Alt B "Show boundaries" from BIM Tool to Spatial Tool
2023-06-05 11:18:52 +05:00
Massimo Fabbro 4865b62ea9 Fix create spaces from walls z-value (#3248)
Co-authored-by: Dion Moult <dion@thinkmoult.com>
2023-06-05 15:17:03 +10:00
Massimo Fabbro 9a440899be New toggle space visibility button 2023-06-05 15:15:37 +10:00
Dion Moult 3ee6bdf207 You can now get decompositions non-recursively in element utilities 2023-06-05 15:11:55 +10:00
Dion Moult 1f43ec8709 Fix #3069. (Again) review all occurrences of users_collection and collection.name 2023-06-05 15:11:19 +10:00
Trashman247 d030582fbb Keep dist-info in compiling brickschema and add persistence extras 2023-06-04 20:53:23 -07:00
Bruno Postle 60a8d9b2fd Include commit summary of merged branches (#3096)
Git merges usually transfer the commit history, but when we resolve a
conflict with a 'mergetool' (ie. ifcmerge), this history is lost,
everything is squashed into a single commit. Now a summary of the
merged changes is appended to the merge message.
2023-06-04 22:47:10 +01:00
Bruno Postle a5de5d8c0e Display multi-line commit and tag messages (#3096) 2023-06-04 18:39:03 +01:00
Sigma Dimensions b506e7dbbc Add a banner to ifcopenshell README 2023-06-04 12:53:21 +01:00
Bruno Postle db8f1a9b70 Operator to delete a Git tag (#3096) 2023-06-04 11:17:45 +01:00
Bruno Postle 032f52d434 Operator to view selected object Git history #3096
A new BlenderBIM > Git History side-panel to show the raw Git log
for the step entity of the selected object
2023-06-04 09:52:30 +01:00
Sigma Dimensions 1003e8de91 Prototype Building Storey Manager #3246 2023-06-03 21:07:20 +01:00
Sigma Dimensions c6ef402b60 fix draw_project_not_saved_ui for BIM documentation 2023-06-03 11:55:44 +01:00
Andrej730 5805653431 same generate_pset_templates.py for ifcopenshell and ifc dev repos
same script will be easier to maintain
2023-06-03 12:57:48 +05:00
Andrej730 186da73135 Fixed validation errors in pset templates library
- missing project and IfcRelDeclares guids
- missing RelatingContext in IfcRelDeclares
2023-06-03 11:00:29 +05:00
Andrej730 528481e774 Fixed missing PrimaryMeasureType for P_LISTVALUE in pset templates #3236
For some reason there is also was missing PrimaryUnit in IFC2X3. But it's unrelated to the changes from this commit (generating pset templates before this commit already has PrimaryUnit there).
2023-06-03 10:34:13 +05:00
Sigma Dimensions 886ab52556 You can now review and assign currencies from the Cost Schedule Panel 2023-06-02 14:52:10 +01:00
Sigma Dimensions 8196f31d82 Display currency on cost item values and total cost 2023-06-02 14:49:59 +01:00
Andrej730 de3b844829 Placeholders for spatial and structural tools 2023-06-02 17:57:44 +05:00
Andrej730 fa4e19eba7 Tests for external svg references 2023-06-02 12:01:44 +05:00
Trashman247 1488ae40ee Update Makefile 2023-06-02 14:09:58 +10:00
Sigma Dimensions aa004ef0c6 auto refresh tasks assigned to products when filtering by active schedule 2023-06-02 00:34:08 +01:00
Sigma Dimensions 0c946fae36 fix removing cost item value 2023-06-02 00:31:50 +01:00
Sigma Dimensions f297739836 BBIM 5D: Various Cost Schedule UI Improvemements 2023-06-02 00:30:49 +01:00
Thomas Krijnen b33e58f40b fix syntax error on gcc 2023-06-01 22:03:31 +02:00
Thomas Krijnen 30d9743ae7 typename :( 2023-06-01 21:47:07 +02:00
Thomas Krijnen c974306636 #3141 eliminate_narrow_operands() 2023-06-01 21:42:31 +02:00
Thomas Krijnen 602176815a Commit obsolete fix just in case 2023-06-01 21:41:08 +02:00
Thomas Krijnen 7652144184 Fix IfcFile::getInverse<T>() 2023-06-01 21:39:08 +02:00
Andrej730 0fd94d291b References for adding external svgs to the sheets
It works exactly the same as schedules - you add some .svg file, path to it stored in ifc and you can attach it to the sheet.

UI - https://i.imgur.com/tGbCGBb.png

Still need to add some tests for references
2023-06-01 21:41:06 +05:00
Sigma Dimensions 3c9f09f246 Use util.element.get_predefined_type() #065bda6 2023-06-01 13:07:00 +01:00
Thomas Krijnen d60fbd2c09 Don't assert but just if-check for not terminating rule execution on very invalid files 2023-06-01 14:06:41 +02:00
Sigma Dimensions 9d869ebb6d Run costing tests and rename changed methods 2023-06-01 13:02:01 +01:00
Dion Moult 971e508e3d See #3069. Continued refactoring to not rely on users_collection[0]. 2023-06-01 21:18:32 +10:00
Dion Moult 7020caf682 See #3069. More cleanup moving away from collection names and assumed single collections. 2023-06-01 17:39:36 +10:00
Dion Moult 7cd7ad1281 Fix regressions after making aggregate based on selected objects. 2023-06-01 16:59:53 +10:00
Dion Moult 586707dd28 Fix #3069. WARNING: dangerous change. Objects that have their own collection now have a pointer to that collection. This fixes a variety of subtle sync bugs. 2023-06-01 16:59:53 +10:00
Andrej730 4bb46fa607 Remove test to reproduce #3169 as irrelevant 2023-06-01 10:01:14 +05:00
Andrej730 7d5beb6c80 Added test to cover 2629172ff 2023-06-01 10:01:13 +05:00
Andrej730 ecc0263062 Fixed bug with saving data to Pset_StairFlightCommon not in project units 2023-06-01 10:01:13 +05:00
Dion Moult 39c5dc6ea4 Merge pull request #3214 from maxfb87/new_patch_recipie
New patch recipe
2023-06-01 09:55:10 +10:00
Thomas Krijnen e6d6ab6da7 More informed invalid shape reporting 2023-05-31 22:15:26 +02:00
Thomas Krijnen d7c3b5a990 #3201 apply boolean results in batches as well 2023-05-31 22:15:01 +02:00
Thomas Krijnen 3409cd7c29 #3201 approximate circular sharp corners 2023-05-31 22:13:53 +02:00
Massimo Fabbro 91176349f7 Remove old patch file 2023-05-31 21:07:34 +02:00
Massimo Fabbro 6634025346 Move the recipe into the blenderbim script folder and rewrite it as a script 2023-05-31 21:02:29 +02:00
Sigma Dimensions a771061495 Exporting cost schedules opens the folder directory 2023-05-31 16:21:19 +01:00
Andrej730 2629172ff4 Displaying project units for length values in psets and qsets
Examples:
- https://i.imgur.com/ww7MJ7w.png
- https://i.imgur.com/N1rOELc.png
2023-05-31 18:16:01 +05:00
Andrej730 36b746da7a Railing, Door Modifiers - project units props
Example - https://i.imgur.com/SJOQMMm.png
2023-05-31 14:33:18 +05:00
Burak Yildiz d3aa2e87c9 fix ifcopenshell.version 2023-05-31 10:12:16 +02:00
Andrej730 c6090ef9b3 black format 2023-05-31 12:06:03 +05:00
Andrej730 6354a11645 maintaining same roof thickness for different rafter edge angles
PS roof code is not getting simpler to work with 🥲
2023-05-31 12:04:10 +05:00
Dion Moult 11ec8e04c2 Removing authoring mode which was an outdated concept. 2023-05-31 15:35:53 +10:00
Dion Moult 8a9998bc65 Fix #3163. Use text in lieu of inability to use URIReferences in drawing pset. 2023-05-31 15:14:53 +10:00
Sigma Dimensions 065bda604e Cost schedule name label now shows the predefined type 2023-05-31 04:38:21 +01:00
Dion Moult 471aeab439 Fix #3120. Don't remove doubles as it may break mesh manifoldness. 2023-05-31 13:26:53 +10:00
Dion Moult f2c757b1bb Fix #3113. Support regex in selector filter values. 2023-05-31 13:23:51 +10:00
Andrej730 f6e72ec06f rafter edge angle and roof thickness #3092
Added option to adjust rafter edge angle and roof thickness
Short demonstration - https://imgur.com/a/TsYSs6i
2023-05-30 18:03:35 +05:00
Andrej730 9dd82036ba Roof modifier - asymmetrical gable #3093
Example - https://i.imgur.com/EHaSt16.png
2023-05-30 18:03:34 +05:00
Dion Moult ff2fa70776 Close #3139. Bump IfcOpenShell. 2023-05-30 21:06:09 +10:00
Dion Moult e4b1f56f6d Fix #3211. Generated fills now are siblings to the element that they void. 2023-05-30 16:07:31 +10:00
Andrej730 0d7a789ed8 Schedule Builder - text/background color support #3154 2023-05-30 10:58:56 +05:00
Andrej730 d73e77c5ed separate ifc text literals in svg with newline #3207 2023-05-30 10:30:22 +05:00
Dion Moult dddbf64e93 Fix #3212. Bug where viewport camera bisection didn't have enough tolerance and sometimes wasn't visible. 2023-05-30 14:31:03 +10:00
Dion Moult 1d5891fde7 Fix #3209. Handle loading of custom scales, fix incomplete NTS implementation, and use Lark for more reliable imperial scale parsing. 2023-05-30 12:53:02 +10:00
Dion Moult c5de64de51 Merge pull request #3177 from IfcOpenShell/elevation_tweaks
a few plan level tweaks
2023-05-30 09:53:42 +10:00
Dion Moult a43b2a2ae8 Merge branch 'v0.7.0' into elevation_tweaks 2023-05-30 09:53:19 +10:00
Massimo Fabbro 7ab92dfa0b IfcPatch ReplaceDrawingPath recipie improved: now it's possible to use it on Linux and on Windows 2023-05-29 20:01:45 +02:00
Massimo Fabbro ff81286874 Now it's possible to fix drawing reference path problem saved in Windows and opened in Linux 2023-05-29 17:14:06 +02:00
Andrej730 51ad31f5a3 Fixed Stair annotation bug introduced in 762299124
in 762299124 I've changed number of segments and verts but never adjusted StairDecorator - so it wasn't drawing parts of the annotation
2023-05-29 17:13:51 +05:00
Andrej730 6336db0069 Optimized iteration over objects for viewport annotations #3198
This commit should increase viewport annotations performance significantly on large projects. Described in #3198
2023-05-29 16:47:47 +05:00
Dion Moult 7d7122ee4c Fix #3210. Revert "BBIM Drawings: Exclude ifc objects hidden from render view"
This reverts commit 6f39648077.
2023-05-29 20:31:23 +10:00
Dion Moult 7d852f9e51 Fix #3138. Remove manual copy class and be more intelligent about what classe can be reassigned. 2023-05-29 17:21:05 +10:00
Andrej730 605097de76 Same distance function for viewport and svg #1321 #3198 2023-05-29 12:11:29 +05:00
Dion Moult 07638dac27 Fix #3200. Bug where include / exclude filters could break the drawing. 2023-05-29 15:27:48 +10:00
Sigma Dimensions 6f39648077 BBIM Drawings: Exclude ifc objects hidden from render view 2023-05-28 14:47:47 +01:00
Sigma Dimensions 90c19f8454 Ctrl+P and Alt+P BIMTool Hotekys to assign/unassign aggregation 2023-05-28 14:45:57 +01:00
Bruno Postle 929aa3a49b Select new/changed objects in visual diff (#3096)
When visualising differences between current/selected revision,
new/changed objects are selected as well as colourised
2023-05-28 11:22:01 +01:00
Bruno Postle 83e97b7205 Fix checkout version equivalent to a remote HEAD 2023-05-28 11:02:46 +01:00
Dion Moult 5d583741b9 See #3184. Preserve parametric layerset axis direction hints when changing types. 2023-05-28 17:29:00 +10:00
Dion Moult d3d2c3608b Fix #2106. You can now assign an opening to another element. 2023-05-28 15:02:55 +10:00
Dion Moult a0edd66b92 Fix #3050. Unlinking now gives you an option to delete as well. 2023-05-28 13:52:23 +10:00
Dion Moult c8c0c9a621 Fix #3169. Don't allow the user to create invalid material sets without items. 2023-05-27 22:50:59 +10:00
Dion Moult 00c010e04d See #3169. Fix bug where non walls and slabs didn't get semantic classes in drawings. 2023-05-27 21:32:13 +10:00
Andrej730 1d2c9780da Revision Clouds - new annotation type
Short demonstration - https://github.com/IfcOpenShell/IfcOpenShell/assets/9417531/90c9b458-0bae-40a2-9eee-d748e57c24a3

Curently it doesn't have any special representation in viewport and it doesn't have any customisable parameters.

You might get come across error "Revision cloud edges must form just 1 polygon" - it means your edges either don't form any polygon or form 2 or more, both cases are not supported.
2023-05-27 15:22:07 +05:00
Dion Moult adec3853e8 Fix #3202. 2023-05-26 19:54:26 +10:00
Dion Moult d3251c5ca1 New get_shape_matrix utility. 2023-05-26 19:31:01 +10:00
Dion Moult 68f8d8798a Fix #3181. 2023-05-26 19:31:01 +10:00
Bruno Postle 4c793be5f7 BBIM Ensure LF end-of-line in Git repo (#3096)
Git auto text detection seems to fail with IFC files, possibly due to
long lines. So we now force detection as text which ensures conversion
from CRLF to LF when adding to the repository. We also convert the local
IFC file to LF otherwise Git thinks that the local file is out-of-sync
with the repo version ¯\_(ツ)_/¯
2023-05-26 08:28:20 +01:00
Andrej730 812eb5eaef Small documentation note 2023-05-25 16:09:43 +05:00
Andrej730 6c2be8f886 Procedurally generating list of props for shading styles to cover more props
If it will be too much we still have option to exclude some of them
2023-05-25 14:50:45 +05:00
Gorgious56 301d4fecf8 Remove the cryptic (and slightly annoying) console warning logs when trying to display the type manager when there is no element type in the file 2023-05-24 16:54:57 +02:00
Gorgious56 604dfa8cf4 Fix annoying tooltip when using the eyedropper to copy a type 2023-05-24 16:06:33 +02:00
Andrej730 8bb4ab91b8 Fixed problem with ifccsv set_element_key #3192
Currently "type" attribute in selector returns something like "#71=IfcWallType('20jY5HfLH4LBwMrDEoTdML',$,'WAL100',$,$,$,$,$,$,.NOTDEFINED.)" when the code was expecting the class name like "IfcSlab" or "IfcWall". Changed it to "class" atribute that returns just class name.
2023-05-24 18:02:53 +05:00
Andrej730 0cdd9a0cde Window Modifier - support typing units in props
Example - https://i.imgur.com/C99RRs9.png
2023-05-24 17:41:10 +05:00
Andrej730 4768ea23e4 More descriptive exception for reassign_class #3192
Added it because there was no error handling here anyway and later there was another UnboundLocalError:

    for attribute in declaration.all_attributes():
UnboundLocalError: local variable 'declaration' referenced before assignment
2023-05-24 16:45:07 +05:00
Andrej730 659cbe69c3 Stair Modifier - support typing units in props
Example - https://i.imgur.com/XQsVge1.png
2023-05-24 16:45:07 +05:00
Andrej730 e22f4dd001 Array Modifier - support typing units in props
Example - https://i.imgur.com/a0r0vUs.png
Also accidentally fixed input_cursor_array not working properly for projects with non-meters units.
2023-05-24 16:45:07 +05:00
Andrej730 394b2003b3 Small error message on aggregating objects 2023-05-24 16:45:07 +05:00
Dion Moult d72ac7827b Fix #3193. Revert "partially addresses #3103."
This reverts commit 1b2ab4e3f0.
2023-05-24 21:31:41 +10:00
Dion Moult 610ec7d8ad Fix #3086. 2023-05-24 19:33:14 +10:00
Gorgious 8f41ae0c1b Using the eyedropper on a type automatically sets the type and validates assign_type. However it does display an annoying message saying the value was not set, I don't know how to get rid of it. 2023-05-24 11:10:35 +10:00
Gorgious f8113d4857 You can now eyedrop an object in the 3D viewport to fill in its class in the type selector 2023-05-24 11:10:35 +10:00
Gorgious 72169d06ad Fix Relating type enum not correctly initializing 2023-05-24 11:10:35 +10:00
Gorgious 2b78871c01 The type manager now switches to the type when clicking on the "select type" button. Duplicating a type also changes the active type in the type manager 2023-05-24 11:10:35 +10:00
Gorgious 1ce254cc9a Selecting types and instances now show a helpful tooltip when the object is not selectable (due to being hidden or in a hidden collection) 2023-05-24 11:10:35 +10:00
Gorgious 3b07c086a8 You can now duplicate a type from the properties panel
+ change the "paste" icon for the  "duplicate" icon
2023-05-24 11:10:35 +10:00
Gorgious ff7b101b71 "Select instances" button is now grayed out when the type doesn't have any instance 2023-05-24 11:10:35 +10:00
Bruno Postle 92405d819b BlenderBIM set gitattributes and autocrlf
Force Git to always treat IFC files as text.
Store IFC in Git with LF line-endings, but checked-out files are
CRLF on Windows.
2023-05-23 22:45:41 +01:00
Andrej730 c367989ebd Roof modifier - more descriptive errors on invalid footprints #3171 2023-05-23 18:46:27 +05:00
Andrej730 7cae099fb4 Default material layer thickness for adding new layers
Same as when you create IfcMaterialLayerSet
2023-05-23 16:20:06 +05:00
Andrej730 7dcccf9ea5 UI problem with creating empty material layer set causing issues #3169
Now it's also possible to select some material that will be used for they first layer of material layer set.
2023-05-23 15:59:15 +05:00
Ryan Schultz 535e974cc3 bulk assignment of objects to an aggregate. 2023-05-22 22:06:08 -05:00
Andrej730 629aff1e50 Added a descriptive error on attempt of deleting last material layer 2023-05-22 16:37:31 +05:00
Andrej730 628b6830db Fixed error loading .ifc and activating view for drawing with underlay 2023-05-22 15:47:28 +05:00
Ryan Schultz 1b2ab4e3f0 partially addresses #3103. 2023-05-21 15:07:08 -05:00
Sigma Dimensions f97752c368 fix contracting/expanding schedule of rates 2023-05-21 13:25:15 +01:00
Sigma Dimensions d2d5db9bf6 Fix selecting unassigned work/cost schedule products 2023-05-21 12:59:54 +01:00
Sigma Dimensions a8554d9e56 small fix for work schedule derived start/end dates 2023-05-21 12:52:05 +01:00
Sigma Dimensions 11a38af901 BBIMD: enable deleting sequence relationships from list of predecessors/successors 2023-05-21 12:48:34 +01:00
Sigma Dimensions 27a4976b9d remove annoying print statement 2023-05-21 12:45:28 +01:00
Sigma Dimensions eb54f5a0cb ios api task fix: remove orphan IfcRelNests when deleting tasks 2023-05-21 12:45:04 +01:00
Sigma Dimensions a4a6dce6de BBIM D: Copy cost items, export Cost Schedules individually, start improving Cost Schedule UI 2023-05-21 12:42:50 +01:00
Sigma Dimensions 4184e25c68 Easier grouping of materials by allowing material attributes editing from the IfcMaterial subpanel in the scene properties tab 2023-05-21 12:33:41 +01:00
Bruno Postle d98b0766c2 Allow missing/broken GitPython
`import git` can fail badly with a broken xcode installation, so
we let blenderbim run anyway
2023-05-21 09:11:26 +01:00
Bruno Postle b8990dd0a4 Fix merging of remote branches (#3096)
You can now 'clone' a remote repository and 'push' to it. There is no 'pull'
functionality because this can fail badly, so there is a 'fetch' which
retrieves all remote branches without merging (and never fails). The
user can then select the remote branch in the branch pull-down and merge
it.
2023-05-20 09:25:33 +01:00
Andrej730 2198201e0b Detect BBIM railings at import to import as meshes not curves #3144
Sometimes railing could consist just of one IFCSWEPTDISKSOLID then it will be considered native swept disk solid and imported as a curve.

But when user create BBIM railing they edit it as a mesh and curve might look a bit different. Therefore we detect it now at import to make sure it's going to be reprsented the same way as it was saved.
2023-05-19 17:33:45 +05:00
Andrej730 53e58848f3 Reset active drawing id if we removed the active drawing
Previously there was an error if you remove all drawings:
```
Traceback (most recent call last):
  File "\addons\blenderbim\bim\module\drawing\ui.py", line 182, in draw
    DrawingsData.load()
  File "\addons\blenderbim\bim\module\drawing\data.py", line 106, in load
    "active_drawing_pset_data": cls.active_drawing_pset_data(),
  File "\addons\blenderbim\bim\module\drawing\data.py", line 134, in active_drawing_pset_data
    drawing = ifc_file.by_id(bpy.context.scene.DocProperties.active_drawing_id)
  File "\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 326, in by_id
    return self[id]
  File "\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 314, in __getitem__
    return entity_instance(self.wrapped_data.by_id(key), self)
  File "\addons\blenderbim\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4517, in by_id
    return _ifcopenshell_wrapper.file_by_id(self, id)
RuntimeError: Instance #1 077 not found
```
2023-05-19 15:40:58 +05:00
Andrej730 9c367d1702 fixed neg values in format_distance & section/plan level #3175 2023-05-19 15:28:45 +05:00
Andrej730 db18a81035 Added default Model/Annotation/PLAN_VIEW to support e68fdb2db 2023-05-19 12:33:56 +05:00
Andrej730 d1d6b00f92 Test that drawing styles are loaded 2023-05-19 12:00:00 +05:00
Andrej730 32fc147a7c Fixed error on rebuilding sheet with underlays
Also added description and more clear name for `bim.open_sheet`

Error was:
```
Error: Python: Traceback (most recent call last):
  File "\addons\blenderbim\bim\module\drawing\operator.py", line 82, in execute
    IfcStore.execute_ifc_operator(self, context)
  File "\addons\blenderbim\bim\ifc.py", line 410, in execute_ifc_operator
    result = getattr(operator, "_execute")(context)
  File "\addons\blenderbim\bim\module\drawing\operator.py", line 1177, in _execute
    del raster_references[reference.Location]
TypeError: list indices must be integers or slices, not str
```
2023-05-19 11:48:35 +05:00
Andrej730 d98054234c Update drawing styles on changing Underlay checkbox #3172 2023-05-19 10:52:52 +05:00
Ryan Schultz d6460026f2 allow elevations to show negative values
removed RL - not standard throughout the world
2023-05-18 22:38:12 -05:00
Bruno Postle 88ba6514e8 Git remote fetch and push operations (#3096) 2023-05-19 00:27:37 +01:00
Andrej730 894a688bd8 Added test scenario to reproduce #3169
Can be easily called with `pytest .\test\bim\test_feature.py -k "issue"`

Commented some lines out to make sure it doesn't interrupt someone's test process.

Need to uncomment `When I press "bim.create_drawing"` if you want to see if it freezes for you.

You can also uncomment `And I save sample test files and open in blender` to see the freeze manually in Blender client.
2023-05-18 18:36:07 +05:00
Andrej730 c69ead4893 Test to cover drawing maintaining sheet position #3155
Updated to gitignore to include some new folders that are created during tests
2023-05-18 17:30:04 +05:00
Andrej730 e68fdb2db7 3d annotations for FALL, SECTION_LEVEL, PLAN_LEVEL #3145
Before that commit if you created those types of annotations and then reopened .ifc file (without .blend) then you would lose their z coordinate and therefore would lose their value (because they were created previously as 2d annotations).

Now those annotations created as 3d to avoid that problem. I've also added temporary fallback that will turn your existing annotations to 3d next time you edit them.
2023-05-18 14:19:36 +05:00
Andrej730 ae9372c3d3 Maintaining drawing's sheet position on raster x/y changes #3155
Example - https://i.imgur.com/uiNWhIq.png
2023-05-17 19:23:42 +05:00
Andrej730 0365c6d43b More consistent PlanLevel and SectionLevel in viewport and svg
Now it's using first vert instead of last to calculate height (same way svgwriter does it)
2023-05-17 14:50:52 +05:00
Andrej730 18b6969221 Showing decorations on activating view #3146 2023-05-17 12:35:53 +05:00
Andrej730 a1935acb3d AngleDecorator - changed edges / arc colors
Now angle annotation edges (not the arc itself) are greyed out when you're not editing them - that way they won't draw unnecessary attention. When you're in edit mode they'll appear white and the angle arc will appear blue.

Demo - https://imgur.com/a/lsgp9G4
2023-05-17 12:20:08 +05:00
Andrej730 9548c5e657 Positioning AngleDecorator text at the center of the arc
Before - https://i.imgur.com/0VxFkg9.png
After - https://i.imgur.com/ibDnlbE.png
2023-05-17 11:52:14 +05:00
Andrej730 762299124f More smoothed lines for annotations with angles and circles 2023-05-17 11:32:01 +05:00
Andrej730 f682bf5688 Added some tests for changing ifc text 2023-05-17 11:18:24 +05:00
Andrej730 f7ed3a8727 Fixed bug with annotations update #3159
toggleDecorations was interrupted because it was trying to update text for non text element
2023-05-17 10:44:26 +05:00
Andrej730 c124506e41 Fixing bug with changing text size #3159
Bug appeared after 046940f but it was there before - it was just kind of compensated by the other bug.
Because of that bug blender text size value was reupdated before saving it to pset therefore pset never received a new value.

Also added some refactor, planned to write some test to get this error covered.
2023-05-16 17:58:26 +05:00
Andrej730 273cdc6ea8 Fixed ifc text annotation preview not showing during edit #3159
Error was:

```
Traceback (most recent call last):
  File "\scripts\addons\blenderbim\bim\module\drawing\decoration.py", line 1899, in __call__
    decorator.decorate(context, obj)
  File "\scripts\addons\blenderbim\bim\module\drawing\decoration.py", line 1451, in decorate
    self.draw_text(context, obj)
  File "\scripts\addons\blenderbim\bim\module\drawing\decoration.py", line 540, in draw_text
    symbol = text_data["Symbol"]
KeyError: 'Symbol'
```
2023-05-16 16:53:38 +05:00
Andrej730 0ef6ea6bd4 Schedule Builder - some naive support for font size in text #3154 2023-05-16 16:43:39 +05:00
Andrej730 607d9a06ec Schedule Builder - support for bold and italic text in cells #3154 2023-05-16 16:31:26 +05:00
Andrej730 1b472ca5f2 Schedule builder - fixing cell alignment #3154
Noticed that it's actually not merging cell style with col style as I did before but just prioritizing cell style if it's defined
2023-05-16 15:24:39 +05:00
Andrej730 18568d6ba7 Schedule cells limit without print range to prevent system freeze
What I've found that sometimes you might get into situation (especially if .ods was created / processed in Excel) you might get a lot unnecessary columns and rows (in fact excel always seems to save 1048576x16384 table) and trying to print this kind of table results in investing a lot of RAM into it and possible system freeze.

Now there is a check if table has more than 10000 cells (number is completely made up 😁) then it would require user to define print range in the table to prevent the issue.
2023-05-16 15:16:48 +05:00
Andrej730 bfb59dd387 Scheduler builder enhancements #3154
Now it supports
1) print ranges - in svg you'll get only the part that's included in print-range.
2) children styles - sometimes cells inherit center alignment from column styles and before that commit text wouldn't be centered in svg in that case
3) repeating rows support
2023-05-16 14:44:45 +05:00
Andrej730 38cf88d5d2 Saving drawing shading styles to ifc #2991
Now shading styles are stored in ifc. It's actually stored in json file (by default it's in projects "assets/shading_styles.json") and the path to it saved in `EPset_Drawing.ShadingStyles`.
Current shading styles is stored in `EPset_Drawing.CurrentShadingStyle`.

This change could potentially cause problems but I've added some temporary fallback to make sure `EPset_Drawing.ShadingStyles` will be set to some default path and default shading styles will be copied to the project's folder.
2023-05-15 16:43:56 +05:00
Bruno Postle 7ca6f9d7a1 BlenderBIM Git clone repository operator (#3096) 2023-05-14 21:10:53 +01:00
Gorgious 5874508263 use tool module instead of local function to activate object 2023-05-13 19:57:52 +02:00
Bruno Postle 954de793dd BlenderBIM Git tagging documentation 2023-05-13 10:37:29 +01:00
Bruno Postle df74d5efbe BlenderBIM list and create git tags #3096 2023-05-13 09:57:10 +01:00
Andrej730 f7b9a7bfb5 Multiline in dimension description / suffix / prefix #3005
Also added some offset for dimension text in viewport to make it more similar to svg
2023-05-12 14:54:22 +05:00
Thomas Krijnen 63eaa88d3d #3139 Capture parsed selected simple type values 2023-05-12 10:19:15 +02:00
Andrej730 f518521ea1 Option to add prefix and suffix to dimension annotation #3005
Example - https://imgur.com/a/0NkStWm
2023-05-11 17:38:48 +05:00
Andrej730 5e1ee22bcd Ifc CSV Export template now also saves the expression #3034
Previously saved templates wouldn't work now, they need to be either recreated or modified to make them work.

Example of old template format:
`["Name", "class", "type.Name"]`

Example of new template format:
`{"expression": ".IfcDoor", "attributes": ["Name", "class", "type.Name"]}`

Note that this would work too:
`{"attributes": ["Name", "class", "type.Name"]}`
2023-05-11 14:18:51 +05:00
Andrej730 ca09ff2ef0 Not all curve annotation types were detected at the import #3090 2023-05-11 10:54:27 +05:00
Bruno Postle 8643aff800 Merge branch 'v0.7.0' of github.com:IfcOpenShell/IfcOpenShell into v0.7.0 2023-05-10 22:53:00 +01:00
Gorgious 2e88993654 Fix #3128 : RefLatitude and RefLongitude attributes now show their description on right click + add a snippet to tell the user how to format the values 2023-05-10 22:51:30 +01:00
Bruno Postle b77849d279 Report ifcmerge conflicts in pop-up #3096 2023-05-10 22:45:22 +01:00
Gorgious c7e288466f Fix #3128 : RefLatitude and RefLongitude attributes now show their description on right click + add a snippet to tell the user how to format the values 2023-05-10 21:31:19 +02:00
Kristoffer Andersen bb48d4aac1 Update meta.yaml
pin daily conda builds to occt 7.7.0
2023-05-10 20:43:22 +02:00
Gorgious56 2b99cc1e58 Fix typo in get_pset docstring 2023-05-10 16:41:19 +02:00
Andrej730 ca286f8d19 Migrating shaders to builtins to support M1 #2897
Migrated all shaders from geometry shaders to builtins (all geometry data now calculated in python before passing to shader) to make them more reliable and support Metal backend on Mac M1 (tested that it works - both annotations and gizmo).

The current downside is that there is no more custom frag shaders too - meaning we do not support dashed lines in the annotations (currently Hidden and Grid just use a bit less bright annotation color).
2023-05-10 18:19:00 +05:00
Bruno Perdigão 73a3cc2cc5 changed custom scale input 2023-05-10 09:11:09 +10:00
Bruno Postle 169709ed04 Selecting a git revision updates info box 2023-05-09 22:15:57 +01:00
Sigma Dimensions 2e746242ce Fix task json issue due to "Bad control character in string literal in JSON at position XXXX" 2023-05-09 15:43:12 +01:00
Sigma Dimensions 951b8e2b15 Convenient Pie Menu shortcut to aggregate selected objects to active object 2023-05-09 14:24:31 +01:00
Sigma Dimensions ede3edcf1e fix toggle_cost_item_parent 2023-05-09 13:25:21 +01:00
Sigma Dimensions 184c9f87b2 Fix baseline gantt chart bug when new tasks are added to the planned schedule 2023-05-09 13:03:57 +01:00
Dion Moult 0793a4602d Minor improvements to shape utility. 2023-05-09 20:51:08 +10:00
Dion Moult bb285c47dc See #2673. Bundle IfcTester for PyPI. 2023-05-09 20:49:08 +10:00
arun 4cb6fc05d6 corrected get_extrusions function 2023-05-08 20:18:57 +02:00
Kristoffer Andersen a302e5db64 add zlib to conda build dependency
zlib is now longer indirectly included from the vtk package now that we have a new occt variant novtk that does not depend on vtk
2023-05-08 14:12:03 +02:00
Bruno Postle ff21749da4 Merge branch 'v0.7.0' of github.com:IfcOpenShell/IfcOpenShell into v0.7.0 2023-05-07 13:12:22 +01:00
Bruno Postle 23b5da7670 BlenderBIM ifc file association (linux only) #2399 2023-05-07 13:08:28 +01:00
Bruno Postle c31e479f47 Rename blenderbim.sh, better initialisation #2399 2023-05-07 09:46:15 +01:00
Dion Moult 260eb31a69 Add shape utility to easily get profiles and extrusions 2023-05-07 17:32:46 +10:00
Dion Moult 1fb6dac6fb Fix failing tests in preparation for release. 2023-05-06 11:05:13 +10:00
Dion Moult 34d947c51f Fix #3084. Issue where drawings with no elements couldn't be generated. 2023-05-06 11:02:41 +10:00
Sigma Dimensions 23f7a6d5a6 fix test-related sequence bug
Fix baseline gantt chart bug
2023-05-06 00:21:57 +01:00
Sigma Dimensions b15926c20a Fix baseline gantt chart bug when new tasks are added to the planned schedule 2023-05-05 23:43:27 +01:00
Sigma Dimensions 0a7ef80ca7 BBIM4D: Enable filtering by active work schedule when retrieve tasks related to objects 2023-05-05 18:26:32 +01:00
Sigma Dimensions be08406cc1 Auto-refresh task sorting 2023-05-05 17:11:24 +01:00
Bruno Postle cc9777b1e8 Basic user documentation for BlenderBIM Git functionality (#3096) 2023-05-04 23:53:37 +01:00
Dion Moult 539b3a243b Fix fundamental bug where area and volume units were ignored on new projects. 2023-05-04 21:43:48 +10:00
Andrej730 41e58a3d46 Small addition to 8c302ed85 2023-05-04 16:00:12 +05:00
Andrej730 8c302ed85c Changed x_angle subtype to degrees
Now BIMModelProperties.x_angle stores data in radians internally but for user it still appears as degrees
2023-05-04 15:53:29 +05:00
Dion Moult dc4dc46b62 See #1676. Fix space boundary generation for IFC4 RV where openings are already subtracted from the body. 2023-05-04 20:22:29 +10:00
Dion Moult a07fa5a2c2 Accommodate invalid named units when loading IFCs. 2023-05-04 19:55:54 +10:00
Dion Moult ad9dbce003 See #3085. Don't bundle numpy as Blender already has it and it causes conflicts. 2023-05-04 19:45:04 +10:00
Andrej730 d0526d0ae5 Updating BIM Tools props on active object change #3102
Updating extrusion_depth, length and x_angle on active object change. Shouldn't be too expensive and that way it'll be more consistent with Blender UI.
2023-05-04 12:55:40 +05:00
Andrej730 75e9c3265d Fallback to abs path adding schedule rel path is not available #3106 2023-05-04 11:32:05 +05:00
Andrej730 b37705ab6e Updating drawing's size on sheet to match it's scale #2965 2023-05-04 11:25:16 +05:00
Massimo Fabbro d9d5f86a6e Now it's possible to regenerate a space that it was created automatically from walls 2023-05-04 11:37:42 +10:00
Sigma Dimensions 1f3ad95c00 remove annoying print statement, run black on cost 2023-05-03 19:46:15 +01:00
Sigma Dimensions 9e360f7efa remove annoying print statement, run black on cost 2023-05-03 19:45:01 +01:00
Sigma Dimensions 64fd6a1f52 fix copying relationships when duplicating tasks 2023-05-03 19:43:05 +01:00
Sigma Dimensions ba04df4ce3 BBIM 4D: implement human readable duration to read/edit durations.
new IOS Fuzzy Duration Parsing utility
2023-05-03 16:09:27 +01:00
Sigma Dimensions cd27a026fd fix editing null task duration values #3091 2023-05-03 16:01:58 +01:00
Dion Moult baedf71106 Minor documentation update to describe how add-ons with conflicting deps / hotkeys are incompatible. 2023-05-04 00:31:44 +10:00
Dion Moult 4f6c95b119 See #1676. Space boundary generation now accounts for voids and fills. 2023-05-04 00:31:24 +10:00
Dion Moult b1761ac393 See #1676. Space boundaries default to physical internal boundaries. 2023-05-03 21:21:55 +10:00
Dion Moult fcdf3e583f See #1676. You can now set the type of boundary class prior to generating boundaries. 2023-05-03 21:03:54 +10:00
Andrej730 2001119dff A bit more intuitive adding drawing/schedule to the sheet
Now it will detect currently active sheet even if you have sheet's drawing/titleblock/schedule selected.
2023-05-03 15:39:53 +05:00
Dion Moult 60a9d96ac8 See #1676. You can now duplicate space boundaries. 2023-05-03 20:38:09 +10:00
Andrej730 6bd177d250 Annotation Tool - always show "Add type" button
It wasn't showing if you had some objects selected which seems a bit counterintuitive - the need to deselect everything to create a new type.
2023-05-03 15:00:58 +05:00
Andrej730 1ece84e31d Fixed error during building schedule from ods
We were discarding some styles that didn't have any style properties and then we always needed to keep it in mind later on, now we just create empty dict for those.
2023-05-03 14:55:45 +05:00
Andrej730 40ea9457a8 Apply scale and rotation to ifc text symbols #3094
Before symbols attached to ifc text were not rotated / scaled if they didn't have "text-template" fields in them.
2023-05-03 14:39:43 +05:00
Andrej730 e95d91a91e Support multiline text in the schedule #3010
Before - https://i.imgur.com/gff5jo3.png
After - https://i.imgur.com/meyXBYb.png
2023-05-03 12:33:07 +05:00
Andrej730 c8fb92175f Added some (naive) text wrapping in the schedule #3010
Before - https://i.imgur.com/dJPQ788.png
After - https://i.imgur.com/T1FtI8H.png

For it to work make sure you have word wrapping in ods.

It's still very naive since it's taking constant font width which could vary depending on font type, font size, font lettering. The proper way would be is to either find some svg way to do it (couldn't find any stable one) or to render text to identify it's width (could be done with PIL but seems overkill, atleast for now).
2023-05-03 12:25:08 +05:00
Sigma Dimensions a6fb4cbfbf BBIM 4D: Enable displaying task tooltip in the gantt chart & add resource columns 2023-05-03 04:34:55 +01:00
Sigma Dimensions 30bb6d05c5 BBIM 4D: You can now visualize & print work schedule baselines with Gantt Charts 2023-05-03 04:33:16 +01:00
Sigma Dimensions 9422f804fb minor fix 2023-05-03 04:22:02 +01:00
Sigma Dimensions 415a7746be BBIM 4D Gantt: Support multiple languages, human readable durations, add convenient Print Function with different Sheet Formats,
start improving overall page style; refactor code to split js and css code away from mustache file
2023-05-02 17:27:47 +01:00
Andrej730 ee903208dc Small fix for text alignment in scheduler 2023-05-02 17:41:56 +05:00
Dion Moult f89e834fea Fix #3085. Prioritise shipped BlenderBIM Add-on packages instead of system packages to avoid dependency clashes. 2023-05-02 22:20:34 +10:00
Dion Moult e8b4335741 Minor UI cleanup. Remove align buttons from architectural tool panel. 2023-05-02 22:20:34 +10:00
Dion Moult 83010f0542 See #1676. You can now add basic space boundaries with the BIM Tool with Shift-B, either by selecting both a space and an element (e.g. wall) or selecting a space and placing the 3D cursor on a face. 2023-05-02 22:20:34 +10:00
Dion Moult 04e5f5036c See #1676. Deleting space boundaries now also removes connection geometry. 2023-05-02 22:20:34 +10:00
Andrej730 5d86d38a14 Support cells text alignment building schedule from ods #2885
Before - https://i.imgur.com/9QZ2YW2.png
After - https://i.imgur.com/M7ZHSJq.png
2023-05-02 17:04:48 +05:00
Andrej730 a82db1f622 Support merged columns building schedule from ods #2885
Before - https://i.imgur.com/p1l6ugn.png
After - https://i.imgur.com/9QZ2YW2.png
2023-05-02 16:24:30 +05:00
Andrej730 fb618d536b Keep rows height building svg schedule from ods #2885
Before - https://i.imgur.com/erMH4Ku.png
After - https://i.imgur.com/p1l6ugn.png
2023-05-02 14:56:05 +05:00
Andrej730 23f96779fa More safe adding roof modifier #3080 2023-05-02 10:38:25 +05:00
Dion Moult 7b67854654 Fix #3088. Prioritise body curves to be loaded before trying to load 2D annotations. 2023-05-02 13:11:01 +10:00
Sigma Dimensions 2e7f941465 BBIM 4D: Auto Update Resource Usage from resource tree 2023-05-02 02:47:22 +01:00
Sigma Dimensions 1c1706fde3 BBIM feature to create & view work schedule baselines 2023-05-02 02:43:54 +01:00
Sigma Dimensions ca77a895e0 IOS.API consider removing baseline tasks when deleting tasks 2023-05-02 02:31:48 +01:00
Sigma Dimensions 0f447f964e IOS.API usecase to create a work schedule baseline 2023-05-02 02:30:38 +01:00
Sigma Dimensions 2c31fc6b25 run black 2023-05-02 02:27:32 +01:00
Dion Moult 0ba79dc105 Accommodate space boundaries with no connection geometry, fetch spatial structure for IFC2X3, and fix scale bug when editing boundary profiles. 2023-05-02 10:23:54 +10:00
dependabot[bot] 52c686b656 Bump flask from 2.0.1 to 2.3.2 in /src/opencdeserver
Bumps [flask](https://github.com/pallets/flask) from 2.0.1 to 2.3.2.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/2.0.1...2.3.2)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 10:06:31 +10:00
Thomas Krijnen 64d98f1295 #2676 2023-05-01 20:16:39 +02:00
Andrej730 ceb2c4075c Option to scale symbol from ifc tag by scaling ifc text object #2946
Also added some text scaling in viewport if there is some symbol associated with text annotation to roughly visually indicate how big this thing is going to be in the svg.

Example - https://user-images.githubusercontent.com/9417531/235445393-447f3aba-8425-4da6-81d0-6bf9004fcf2b.mp4
2023-05-01 16:25:04 +05:00
Andrej730 166e7d52ec Keep text rotation for text annotation with symbols #2946 2023-05-01 16:25:04 +05:00
Dion Moult 644c2652ea See #1676. You can now toggle boundaries on or off in the BIM tool via Alt-B, with a special boundary decorator. 2023-05-01 21:19:29 +10:00
Andrej730 63b201fd95 Test command to load blend file during test scenario for debugging 2023-05-01 15:35:27 +05:00
Andrej730 d70616056c Moving decorators colors from scene to addon props #3033 2023-05-01 14:54:47 +05:00
Dion Moult a65e376886 See #1676. Tab now toggles space boundary surface profile editing. 2023-05-01 19:40:49 +10:00
Andrej730 a985c70f0c Fixed error on adding Roof modifier to non-footprint objects #3080 2023-05-01 14:03:28 +05:00
Andrej730 0d09e02e7e Fixed bug with double conversion of height/extrusion length #3073
Also fixed some tests
2023-05-01 13:46:24 +05:00
Thomas Krijnen 23e3551f27 Fix regex escape in rule_executor.py 2023-04-30 19:09:43 +02:00
Shohei Kunimatsu 885bca0865 Fix wrong attribute name usage (ValueComponent -> UnitComponent) in IfcFile::getUnit 2023-04-30 19:06:58 +02:00
Sigma Dimensions 0f874dad51 BBIM 4D features & fixes:
- feature to re-order tasks
- fixes for task sorting
- further workSchedule UI/UX improvements
- forgotten bits and bobs
2023-04-30 15:44:13 +01:00
Sigma Dimensions 107873cf6e - refactor IOS.API resource calculation to re-use shared utilities
- run black
2023-04-30 15:35:17 +01:00
Sigma Dimensions 4a8f5af7ba - BBIM 4D: features to review and edit Resource productivity data on the fly
- IOS: new resource utilitiy functions
2023-04-30 15:31:36 +01:00
Dion Moult 83084aeb7b Add profile-style (like slab editing) enable editing, edit, and disable editing operators for energy boundary surface geometry. 2023-04-30 20:57:51 +10:00
Dion Moult 51640ccc28 Fix #3030. Don't bother layerset slicing walls with a single layer. 2023-04-30 13:43:43 +10:00
Dion Moult aefbc134ea Cut merging now only applies to particular elements for the majority of cases. Drawing generation can be twice as fast due to this. 2023-04-30 13:43:43 +10:00
Massimo Fabbro 29e1d70334 Generate space from walls refactor and cleaning around 2023-04-29 22:33:19 +02:00
Massimo Fabbro 9118e529e6 Add generate space button in UI in N-Panel -> BlenderBim -> Architectural 2023-04-29 22:33:19 +02:00
Massimo Fabbro 8ee0a1611d Now it's possible to create spaces automatically from selected walls 2023-04-29 22:33:19 +02:00
Sigma Dimensions 2af4388f40 Fix duplicate task logic in IOS.API 2023-04-29 13:53:04 +01:00
Dion Moult 93a2d18ea6 Filter elements visible in the camera view. Drawing generation is now significantly faster on larger projects (e.g. 24s down to 10s for a portion of the Revit sample project) 2023-04-29 16:33:44 +10:00
Dion Moult fc49859ea4 Fallback to unmerged polygons if merging fails. More investigation needed. 2023-04-29 16:30:40 +10:00
Dion Moult c0ac9cb380 Viewport layerset slicing now uses a cache for speed. 2023-04-28 22:46:49 +10:00
Andrej730 d5cc6c3c8e Fixed double conversion in bim tool props after b4b6404
No more 1000000 and 3000000 mm values
2023-04-28 17:32:19 +05:00
Andrej730 9b22b5000f Added support for different railing cap types
Very similar to this - https://i.imgur.com/SNyvfgh.png
2023-04-28 17:24:41 +05:00
Dion Moult 3b69a4cc78 Fix bug where numerical tolerance caused certain objects to be unnecessarily updated. 2023-04-28 22:15:09 +10:00
Dion Moult adf54efcc5 Fix bug in cut decorator layersets where walls could be joined to odd non-layered things. 2023-04-28 22:14:26 +10:00
Dion Moult f6962eb58e Fix #3053. Bug where very thin meshes (<1mm) couldn't be reverse engineered into extrusions. 2023-04-28 21:05:13 +10:00
Andrej730 11601d6532 Fixed bug with wrong position of support in wall mounted railing
The problem was that that support's disk was not rotated according to the railing path.
2023-04-28 11:43:15 +05:00
Sigma Dimensions be2131d62c BBIM 4D: Auto-refresh task re-ordering 2023-04-27 13:58:08 +01:00
Dion Moult 3ffbf46ac2 Fix #3066. Regression crash when deleting openings. 2023-04-27 22:24:12 +10:00
Sigma Dimensions 3943107eec forgotten core functions & run black 2023-04-27 13:05:51 +01:00
Sigma Dimensions 94e3f75341 Sequence Tools clean-up 2023-04-27 13:03:32 +01:00
Sigma Dimensions 8bc8b950e7 BBIM 4D: Features to select a Work Schedule's assigned / unassigned products 2023-04-27 12:55:31 +01:00
Sigma Dimensions 05a95ac666 Work Schedule Panel UX improvement 2023-04-27 12:53:27 +01:00
Sigma Dimensions f016c803e4 Fix schedule task sorting 2023-04-27 12:49:27 +01:00
Dion Moult bac0dd37fa Fix #3052. Deep deletion of large geometries is now thousands of times faster. 2023-04-27 20:15:17 +10:00
Bruno Postle 75a37cf737 Fix crash when switching between git revisions 2023-04-26 23:50:36 +01:00
Bruno Postle bb7e9c4610 Fix check for invalid Git branch name 2023-04-26 22:25:27 +01:00
Andrej730 ee2f18349f WALL_MOUNTED_HANDRAIL type for Railing modifier
Added WALL_MOUNTED_HANDRAIL type for railing modifier. It's still a bit work in progress - still need to add support for different railing termination types.

Here's the short demonstration - https://user-images.githubusercontent.com/9417531/234582621-6c6f948b-9cdc-4be6-b380-17ddbf5803bf.mp4
2023-04-26 18:04:39 +05:00
Dion Moult 8829a3cbe9 See #1227. Minor fix. 2023-04-26 22:24:37 +10:00
Dion Moult b210e39c7e See #1227. Experimental viewport layerset visualisation. 2023-04-26 22:10:34 +10:00
Bruno Postle 4d4500f061 Fix some refresh glitches in IFC Git panel 2023-04-26 00:07:22 +01:00
Thomas Krijnen 79860a0c04 Fix iterator::get() invalid cast on nullptr 2023-04-25 21:00:01 +02:00
Bruno Postle d53fcdc616 Format ifcgit code with black 2023-04-25 07:30:35 +01:00
Dion Moult 5e6a094ac6 Fix #3046. Renaming drawings now updates all drawing references on sheets. 2023-04-24 22:41:38 +10:00
Andrej730 757bf4e916 Fixing error on using bim.override_mode_set_edit with no active object
Error was:
  File "\addons\blenderbim\bim\module\geometry\operator.py", line 775, in _execute
    obj.select_set(True)
AttributeError: 'NoneType' object has no attribute 'select_set'
2023-04-24 11:17:08 +05:00
Andrej730 7bb57b3ab9 Fixed blurred text with background after bfbced3
before commit - https://user-images.githubusercontent.com/9417531/233907917-f86ad10b-0227-4180-9488-a8b71a00f099.png
after commit https://user-images.githubusercontent.com/9417531/233907920-d100c73a-e206-42fd-bb41-f7257ea6f98c.png

Tested it on firefox too
2023-04-24 10:33:38 +05:00
Dion Moult cb22b5804d Fix #3055. Get paths using forward slashes for platform compatibility. 2023-04-24 13:11:42 +10:00
Dion Moult bfbced3859 Fix #3051. Text background filter now applied on <text> element to make it work on Firefox. 2023-04-24 12:58:36 +10:00
Dion Moult c090ee9b83 Fix #3040. View title template variables now have access to sheet attributes prefixed with "Sheet". 2023-04-23 22:04:49 +10:00
Dion Moult b6caf069d0 Fix #3001. User can now specify join criteria in drawings. Only elements where all the criteria have the same values are merged. 2023-04-23 21:32:00 +10:00
Dion Moult 5b4449eea0 Fix #3054. Edit sheet is now implemented for drawings, schedules, and titleblocks. 2023-04-23 17:49:51 +10:00
Bruno Postle 7dc17a3653 Include git, gitdb and smmp libs in blenderbim zip 2023-04-23 08:35:39 +01:00
Bruno Postle 598bf799de Install GitPython *before* removing the working folder 2023-04-23 08:12:49 +01:00
Bruno Postle 4774a37d48 Add GitPython dependency 2023-04-23 08:03:19 +01:00
Dion Moult d9a1e6f4b1 New default patterns for stack and stretcher bond tiles and floorboards. 2023-04-23 12:44:35 +10:00
Bruno Perdigão 72dae8e9ad applyed the patch by Bruno Postle 2023-04-23 12:05:57 +10:00
Bruno Perdigão b2d7fb9443 changed imports to integrate with blenderbim 2023-04-23 12:05:57 +10:00
Bruno Perdigão bf945e36bd initial commit 2023-04-23 12:05:57 +10:00
Dion Moult 2bcfe93dd2 See #3002. Spaces are now managed separately so that they don't conflict with projection polygon merging and raycasting. 2023-04-22 23:59:33 +10:00
Dion Moult 195ef743c6 See #3002. Experimental SVGFill approach to polygon merging. 2023-04-22 13:05:42 +10:00
Thomas Krijnen 8478eb9aa0 Update draw.py 2023-04-21 16:29:04 +02:00
Andrej730 47f57d20cd Fixed couple bugs in furniture library
1) last polyline point was failing on Consecutive rule causing validation errors
2) Fixed wrong ifc class for dishwasher (was used occurence class instead of type)
2023-04-21 18:24:32 +05:00
Dion Moult 8f8eb06d6b See #3002. Experimental shapely approach to polygon merging for semantic projection elements. 2023-04-21 22:33:08 +10:00
Andrej730 7d6803f325 Roof modifier - remove redundant context fill causing visual artifacts 2023-04-21 16:49:44 +05:00
Andrej730 f9b7a8b92b Roof modifier - removing bottom chord if angle = 90 degrees
This - https://i.imgur.com/75AmYGI.png
instead of https://community.osarch.org/uploads/editor/yp/zcaqxx9b33wu.png
2023-04-21 16:49:44 +05:00
Andrej730 7ee0c047e5 Roof Modifier - separating vertices on defining gable roof angle
Added option (which is activated by default) - when you set gable roof angle for some edge it will duplicate the top vertex instead of just moving which allows you to do shape like this - https://imgur.com/a/OEFZ4pw

Previously you would get something like this in that case - https://community.osarch.org/uploads/editor/ap/hlt70rbw5r1l.png
2023-04-21 16:49:44 +05:00
Andrej730 bfbfe17644 OverrideDelete - remove objects with X if they are not related to ifc
It was a bit frustraiting when you added a cube and can't just get rid of it with X hotkey 😅
2023-04-20 17:15:17 +05:00
Andrej730 046940f949 Fixed error in disabling text exiting after deleting text literal 2023-04-20 14:27:37 +05:00
Dion Moult 2950ddcf4f Fix validation error where IfcURIReference cannot be used as a property data type :( 2023-04-20 18:06:35 +10:00
Dion Moult 3d441b4ad3 Fix #3038. Fix #3039. Selector should default to none instead for throwing errors if the query doesn't have a result. 2023-04-20 17:41:52 +10:00
Dion Moult caa5e8983b Fix #3021. IfcSpatialElements are included in drawings by default. 2023-04-20 17:34:24 +10:00
Andrej 59b7944d8e Merge pull request #3032 from IfcOpenShell/quantities_project_units
Converting quantities to project units to fix #3025
2023-04-20 11:03:12 +05:00
Andrej730 648eb8fdd1 Converting to project units inside QtoCalculator.guess_quantity
Also added some error message if `calculate_quantity` failed to calculate a quantity
2023-04-20 11:01:38 +05:00
Andrej730 f160516772 tool.Qto.convert_to_project_units 2023-04-20 10:32:36 +05:00
Andrej730 4beb7780f8 bim.calculate_quantity - remove convertion part
now the convertion already happens in QtoCalculator.calculate_quantity
2023-04-20 10:32:24 +05:00
Kristoffer Andersen d44b6d40e9 pin lief version for conda build 2023-04-20 06:48:44 +02:00
Kristoffer Andersen 8fd9f5a8cb Add conda to conda daily build trigger path 2023-04-20 06:43:31 +02:00
Kristoffer Andersen 414af2f55e Change conda lief version 2023-04-20 06:40:44 +02:00
Kristoffer Andersen 8624be6bcf Fix conda env 2023-04-20 06:36:10 +02:00
Andrej730 4aa26b613b test_qto.py black format 2023-04-19 19:05:11 +05:00
Andrej730 57cb062d48 Tests for calculating quantities for prefix and imperial project units 2023-04-19 19:04:05 +05:00
Andrej730 b4b6404b65 Added DISTANCE subtype to BIM Tool Extrusion Depth and Length
In BIM Tool it looks like this right now - https://i.imgur.com/JWVPssg.png (note the units)
Previously it was displaying value like this - https://i.imgur.com/244aYTN.png

The benefit is that you can specify other units in that kind of property and it will automatically convert to current project's unit. 

For example if you have millimeters as project's unit you can still type "10m" instead of "5000" and it will automatically convert it to 5000mm. 
Or type in inches like 5" 11'.
2023-04-19 18:03:26 +05:00
Andrej730 989dd2be50 qto_calculator.py black format 2023-04-19 17:04:15 +05:00
Andrej730 50b8baddec Update QtoCalculator to convert to project units at the end
Before this commit it was calculating all values in meters not taking into account actual project units.
2023-04-19 17:03:32 +05:00
Andrej730 2e00c3db0b Update viewport on bim.activate_model
To see the changed context right away in the viewport
2023-04-19 12:12:11 +05:00
Andrej730 232260787e Fixed bug with wrong text value in viewport on canceling text editing
Actual text was replacing with "TEXT" default value if you cancel text editing instead of applying changes
2023-04-19 11:37:10 +05:00
Andrej730 54054c4aee Fixed bug in get_object_bounding_box #3023 2023-04-19 11:27:45 +05:00
arun 1a7843a6b5 Nesting added to util.get_decomposition function 2023-04-19 15:46:51 +10:00
Sigma Dimensions ed4ba4d0d3 fix "cost_item quantity updates" bug when editing a QTO 2023-04-19 01:01:44 +00:00
htlcnn 849d6118d0 fix EditBcfTopic and EditBcfTopicName 2023-04-19 09:23:50 +10:00
Andrej730 364138d408 CutDecorator color connected to preferences too #2987 2023-04-18 18:13:04 +05:00
Dion Moult 32c8da06ca New default triangle, hexagon, capsule, circle, and space tag symbols 2023-04-18 22:32:09 +10:00
Andrej730 2df4c5825f Added some decorator colors to addon preferences #2987
For ProfileDecorator (editing profiles, roof preview) and DecorationsHandler (openings).
Still need to add CutDecorator colors to preferences
2023-04-18 17:29:07 +05:00
Andrej730 527cbc3ae0 Some descriptions for EPset_Drawing 2023-04-18 16:59:07 +05:00
Andrej730 4fee8744d6 Fixed text annotation rotation in viewport #3017
Fixed text annotation rotation in viewport for the views rotated by multipel axis.
Changed text direction calculation to be the same in both viewport and svg.
2023-04-18 16:59:07 +05:00
Thomas Krijnen 8f8862d23d get_mappeditem_transformation() 2023-04-18 13:17:20 +02:00
Thomas Krijnen 836f36fd8e Add util.placement.get_cartesiantransformationoperator3d() 2023-04-18 13:15:13 +02:00
Thomas Krijnen a1326cb5ed Normalize vectors in a2p() 2023-04-18 13:13:29 +02:00
Vukas Pajic 4bfda8851c Update failure reason #3018 2023-04-18 13:12:24 +02:00
Andrej730 f02f15cbfb unsuppress zero inches in formatting distance #3011
Added option to suppress zero inches in the dimension annotation text through SuppressZeroInches property of BBIM_Dimension property set.
Previously by default suppressing zero inches was enabled. Now by default it is disabled.

SupressZeroInches On  - https://i.imgur.com/nrhELnA.png
SupprezZeroInches Off - https://i.imgur.com/gIuO2GW.png
2023-04-18 14:17:40 +05:00
Dion Moult 30182684d5 Fix bug where you could save geometry with no data (no vertices / splines) which is invalid. 2023-04-18 18:10:01 +10:00
Dion Moult 7df80af30b Fix #2913. Bug where properties with multiple inverses were not correctly purged. 2023-04-18 18:08:24 +10:00
Dion Moult 6b2e867107 Fix #2916. Bug where joining swept solids didn't merge styles correctly. 2023-04-18 18:07:44 +10:00
Vukas Pajic d333090b09 cleanup 2023-04-18 09:17:23 +10:00
Vukas Pajic 8ae7763ac5 added new tests for case where spec has no requirements 2023-04-18 09:17:23 +10:00
Andrej730 51ac86be79 Fixed bug in bim.select_assigned_product
It was trying to call method `Drawingcls.get_active_object()` that didn't exist
2023-04-17 14:47:11 +05:00
Andrej730 552078c8a2 TEXT_LEADERS BoxAlignment, FontSize, multiline in viewport preview #3008
Moved code for drawing text in viewport to a separate reusable method `draw_text` in BaseDecorator.
2023-04-17 11:21:07 +05:00
Dion Moult 4b4ede733f Add support for loading IfcProxy 2023-04-17 10:37:30 +10:00
Dion Moult d07e8bc747 Add support for editing ref latitude/longitude 2023-04-17 10:14:22 +10:00
Massimo Fabbro 8850d78e5a Small fix 2023-04-17 09:25:21 +10:00
Massimo Fabbro 4fbf4e7d42 Now it's possible to specify the digits number in a drawing. Fix #2993 2023-04-17 09:25:21 +10:00
Ryan Schultz d6e1a670b9 Library - changed to correct class 2023-04-17 09:24:35 +10:00
Dion Moult 1a32c8827e Fix #3003. 2023-04-17 09:11:33 +10:00
Dion Moult 784b5156df Fix #2975. Fix bug where imperial projects still created drawings with metric scales by default. 2023-04-16 23:18:22 +10:00
Dion Moult 6e3336afb1 See #2975. Fix bug where custom scales were not loaded correctly. 2023-04-16 23:17:56 +10:00
Dion Moult d0ddee3623 Fix bug where changing object visibility didn't first check for view layer existence. 2023-04-16 21:50:58 +10:00
Ryan Schultz 9cf55033d4 Fix #2989 2023-04-16 08:05:05 +10:00
Dion Moult 7371efde17 Fix #2980. Minor cleanup to polish array panel UI. 2023-04-15 16:01:50 +10:00
Dion Moult 156269a53f Fix #2988. Imperial dimensions in viewport are now split between feet and inches. 2023-04-15 15:33:01 +10:00
Ryan Schultz ed7e5fb482 Fix #2990 2023-04-14 15:57:36 -05:00
Andrej730 2e973a4591 Fixed bugs with furniture library toilets and basins #2976
Bug was introduced in cf6acd5 when `shape_builder.get_rectangle_coords` started returning coords in counter-clockwise order instead of clockwise.
2023-04-14 19:07:38 +05:00
Andrej730 f1bd82d301 Dimension description in viewport/option to hide the measurements #2918
same thing for diameter annotations since they are just reusing dimension annotations

+ some refactor along the way
2023-04-14 17:52:54 +05:00
Dion Moult f51bfa314d Fix #2986. Reimplement Metadata property of EPset_Drawing to include arbitrary metadata as CSS classes. 2023-04-14 20:24:02 +10:00
Dion Moult 7b3410c7b1 Fix #2985. Purge obsolete vector style feature. 2023-04-14 20:04:33 +10:00
Dion Moult 6b0e7d51b1 Fix #2979. Batch drawling unselected and selected cut lines. 2023-04-14 18:24:01 +10:00
Andrej730 4e5659efad Annotation Tool
Added Annotation Tool that allows you create annotation types and their occurences. It will also allow us to get rid of "Annotation" panel in N-panel.

I've recorded bunch of short videos to demonstrate the features:

- bulk tagging - currently works only for "Text" and "Stair arrow" type of annotations, adds annotations to all selected objects, automatically assigns products to the annotations
https://user-images.githubusercontent.com/9417531/231968358-28cbb762-3349-470a-beef-d1ab21882769.mp4

- creating annotation type with representation - all occurences will share the same representation which makes bulk tagging really powerful if you use variables like {{PredefinedType}}, {{GlobalId}}, {{Name}}, {{Description}}, {{ObjectType}}, {{Tag}}

https://user-images.githubusercontent.com/9417531/231970500-333514c6-6406-4ef5-a9e7-fddfcc9a2436.mp4

- creating annotation type without representation - it allows occurences to have unique text or line geometry but still share the same classes from inherited property set

Examples:
  creating text type without representation to create title case annotations
  https://user-images.githubusercontent.com/9417531/231969361-bda5f924-a8c8-4f5a-ba61-461aa7101f73.mp4

  creating type for oblique dimension annotations
  https://user-images.githubusercontent.com/9417531/231969902-38e8c3f4-45a6-4c98-bba4-2956288ce10a.mp4

- readjusting - if you created some annotations using bulk tagging but the products were changed / moved afterwards now you can select those annotations and "readjust" them according to new product's position / measurements
https://user-images.githubusercontent.com/9417531/231968975-ee8d6589-60ee-4575-9be2-b0ce68d43ffa.mp4

PS In this commit I've also moved all icons to 1 .blend file and added instructions how to regenerate them.
2023-04-14 12:40:53 +05:00
Dion Moult 66f10adde8 Fix #2980. Array deletion now uses delete tool. Delete moved into tool so it can be used by other functions. 2023-04-14 09:56:55 +10:00
Dion Moult 459c4d7fcc See #2978. Fix crash upon drawing deletion. 2023-04-14 09:36:51 +10:00
Dion Moult 03d9efb790 Fix #2955. Drawings can now set a precision. 2023-04-13 22:20:18 +10:00
Dion Moult 33bd6099ee Fix #2971. Only update placement if object actually moved. 2023-04-13 21:56:32 +10:00
Dion Moult 850a1d326b Purge old code from timer-based type browser system 2023-04-13 21:39:54 +10:00
Thomas Krijnen f0bb19d48d Fixes to validation of selected simple type / enum 2023-04-13 13:16:48 +02:00
Dion Moult a56eac0131 Minor fix 2023-04-13 18:48:20 +10:00
Dion Moult d3201809ab Fix #2968. Deletions are no longer postponed. Should fix or reveal a lot of sync errors. 2023-04-13 18:38:28 +10:00
Dion Moult 3628a0e241 Fix bug where switching representations didn't update the material checksum, leading to unnecessary material syncs at export time. 2023-04-13 18:15:28 +10:00
Dion Moult 07badd3df5 Styles are applied per mesh data now (potentially dangerous). Fix crash when switching to representation which has styles from an unstyled mesh. 2023-04-13 16:10:00 +10:00
Dion Moult f63091ce05 Fix #2974. Type property sets are now properly copied. 2023-04-13 14:08:02 +10:00
Dion Moult 617b2978c0 New activate model operator to switch back to a MODEL_VIEW target view subcontext 2023-04-12 21:27:43 +10:00
Dion Moult 364e96ad1e Activating a drawing now automatically switches to the preferred target view representation of all elements 2023-04-12 21:27:43 +10:00
Dion Moult 9170e5ca65 New "cut decorator" that draws cut lines in drawings. 2023-04-12 21:27:43 +10:00
Dion Moult cbe71f221c Only activate drawing styles if underlay enabled, and default to default Blender styles to prevent confusion 2023-04-12 21:27:43 +10:00
Dion Moult c039c01407 Regenerating fills now maintains the active representation 2023-04-12 21:27:43 +10:00
Dion Moult 629ba41f5f Only allow drawing / sheet / schedule creation once the IFC is saved to enforce correct relative paths. 2023-04-12 21:27:43 +10:00
Andrej730 198fa67cc1 Focus on text field on edit Ifc Text with BIM Tool hotkey (once again)
This option was here before but it was accidentally discarded after f7181aa
2023-04-12 11:51:50 +05:00
CyrilWaechter e7830e3d55 Fix #2964 2023-04-11 22:03:26 +02:00
Andrej730 90bfb25f41 restoring selection on bim.override_mode_set_edit if nothing worked
it was a bit confusing when you're trying to edit some object, you get error message but you also lose object selection
2023-04-11 19:17:03 +05:00
Andrej730 037cb00caa Fixed bug with roof created in projects with milimeters units
the problem was that operators were converting angle using SI and angle was set to 10000
2023-04-11 19:17:03 +05:00
Andrej730 f002124c38 Fixed error in PLAN_LEVEL elevation value in printed svgs #2961
Also added more precision to inPerFoot in helper.format_distance to avoid this a bit annoying precision problem where format function keeps adding 1/256"

Without precision - https://i.imgur.com/D9WYjvJ.png
With precision - https://i.imgur.com/3XgOFSH.png
2023-04-11 19:06:59 +05:00
Andrej730 ac42f9f599 Changed roof preview colors and it's now transparent
Changed roof preview colors to the same as openings
2023-04-11 19:06:58 +05:00
Andrej730 88d4640d3f fixed mistake in tool.Blender.apply_bmesh
was resulting in error when you apply roof path
2023-04-11 17:30:29 +05:00
Andrej730 d2da01041c Added checkboxes to drawing list to mark multiple selected drawings
Checkboxes affect the drawings that will be used when you shift click "Create drawing", "Open Drawing", "Remove Drawing". Previously those opeartors were always applying the action to all drawings.

Also added option to remove selected drawings with shift+click to "Remove Drawing" and added new operator "Select all drawings" to select drawings in one click (you can shift click it to delsect all drawings).

Example - https://i.imgur.com/GAGghu5.png
2023-04-11 17:14:10 +05:00
Dion Moult 75c17b820f Fix bug where invalidly mapped representations shouldn't be edited. 2023-04-11 21:50:28 +10:00
Thomas Krijnen 2dc4bbf8cd Support rule compilation and execution on latebound schema 2023-04-11 13:24:32 +02:00
Thomas Krijnen c9a5abc3be Some small fixes for rule compliance in template.py 2023-04-11 09:46:50 +02:00
Thomas Krijnen 7ea468a9a6 Update build-all.py 2023-04-11 08:47:46 +02:00
Dion Moult c6223520e0 Fix #2947. Embarrassing bug where slabs didn't consider the total thickness. 2023-04-11 16:24:39 +10:00
Dion Moult 176cbf9861 Fix #2948. Bug where IFC array tool didn't track undo properly causing crashes. 2023-04-11 15:21:04 +10:00
Dion Moult 00315a6f2d See #2516. Titleblocks dropdown now also shows project titleblocks. 2023-04-11 14:08:48 +10:00
Dion Moult 2145b2f8e2 Fix #2955. You can now store default paths in a project pset. 2023-04-11 14:06:31 +10:00
Dion Moult 31155e7bc9 See #2516. Fix issue where getting sheet layout URIs were not explicit. 2023-04-11 12:26:05 +10:00
Trashman247 2d07208d0f Reformat parametrized "Save" in IFC project (again) 2023-04-11 10:26:48 +10:00
Trashman247 35ad7e16c6 Reformat parametrized "Save" in IFC project 2023-04-11 10:26:48 +10:00
Trashman247 27c52fe6d5 Add dynamic tool tip for parametrized "Save" in IFC project 2023-04-11 10:26:48 +10:00
Andrej e153f63a23 Merge pull request #2962 from maxfb87/fix_bug
Fix minor bug
2023-04-11 01:23:58 +05:00
Andrej 2cbbc360c0 Merge branch 'v0.7.0' into fix_bug 2023-04-11 01:23:27 +05:00
Thomas Krijnen 8a4a42777f Property transfer ownership of schema from py to c++ upon register_schema() 2023-04-10 22:01:53 +02:00
Thomas Krijnen 352d6b5ef9 Attempt load schema from cwd (IS THIS DANGEROUS?) 2023-04-10 20:31:56 +02:00
Thomas Krijnen cc49b0efdc Don't fail on unmapped attribute types (IFC4.4) 2023-04-10 20:17:26 +02:00
Andrej730 e71ee988bf Fixed error on disabling BlenderBIM addon
Error was occuring because macros doesn't have `is_registered` attribute.

Error: Traceback (most recent call last):
  File "C:\Software\Steam\steamapps\common\Blender\3.5\scripts\modules\addon_utils.py", line 421, in disable
    mod.unregister()
  File "\scripts\addons\blenderbim\__init__.py", line 45, in unregister
    blenderbim.bim.unregister()
  File "\scripts\addons\blenderbim\bim\__init__.py", line 192, in unregister
    if cls.is_registered is not False:
AttributeError: type object 'OverrideDuplicateMoveMacro' has no attribute 'is_registered'

Still getting some other error on disabling the addon, seems to happen due ongoing drawing system restructure.
Error: Traceback (most recent call last):
  File "C:\Software\Steam\steamapps\common\Blender\3.5\scripts\modules\addon_utils.py", line 421, in disable
    mod.unregister()
  File "\addons\blenderbim\__init__.py", line 45, in unregister
    blenderbim.bim.unregister()
  File "\addons\blenderbim\bim\__init__.py", line 177, in unregister
    if bpy.data.scenes['Scene'].BIMProperties.module_visibility['drawing'].is_visible:
KeyError: 'bpy_prop_collection[key]: key "drawing" not found'
2023-04-10 18:05:40 +05:00
Dion Moult 937a5b2c2d Fix #2516. Add/build/remove/view/rename/copy sheet/drawing/schedule now all references and updates user configurable relative paths. 2023-04-10 22:30:33 +10:00
Dion Moult 92221e19c3 Fix bug where unassigning a document was too aggressive and deleted relationships where it shouldn't. 2023-04-10 22:30:33 +10:00
CyrilWaechter e5c920864c Add ifczip and ifcxml to x-ifc mime-type 2023-04-10 11:43:26 +02:00
Nathan Hild 6f63682bdf Correct tooltip messages for enabling and disabling edit buttons 2023-04-10 10:28:10 +02:00
Andrej730 7623eddcd7 Including/Excluding IfcAnnotations from drawing #2903
Including or excluding elements from the drawing using EPset_Drawing.Include/Exclude now also works for IfcAnnotation elements. Both in viewport (on "activate view") and on svg print.

Related change - annotation decorations are now hidden in viewport if their object is hidden.
2023-04-10 12:37:39 +05:00
Andrej730 d1dee1e908 Fixed errors from 9bca705 2023-04-10 12:30:51 +05:00
Andrej730 8b302f8d21 Make BIM Tool alignment buttons clickable and some hotkeys code cleanup 2023-04-10 11:22:17 +05:00
Dion Moult dfeebd6b6b Fix #2960. 2023-04-10 09:01:34 +10:00
Massimo Fabbro df53ce9f6e Better fix about cls without is_registered method 2023-04-09 22:33:37 +02:00
Massimo Fabbro 9bb2c00b6d Fix bug related to operators without is_registered method 2023-04-09 21:58:11 +02:00
Dion Moult 641253c4c6 Document list now shows description and locations instead of names as names are inherited. 2023-04-09 23:03:10 +10:00
Dion Moult 6ce49b7130 See #2516. References to titleblocks, layouts, and published sheets are now explicitly stored. Titleblock paths are now configurable. Generated filenames are sanitised. 2023-04-09 23:03:10 +10:00
Andrej730 804ad0cece Prevent flickering for SectionLevel and Grid decorators 2023-04-09 18:03:08 +05:00
Dion Moult 6c60d14c05 Fix #2959. Oversight when disabling mesh edit mode. Edit grid axes should be allowed. 2023-04-09 12:52:10 +10:00
Dion Moult def2d2bcc9 See #2516. WARNING: breaking changes! Restructure drawing system to use relative paths based on IfcDocumentReference Locations. 2023-04-08 21:59:53 +10:00
Andrej730 9bca705dc3 Solved producing orphan objects data on drawing deletion 2023-04-08 11:37:35 +05:00
Andrej730 2dcc271dff Updating sheet name from UI #2950 2023-04-07 19:06:41 +05:00
Thomas Krijnen 33415fa1af #2685 Fix AttributeError 2023-04-07 16:02:11 +02:00
Andrej730 10315e0e29 annotation and gizmo shaders rework for smoothed lines without bgl #2897
Reworked annotation and gizmo shaders to work without `bgl` and support smooth lines.

Moved LIB_GLSL and DEF_GLSL to shaders module since it's basically the same code and this way it'll be easier to keep track of it.
2023-04-07 17:36:58 +05:00
Dion Moult f321cc81c8 Minor improvement to add error message when mirror elements called without a mirror axis. 2023-04-07 20:07:38 +10:00
Bruno Perdigão 68b685f580 minor fix, sets a minimum to 'count' 2023-04-07 19:58:33 +10:00
Bruno Perdigão c87c79b937 Fix #2937. IFC Array now have the option to sync children 2023-04-07 19:58:33 +10:00
Sigma Dimensions de3dfcdc43 BBIM 4D Features to:
- Display nested task resources/task inputs of the active task
- Show list of tasks related to the current object selection
- Highlight, in the WorkSchedule panel, tasks  related to the current object selection
2023-04-07 04:33:56 +02:00
Kristoffer Andersen 657ddc0fa1 conda daily pin occt version 2023-04-06 21:38:42 +02:00
Dion Moult 1da01489f1 Fix #2935. Duplicating objects clear any parametric array relationships. 2023-04-06 21:18:36 +10:00
Massimo Fabbro 64a27614ff Fix bug #2825 2023-04-06 21:12:18 +10:00
Dion Moult 6c5acfc8bb Fix #2945. Selector should expand enumerated list properties so that you can match any of them. 2023-04-06 19:21:22 +10:00
Andrej730 884ee5b587 Warning when user loading sheets and some svgs are missing
Added this warning because missing svgs can lead to errors later on.
2023-04-06 13:51:12 +05:00
Andrej730 c2320a3c1e ChangeSheetTitleBlock operator
Added operator to change title block of currently selected sheet, it's located right after "Add sheet" button.
The way it works - you select the sheet, select the desired titleblock from dropdown menu and it overrides current titleblock from the sheet with the new one.
2023-04-06 13:51:07 +05:00
Bruno Perdigão ab23030051 ifc array modifier: get cursor position in relation to the object local axes 2023-04-06 10:45:47 +10:00
Bruno Perdigão 699c692f6c ifc array modifier: adds the option to get the dimensions from the 3d cursor 2023-04-06 10:45:47 +10:00
Bruno Perdigão 0c85e26950 ifc array modifier: bugfix, prevent divider from being zero. 2023-04-06 10:45:35 +10:00
Bruno Perdigão 2cd7e737cd ifc array modifier: adds the option to choose between "total" and "increment" as dimension input 2023-04-06 10:45:35 +10:00
Gorgious56 a1adbe2b34 You can now change the section line decorator width in the UI 2023-04-06 09:37:01 +10:00
Gorgious56 a144c2b7ea Add new shader to display the section as a thick line on the mesh 2023-04-06 09:37:01 +10:00
Gorgious56 201c056ffa Add new decorator utility to the Compare node group 2023-04-06 09:37:01 +10:00
Andrej730 2e95168610 Title case naming for operators 2023-04-05 17:49:58 +05:00
Andrej730 b18c05cbb9 Open all drawings at once with shift+click (similar to print all)
Also added filepath check to make sure all drawings were printed first.
2023-04-05 17:47:27 +05:00
Andrej730 102a4c6110 Title case naming for operators 2023-04-05 17:47:27 +05:00
Dion Moult b6c0ef3d19 Fix #2936. Unassigning a type now also unmaps representations. 2023-04-05 22:33:11 +10:00
Andrej730 ea3065dbc2 Sync viewport visibility based on EPset_Drawing/Include Exclude #2613
It's not real time, it's triggered on using "Activate view" button in "Drawings" section.
2023-04-05 16:34:43 +05:00
Gorgious56 534c3ad329 Fix temporary section cutaway socket inputs/outputs not initializing properly
Related to #2547
2023-04-05 13:30:35 +02:00
Dion Moult 90a7d807a1 Fix #2938. Unlinked objects should no longer synchronise edits after they've changed. 2023-04-05 21:07:44 +10:00
Dion Moult 4baafb5e2f See #2938. Fix issue where unlinking didn't consider other users of the object's data or material. 2023-04-05 20:58:24 +10:00
Andrej730 f911765cdb Support for SECTION_LEVEL annotations description in viewport
Example - https://i.imgur.com/ATF9Fp6.png
(similar to svg)
2023-04-05 14:44:27 +05:00
Andrej730 d0a36c79d5 Small fix 2023-04-05 13:10:41 +05:00
Andrej730 ffea5320a0 Background for Ifc Text annotations in SVG
Added option to fill background of Ifc Text annotation with white color.

To make it work need to add "fill-bg" class to EPset_Annotation - https://i.imgur.com/ig2EhkQ.png.

Result - https://i.imgur.com/mq4hzAM.png
2023-04-05 12:38:36 +05:00
Andrej730 0b54e41a40 Small editing assigned product UI fix
Previously checkmark didn't worked at all if the existing and new product were the same.
2023-04-04 19:02:07 +05:00
Andrej730 26c67f770a Sliding doors - more consistent 2d repr between door types #2919 2023-04-04 18:53:59 +05:00
Andrej730 f6623db0e6 Sliding doors - moved annotation arrow to Annotation/PLAN_VIEW #2919 2023-04-04 18:38:44 +05:00
Dion Moult d7844ee8e8 Fix #2114. Duplicate overrides are now defined as macros which means that repeating last function now works. 2023-04-04 22:01:45 +10:00
Andrej730 1c8970bbf2 removed redundant parts from generate_steel_profiles_library.py
removed never used methods and contexts
2023-04-04 14:23:21 +05:00
Dion Moult eb70849a30 Fix #2898. Explicitly check for changed active material in material UI panels. 2023-04-04 17:04:32 +10:00
Andrej730 77ce3c9067 Fixed ifc validation errors for generated openings #2925
Now ELEVATION_VIEW 3d curves converted to 2d to be extruded later on to create opening representation.
2023-04-04 11:18:29 +05:00
Dion Moult 56cd226a27 Deprecate mode subscriptiosn of profiles and walls 2023-04-04 13:59:10 +10:00
Dion Moult a1acdc0977 See #2881. Allow indices in the selector instead of relying on external evaluations. 2023-04-04 09:58:23 +10:00
Dion Moult 1a624c957b See #2916. Minor fix. 2023-04-04 09:43:58 +10:00
Andrej730 1c9eeb2aca Revert "Fixed ifc validation errors for generated openings #2925"
This reverts commit 66a53b486a.
2023-04-03 23:04:27 +05:00
Gorgious56 45f06eeea7 Interface now displays a hint when trying to edit a non-mesh-like object
& Fix case where the active object would go into edit mode even if not mesh-like when multiple objects were selected
2023-04-03 17:55:44 +02:00
Andrej730 66a53b486a Fixed ifc validation errors for generated openings #2925 2023-04-03 19:53:43 +05:00
Andrej730 fc45f5b48f Fixed ifc validation errors for furniture library #2925
Fixed bunch of validation errors with furniture library:

- IfcSpaceType PredefinedType wasn't optional
`<attribute PredefinedType: <enumeration IfcSpaceTypeEnum: (EXTERNAL, GFA, INTERNAL, NOTDEFINED, PARKING, SPACE, USERDEFINED)>> Not optional`

- some object had 0.0 depth extrusion
```
Rule IfcPositiveLengthMeasure_WR1:
    (self > 0.)
Violated by:
    (0.0 > 0.0)
```

- some orphan representations violating:
```
Rule IfcShapeModel_WR11:
    ((sizeof(self.OfProductRepresentation) == 1) ^ (sizeof(self.RepresentationMap) == 1) ^ (sizeof(ofshapeaspect) == 1))
Violated by:
    ((0 == 1 ^ 0 == 1) ^ 0 == 1)
     +  where 0 = sizeof(())
     +    where () = #9091=IfcShapeRepresentation(#15,'Body','SweptSolid',(#9090)).OfProductRepresentation
     +  and   0 = sizeof(())
     +    where () = #9091=IfcShapeRepresentation(#15,'Body','SweptSolid',(#9090)).RepresentationMap
     +  and   0 = sizeof(())
```
2023-04-03 19:53:43 +05:00
Andrej730 c7105a22e6 Fixed validation error for ELEVATION_VIEW curves #2925
Error occured because ShapeBuilder was assigning "Curve2D" representation type for elevation view curves when the correct type is "Curve3D".

It use to occur for both doors and windows created with ifc modifier.

```
Validation error text:
2023-04-03:18:21:28,879 ERROR   [rule_executor.py:154] On instance:
    #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134))
Rule IfcShapeRepresentation_CorrectItemsForType:
    (IfcShapeRepresentationTypes(self.RepresentationType,self.Items))
Violated by:
    False
     +  where False = IfcShapeRepresentationTypes('Curve2D', (#134=IfcIndexedPolyCurve(#133,(IfcLineIndex((1,2)),IfcLineIndex((2,3)),IfcLineIndex((3,4)),IfcLineIndex((4,1))),$),))
     +    where 'Curve2D' = #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134)).RepresentationType
     +    and   (#134=IfcIndexedPolyCurve(#133,(IfcLineIndex((1,2)),IfcLineIndex((2,3)),IfcLineIndex((3,4)),IfcLineIndex((4,1))),$),) = #135=IfcShapeRepresentation(#21,'Profile','Curve2D',(#134)).Items
```
2023-04-03 19:53:43 +05:00
Andrej730 e1fc7cad44 Fixed all unit.add_si_unit uses after fd87747
Now they were causing `TypeError: Usecase.__init__() got an unexpected keyword argument 'name'`
2023-04-03 19:53:42 +05:00
Andrej730 afeeaeb984 Fixed some validation errors for doors and windows #2925
Fixed the ones caused by using 3d curves as inner/outer curves in profiles.
2023-04-03 19:53:42 +05:00
Andrej730 2bc60b87f2 Fixed issue with tool.Blender.apply_bmesh 2023-04-03 19:53:42 +05:00
Dion Moult 4ad9ecb7db FixRevitTINs patch recipe now also purges non up-facing polygons as Revit doesn't handle them very well. 2023-04-03 21:28:34 +10:00
Dion Moult 3ec7b82b85 Fix #2930. Do not require entity applicability in IfcTester. 2023-04-03 21:28:00 +10:00
Dion Moult 48666def6b Fix #2910. Bug where style colours were not synced prior to duplication. 2023-04-03 20:16:43 +10:00
Chun 5732921fb6 a simplifier workflow and a more consistent coding style 2023-04-03 19:50:53 +10:00
Chun b86c11e1dc Unify variable 2023-04-03 19:50:53 +10:00
Chun 1bae4b219a Update functions of get_connected_to and get_connected_from compatible with IFC4 and IFC2X3 2023-04-03 19:50:53 +10:00
Chun 70ff73f805 Add IFC4 support for functions get_connected_to and get_connected_from in util.system 2023-04-03 19:50:53 +10:00
Chun a9636c5038 Add IFC4 support to get_connected_to and get_connected_from functions 2023-04-03 19:50:53 +10:00
Dion Moult a406b9f7ef Fix #2928. 2023-04-03 18:12:32 +10:00
Dion Moult f291345111 Fix #2924. IfcElements default to a null predefined type so they can inherit where possible. 2023-04-03 13:54:25 +10:00
Dion Moult c947ccb8be Fix #2926. Connections removed when rotating 90 deg to prevent unintuitive behaviour. Layer2 are also now recalculated. 2023-04-03 13:43:42 +10:00
Dion Moult 28c6b0d4bb Link to IfcArchitect tutorial series for quickstart video tutorials 2023-04-03 12:35:10 +10:00
Dion Moult 19317a9cc2 See #2881. Add support for evaluated commands in smart text literals 2023-04-02 21:25:06 +10:00
Dion Moult d67da6425e Fix #2927. Continuing to make mesh editing stricter. 2023-04-02 15:02:43 +10:00
Dion Moult 901f41358f Shortlist which IFC geometries may be treated as a meshlike object. 2023-04-02 13:45:05 +10:00
Dion Moult 061922aea2 Minor fix 2023-04-01 22:19:29 +11:00
Massimo Fabbro 5f7b6a5498 fix qto ui bug where objects with no assigned base qto doesn't allow to show the qto panel 2023-04-01 21:59:53 +11:00
Dion Moult 2ef9d5eed9 Fix #2922. You can now edit extrusion profiles of swept solids. 2023-04-01 21:27:20 +11:00
Dion Moult 9fba57d5db Disable edit mode on non mesh-like representations as well to prevent risk of invalid geometry. 2023-04-01 21:25:45 +11:00
Dion Moult e9074e3b3f Fix bug where generated openings invalidly used 3 dimensions instead of 2 2023-04-01 18:14:54 +11:00
Andrej730 f053ba714f Fixed bug in tool.Blender.get_bmesh_for_mesh
It caused errors because it was expecting mesh object to be selected - when it's not necessary that active_object is the one that mesh belongs to and sometimes no objects can be selected at all.
2023-04-01 12:12:34 +05:00
Andrej730 b6598f09a3 Fixed error with switching from EDIT mode for annotation meshes
Error occured when you were editing annotation mesh and tried to switched from EDIT mode

Error: Python: Traceback (most recent call last):
  File "\blenderbim\bim\module\geometry\operator.py", line 838, in invoke
    elif element.HasOpenings:
  File "\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 153, in __getattr__
    raise AttributeError(
AttributeError: entity instance of type 'IFC4.IfcAnnotation' has no attribute 'HasOpenings'
2023-04-01 12:00:07 +05:00
Andrej730 b9d7b95304 Revert part of 3a3d96be0 #2897
Reverted part of the bgl to gpu transition (to not scare away people with annotations without antialiasing🙂) until I work out the complete solution.
2023-03-31 19:56:26 +05:00
Andrej730 3db540f786 Fixed another typo related to #2889... 2023-03-31 19:50:22 +05:00
Andrej730 071b99c6c6 Fixed crash in Blender 3.5 on creating fill area annotation
Crash was caused by some change in Blender Python API in 3.5.
The code below resulted in `ValueError: bpy_struct: item.attr = val: MeshPolygon.vertices: array length cannot be changed to 4 (expected 0)`

```
obj.data.polygons.add(1)
p1 = obj.data.polygons[-1]
p1.vertices = (v1.index, v2.index, v3.index, v4.index)
```
2023-03-31 17:52:07 +05:00
Andrej730 3a3d96be0a bgl to gpu: profiles and openings decorations #2897
Still need to fix shaders.py and decoration.py
2023-03-31 16:38:24 +05:00
Andrej730 a03fbab4d5 Added description to some annotation operators 2023-03-31 11:06:21 +05:00
Andrej730 cc3b119288 Automatically adjusted STAIR_ARROWs now stop at the top thread
Previously they were ending at the end of the stair object and problem was that the end of the object could be at the slab underneath the stair.

Example - https://i.imgur.com/Y43v0GM.png
Before - https://i.imgur.com/Ze9DoK2.png
2023-03-31 10:59:39 +05:00
Andrej730 1a750d1b85 STAIR_ARROW annotations attached to IfcStairFlight object now readjusted after changes in IFC Stair modifier
Later probably will also need some other way to readjust annotations - so they can be readjusted for custom stairs, not created with modifier.
2023-03-31 10:59:39 +05:00
Andrej730 5b3ae9b9fd Clever STAIR_ARROW annotation
Now adding STAIR_ARROW annotation is a bit more clever - if you have IfcStairFlight selected when adding this type of annotation it will automatically:
1) define stair as it's parent;
2) add the stair as it's product;
3) place itself along the stair (it's assumed that stair direction is X+)

Example - https://i.imgur.com/Ze9DoK2.png
2023-03-30 18:41:55 +05:00
Andrej730 81471d80cd Fixed bug causing errors in IFC4X3 projects
It was causing an error below on opening BIM Tool and probably in some other places.

```
Traceback (most recent call last):
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 35, in draw
    self.draw_tool_settings(context)
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 48, in draw_tool_settings
    tool = ToolSelectPanelHelper.draw_active_tool_header(
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_toolsystem_common.py", line 809, in draw_active_tool_header
    draw_settings(context, layout, tool)
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 67, in draw_settings
    BimToolUI.draw(context, layout)
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 89, in draw
    AuthoringData.load()
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 52, in load
    cls.load_ifc_classes()
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 109, in load_ifc_classes
    cls.data["ifc_classes"] = cls.ifc_classes()
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 196, in ifc_classes
    + tool.Ifc.get().by_type("IfcDoorStyle")
  File "\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 364, in by_type
    return [entity_instance(e, self) for e in self.wrapped_data.by_type(type)]
  File "\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4499, in by_type
    return _ifcopenshell_wrapper.file_by_type(self, *args)
RuntimeError: Entity with name 'IfcDoorStyle' not found in schema 'IFC4X3'
Traceback (most recent call last):
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 35, in draw
    self.draw_tool_settings(context)
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 48, in draw_tool_settings
    tool = ToolSelectPanelHelper.draw_active_tool_header(
  File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_toolsystem_common.py", line 809, in draw_active_tool_header
    draw_settings(context, layout, tool)
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 67, in draw_settings
    BimToolUI.draw(context, layout)
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 92, in draw
    cls.draw_header_interface()
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 351, in draw_header_interface
    cls.draw_type_selection_interface()
  File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 367, in draw_type_selection_interface
    if AuthoringData.data["ifc_classes"]:
KeyError: 'ifc_classes'
```
2023-03-30 17:12:00 +05:00
Andrej730 eb14db4deb Fixed typo in ifcopenshell.util.type 2023-03-30 16:42:25 +05:00
Andrej730 50d989363a Added arrow to 2d repr of sliding doors (#2919)
Example - https://i.imgur.com/eJnhDXU.png
2023-03-30 16:36:55 +05:00
Dion Moult e52a99bd71 Load all type products by default (in preparation for IfcAnnotationType support) 2023-03-30 21:26:16 +11:00
Andrej730 a7a7c86657 IFC Door Modifier - sliding doors
Added support for sliding doors in IFC Door Modifier.

The main differences are 2d representation (https://i.imgur.com/VyEH569.png) and the door panel being placed before the lining, not after
2023-03-30 12:41:34 +05:00
Andrej730 59b8347082 Added option for oblique style for viewport dimension annotations
It's available after adding "oblique" to EPset_Annotation classes of the annotaiton.

Examples with and without it:
- https://i.imgur.com/JtgSeUK.png
- https://i.imgur.com/H7TPnfo.png
2023-03-29 16:37:00 +05:00
Andrej730 86883770b8 Fixed wrong text direction for plan level annotation
It occured when plan level spline direction was right-to-left.
2023-03-29 15:02:39 +05:00
Andrej730 d19c7d27a8 Cleaned up meshes produced during slab / arbitrary profile edit
Previously it was producing orphan meshes
2023-03-29 14:30:35 +05:00
Andrej730 eb35aad6e3 Added warning to bim.set_arc_index 2023-03-29 14:30:35 +05:00
Thomas Krijnen 5f952ecd00 Update ci.yml 2023-03-29 11:14:51 +02:00
Thomas Krijnen 74cd28d761 Update ci-py-only.yml 2023-03-29 11:14:41 +02:00
Thomas Krijnen 6e8049c43b Update ci.yml 2023-03-29 10:46:18 +02:00
Thomas Krijnen bbc61483ad Update ci-py-only.yml 2023-03-29 10:45:54 +02:00
Andrej730 db5315249c Fixed bug with slab editing decorator breaking on undo
Because of jumping between modes "bim.set_arc_index" doesn't remove newly created vertex groups on undo which resulted in error in decorator.

    File "\blenderbim\bim\module\model\decorator.py", line 134, in __call__
        if group_index in vertex[deform_layer]:
    AttributeError: BMElem[key]: invalid key, must be a BMLayerItem
2023-03-29 10:34:11 +05:00
Sigma Dimensions 4d34404e47 code clean up 2023-03-29 01:59:42 +00:00
Sigma Dimensions fa261b3281 Features to re-order cost items in a tree (changing parent & changing nesting order) 2023-03-29 01:49:55 +00:00
Sigma Dimensions 73feadcd66 Improved UI for adding cost item values 2023-03-29 01:38:21 +00:00
Sigma Dimensions da84165e13 Enable object selection from Cost item related products' list 2023-03-29 01:35:21 +00:00
Sigma Dimensions cc550c413b fix UI issue for loading product cost items 2023-03-29 01:31:09 +00:00
Sigma Dimensions 5b8b68457f ios utility to transform a human readable date or duration from string into objects 2023-03-29 00:47:05 +00:00
Sigma Dimensions 7850f8c718 You can now view & and highlight cost items assigned to an object, from Viewport Selection 2023-03-29 00:41:59 +00:00
Sigma Dimensions 3502b560f0 You can now select unassigned cost schedule products 2023-03-29 00:32:08 +00:00
Sigma Dimensions 53aa5e5fe0 You can now clear all cost assignements at once 2023-03-29 00:23:32 +00:00
Sigma Dimensions 674526d2df Show total elements/tasks/resources assigned to a cost item 2023-03-29 00:06:31 +00:00
Sigma Dimensions 384c9c9872 Refactor BBIM costing code, and re-use shared IOS utilies code 2023-03-28 23:28:00 +00:00
Sigma Dimensions 1170448cd0 New ifcopenshell cost utilities 2023-03-28 23:11:07 +00:00
Sigma Dimensions a7ec9c097a Enable displaying assigned nested resources for Cost Items 2023-03-28 23:09:07 +00:00
Sigma Dimensions 9b3b29a91c Enable displaying assigned nested tasks for Cost Items 2023-03-28 23:05:26 +00:00
Sigma Dimensions 16c4b212fd Enable displaying nested elements for Cost Item assigned Elements 2023-03-28 22:53:03 +00:00
Andrej730 50ba0815f7 Fixed UI for box alignment
Replaced checkboxes with icons and removed vertical and horizontal space between them, now looks neat.
2023-03-28 19:34:32 +05:00
Thomas Krijnen 8d3347c02b Update Dockerfile 2023-03-28 15:49:27 +02:00
Andrej730 fbd57a2bd7 Fixed array operator bug after 75f56462b (related to #2905) 2023-03-28 18:16:42 +05:00
Andrej730 75c98e5b00 Exiting current editing decorator if user switches from EDIT mode
Switching from EDIT mode acts like canceling editing which seems intuitive.

Now it's also possible to add similar thing to other use of decorators - beware of the possible Blender bug - mentioned it in `ProfileDecorator.install description`

Added this change to editing of profiles, extrusion axis, roof and railing paths, extrusion profiles.
2023-03-28 17:28:59 +05:00
Andrej730 c725eeb5db IFC Roof - small fix 2023-03-28 16:45:46 +05:00
Andrej730 75f56462b5 IFC Array - option to use local space instead of global (#2905) 2023-03-28 15:40:25 +05:00
Andrej730 f6ca12d3b8 IFC Text Multiple literals now displayed in viewport separated by newline 2023-03-28 14:58:12 +05:00
Andrej730 f6b7201bc4 Added default blender selection behaviour to CAD Tool
Similarly to BIM Tool (85bba9d)
Now it works exactly as default blender selection - supports box selection etc
2023-03-28 14:52:23 +05:00
Andrej730 ab618be49f Gable Roof support for roof modifier
How it works:
1) You add Roof Modifier to some object that represents roof footprint.
2) Start editing path (Shift-E in BIM Tool).
3) Then you can select any edge and specify roof angles manually for each edge (Shift-R in BIM Tool)
to make side gabled you just need to set angle to 90 degrees. Preview will update automatically.  You can set it back to 0 for angle to be defined automatically.

Some other changes:
- refactored decorator.py, in decorator now it's possible to supply some custom bmesh function that will be called on redraw, decorator now also can draw faces;
- changed colors for selected verts / edges to less bright, now it in more contrast to selected verts / edges color and seems much more readable;
2023-03-28 12:43:06 +05:00
Sigma Dimensions 5943e7e62e api usecase to re order related objects in a nest 2023-03-28 04:29:08 +00:00
Sigma Dimensions fde654aee7 api usecase to change nest 2023-03-28 04:27:47 +00:00
Sigma Dimensions 4880e1f9eb You can now select individual Task Inputs & Task Ouputs directly from the task quantity assignments. 2023-03-28 04:13:18 +00:00
Sigma Dimensions 8083a635a8 You can now import work schedules from csv 2023-03-28 04:04:48 +00:00
Dion Moult fab76bbcde Fixed bug where enumeration values in psets could be empty lists. 2023-03-27 23:08:47 +11:00
krande 7f78df595f minor clarification in comment 2023-03-27 13:35:24 +02:00
krande 03ff34f89f update ci-restart script with code that works and is testable locally 2023-03-27 13:35:24 +02:00
krande 8820a1dcc3 switch to a python implementation of the same procedure 2023-03-27 13:35:24 +02:00
krande 514975d123 add a workflow to catches and restarts failed conda builds due to 143 errors. And minor cleanup of unused variables in conda meta.yaml 2023-03-27 13:35:24 +02:00
Dion Moult c87911f00e IFC selector now uses "class" as a keyword to get the IFC class to disambiguate between "type" and "class". 2023-03-27 21:47:11 +11:00
Dion Moult 1e77562f0f Fix #2847. You can now join meshes and extrusions together. 2023-03-27 21:46:26 +11:00
Dion Moult b1843ce781 Fix IfcTester bug which did not consider null enumeration values 2023-03-27 17:36:06 +11:00
Dion Moult 02fb09ff7e Implement faux-mirroring. 2023-03-27 14:21:59 +11:00
Dion Moult bdb193f500 Minor fix 2023-03-27 13:38:14 +11:00
Dion Moult e9a3630595 Fix #2898. You can now copy materials from the materials tab. 2023-03-26 19:04:32 +11:00
Dion Moult fb3e4016ec See #2898. Fix bug where UI data was not refreshed when you switched active materials. 2023-03-26 18:07:10 +11:00
Trashman247 15a1aa5355 Move bl_descriptions
Moved bl_descriptions under bl_options when bl_options exists, copying the syntax of already existing operators with descriptions.
2023-03-26 17:46:33 +11:00
Trashman247 f1d6e95e51 Add tooltips to IFC Project Info and Clash Sets Panels 2023-03-26 17:46:33 +11:00
Dion Moult b9c99b35a5 Fix #2881. Support added for referencing nested relationships and material set items. 2023-03-25 22:07:18 +11:00
Dion Moult df0a503b89 Improve implementation of is_moved so that anywhere we check movement, types and projects are not considered 2023-03-24 21:59:09 +11:00
Dion Moult 346071185f Fix bug where appending a product from a library which had relationships to types caused a bunch of types to be pulled in unintentionally 2023-03-24 20:53:55 +11:00
Dion Moult f3f90e0ad5 Fix bug where mesh analysis during updating meshes as solids (i.e. extrusions) did not remove doubles, causing it to fail on sloppy meshes (and meshes are often sloppy) 2023-03-24 20:53:18 +11:00
Dion Moult 8aa2c1eea7 Fix critical bug where types would think they moved and cause long syncs at export time. 2023-03-24 20:52:20 +11:00
Dion Moult 57c32e55c2 Fix #2698. Bug where clash sets couldn't be visualised if you had one of the models open (i.e. not linked) in the active session. 2023-03-24 18:25:33 +11:00
Dion Moult de080a668f Fix #2901. Silly typo. 2023-03-24 17:48:27 +11:00
Dion Moult 00fc71dcbe Fix #2837. Shared subelements mistakenly caused the subelement append loop to break early. The solution is to traverse one level at a time. 2023-03-24 17:36:46 +11:00
Andrej730 808cb6ec14 Fixed outdated code issue 2023-03-24 11:00:08 +05:00
Andrej730 8899776106 Fixed #2900
1) Leaders text decorator wasn't changed after adding support for multiple literals
2) added drawing data update on toggling viewport annotations - so user would see correct values right away; also fixed similar thing on updating product
2023-03-24 11:00:08 +05:00
Andrej730 ae674b00c2 Fixed bugs after adding aggregated text annotations (#2899) 2023-03-24 10:09:23 +05:00
Dion Moult 73b6d23d4f Minor fix 2023-03-24 16:05:27 +11:00
Dion Moult 6d1cabe534 Fix #2887. Fix bug where you could create multiple opening objects. 2023-03-24 15:03:39 +11:00
Dion Moult ab34fda42c See #2887. Save mesh dialog now only shown when mesh is edited. 2023-03-24 14:33:13 +11:00
Dion Moult fab4133df6 Minor fix 2023-03-24 13:22:10 +11:00
Dion Moult 301e368a2c Minor fix 2023-03-23 22:09:31 +11:00
Dion Moult 0a22714fb8 See #2887. Experimental edit mode toggle override to ensure mesh changes stay in sync and so that you can edit meshes without openings applied. 2023-03-23 21:51:06 +11:00
Thomas Krijnen ef2cec7435 #2884 depends python3-pytest 2023-03-23 09:05:39 +01:00
Dion Moult b4f486e9aa Minor fix 2023-03-23 16:54:15 +11:00
Andrej730 297303063e Small changes in default names for saving ifc projects
1) changed first ifc saving handler from save_pre to save_post so that in the situation when you just created with .blend file and started ifc project on save dialog would suggest the same name for the .ifc file and for .blend file (previously it was always suggesting ".ifc" and you had to type it in manually).

2) suggested default ifc project named changed from `<blend_filename>.blend.ifc` to `<blend_filename>.ifc` for simplicity.

PS save_pre didn't really work anyway - by the time "save ifc dialog" file was invoked and appeared .blend file was already saved anyway.
2023-03-23 09:54:16 +05:00
Andrej730 df95bdb48e Fixing tests after 2003bfe4f 2023-03-23 09:53:02 +05:00
Dion Moult 95ac021623 Improve UI to indicate active representation. 2023-03-23 15:37:52 +11:00
Dion Moult 416efa4f14 See #2887. Fix bad UI design that could lead to objects created with the unintended context. 2023-03-23 10:44:57 +11:00
Ryan Schultz 2003bfe4fe Added_MODEL_VIEW_context
added...
context_type="Model", context_identifier="Annotation", target_view="MODEL_VIEW", parent=model
from: https://github.com/IfcOpenShell/IfcOpenShell/issues/2890
2023-03-23 08:00:39 +11:00
Andrej730 fc55a48c11 Automated adjustment of annotations scale if either camera orthographic scale or drawing scale changed 2023-03-22 15:56:55 +05:00
Andrej730 37a6be1e2b Ifc text viewport rotation for text with box alignment 2023-03-22 15:47:07 +05:00
Andrej730 e551bf531c Optimized ifc text viewport rotation algorithm 2023-03-22 14:37:48 +05:00
Andrej730 e173ea7f80 Ifc Text rotation in viewport preview 2023-03-22 14:05:03 +05:00
Andrej730 f8dc421f03 Fixed bug with multiline text in svg
Insertion position at <text> instead of <tspan> creates unnecessary x offsets between tspans
2023-03-22 11:04:43 +05:00
Andrej730 e2afb34e0d Fixed typo causing #2889 2023-03-22 10:09:38 +05:00
Andrej730 f7181aae8a Multiple literals in 1 Ifc Text + aggregated text annotations
Added option to store multiple literals inside 1 Ifc text object.

If multiple literals share the same `BoxAlignment` then only the first one will be displayed in viewport
to prevent visual clutter (although added small asterisk symbol to indicate that there are still multiple literals).

Added option for aggregated text annotations. Example - "door-tag" symbol.
If you create text, specify "door-tag" symbol in EPset_Annotation.Symbol
\and add two literals to it then they'll automatically will fit to that door-tag in the svg drawing
(https://i.imgur.com/OXaIlWe.png).

The way it works - you define symbol in symbols.svg (or in your own symbols svg file)
and then add the `<text>` fields where text from literals will fit right in.
The imporant note: `<text>` tag must have attribute `data-type="text-template"` for it to work.
For example: `<text text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>`
2023-03-21 17:37:28 +05:00
ArturTomczak 2a0fdd214c update the namespaces to current IDS schema 2023-03-21 20:37:37 +11:00
Dion Moult 45209be0ff You can now easily get a list of FMHEM classes and subtypes to list explicitly in IDS requirements 2023-03-21 17:15:59 +11:00
Dion Moult fcb3640bee IfcTester webapp can now render simple PartOf requirements 2023-03-21 17:13:34 +11:00
Dion Moult d503a4b50b Fix #2883. Regression in text in drawings. 2023-03-21 12:31:32 +11:00
Dion Moult 8bae2984e1 Fix #2886. Typo. 2023-03-21 09:11:30 +11:00
Andrej730 78499cc55d Fixed bugs related to "print all" (#2882) 2023-03-20 15:15:54 +05:00
Dion Moult b6aa5c57c0 Fix bug where copying types with parametric materials could lead to invalidly reused material set items. 2023-03-20 20:40:11 +11:00
Dion Moult d71e34f073 Fix bug where 2D types were not loaded as a fallback from the body representation. 2023-03-20 19:42:54 +11:00
Dion Moult a38d06d7e7 Remove dead code that manually synced drawing references. Now we have an automatic sync_references function instead. 2023-03-20 17:05:43 +11:00
Dion Moult 72b5cc8a44 Minor fix 2023-03-20 17:03:39 +11:00
Dion Moult c97e1079e8 See #2866. Fix issue where annotation should be able to use 3D coordinates (i.e. Model context type) for elevations and sections where it makes more sense. 2023-03-20 16:36:50 +11:00
Carlos Villagrasa 65caa7906d Merge remote-tracking branch 'upstream/v0.7.0' into pset_custom_units_test 2023-03-19 22:33:01 +01:00
Carlos Villagrasa d89a8520a9 Added a test for pset custom IfcUnits 2023-03-19 22:23:36 +01:00
Andres d68356c3a7 Rename class causing unregistering error 2023-03-20 08:21:11 +11:00
Andres cb0e8b6bf2 Add own sublogger for IfcSverchok 2023-03-20 08:21:11 +11:00
Andres b20b99669d Chore: add newline at end of file 2023-03-20 08:21:11 +11:00
Andres d41a277b71 Fix runtime error when unregistering add-on 2023-03-20 08:21:11 +11:00
Andres 33e6a0fdae Update logger to match Sverchok latest 2023-03-20 08:21:11 +11:00
Massimo Fabbro d911d8579d Add qto data file 2023-03-20 08:12:24 +11:00
Massimo Fabbro 05bdc962a3 Now it's possible to see the selected object related cost items and related quantities in qto n-panel 2023-03-20 08:12:24 +11:00
Sigma Dimensions 0e03a01f61 fixing previous commit #ff806dc 2023-03-19 14:11:32 +00:00
Sigma Dimensions ff806dc6e4 improve covering qto calculation 2023-03-19 13:30:35 +00:00
Thomas Krijnen 5fcfbac4a3 Update validate.py 2023-03-19 13:24:27 +01:00
Thomas Krijnen 00b18f67cf #2685 indeterminate upper bound formatting 2023-03-19 12:46:15 +01:00
Dion Moult 088354a96b Fix critical bug where copied representations would be inefficiently or incorrectly replicated. 2023-03-19 22:03:45 +11:00
Dion Moult cfd857233c Fix #2864. Fix bug where element containment was invalidly prioritised over voids and fills in relative placement. 2023-03-19 18:46:34 +11:00
Dion Moult 2816d7f522 Fix bug where deleting the drawing object could lead to orphaned relationships 2023-03-19 18:15:09 +11:00
Dion Moult 3da718a6d1 Fix bug where removing objects could leave orphaned annotation relationships 2023-03-19 15:17:26 +11:00
Dion Moult 558aff72a0 Psets and qtos are now only created when properties exist to prevent invalid IFCs. 2023-03-19 14:49:31 +11:00
Dion Moult bcc399b842 Empty psets are purged to discourage invalid psets with no properties 2023-03-19 13:13:15 +11:00
Andrej730 32e47d03d4 IFC text - box alignment in viewport 2023-03-18 11:56:29 +05:00
Carlos Villagrasa a669c194cf Merge pull request #2869 from cvillagrasa/api_material_fix
Api material fix
2023-03-17 17:04:22 +01:00
Carlos Villagrasa 91f4687eac Revert "Add more parameters to material.add_layer"
This reverts commit 9946117de1.
2023-03-17 17:02:35 +01:00
Andrej730 31f6baaf67 small refactor for Ifc.edit and tool.Ifc
1) replaced IfcStore.edited_objs.add with tool.Ifc.edit
2) updated interface in tool.py
3) removed unlink from tool.Ifc - it was declared there twice
2023-03-17 17:50:56 +05:00
Andrej730 a83c4b2896 Stair, roof, railing - auto updating representation when creating one or update it
So basically there should be no need to manually update representation after you created one of the objects from ifc modifiers.
2023-03-17 17:32:36 +05:00
Andrej730 c685425667 Fixed bugs with text annotations after
1) Bug when new text added without specifying it's font size in class appeared empty;
2) Bug when leader text appeared weirdly bold.
2023-03-17 17:02:42 +05:00
ay-ex 553334d50e add imports to snippet
added imports and syntax highlighting so it is easier to run for newcomers
2023-03-17 20:33:15 +11:00
Andrej730 0b7b0a29a9 Solved redundant spaces in multiline svg text annotations (#2833)
The issue occurs because of svg pretty formatting - indent spaces <text> tag treats as actual spaces. Because of that use some css magic to remove those spaces from <text> tag and assign class to it's children <tspan> tags.

Altough trying to solve this issue I've tried to disable svg pretty format and got empty svg as a result (only templates, styles, no annotations) for some reason.
2023-03-17 11:05:27 +05:00
Andrej730 ae7f834a0f draw_text_annotation refactor
Refactored a code a bit and replaced literal parsing with `text_obj.BIMTextProperties.text` since it's already done beforehand in `tool.Drawing.update_text_value()`.
2023-03-17 11:05:26 +05:00
Andrej730 fe0a98a44f black format 2023-03-16 16:08:58 +05:00
Andrej730 35e748089b Prevent pyrna_enum_to_py warnings on using BIM Tool hotkeys
Type of warning fixed:
WARN (bpy.rna): pyrna_enum_to_py: current value '0' matches no enum in 'BIMModelProperties', '', 'ifc_class'
2023-03-16 16:08:58 +05:00
Andrej730 ff2cda7d18 Small refactor + allowing to preview text in viewport while editing 2023-03-16 16:08:58 +05:00
Andrej730 0d473fa9ac Fixing BoxAlignment value in tests (similar to 9f7db386a) 2023-03-16 16:08:58 +05:00
Andrej730 d8eb765906 BIM Tool - hotkey for editing text annotation
Added hotkey in BIM Tool for editing active text annotation (It's binded on Shift + E).
2023-03-16 16:08:58 +05:00
Carlos Villagrasa fab7b590f7 Allow for custom IfcUnits when editing psets 2023-03-16 20:39:32 +11:00
Andrej730 c9f52d2f8e Option to print all svg drawings #2794
It's working either if you shift click the printing button or supply `print_all = True` argument to `bim.create_drawing operator`.
2023-03-16 11:35:31 +05:00
Andrej730 821993d289 Fixed accidentally removed line in ee1e40171 2023-03-16 10:11:26 +05:00
Andrej730 2d32bc609a Figured a new way to update viewport to preview changes in ifc text 2023-03-16 10:11:26 +05:00
Andrej730 296cec02e8 Removed outdated code from BIMTextProperties 2023-03-16 10:11:26 +05:00
Andrej730 b55ac88c9d Fixing tests after 9f7db386a
TestExportTextLiteralAttributes and TestImportTextAttributes was failing because now we're assuming that BoxAlignment will have 1 of values from the list below and not "BoxAlignment"

"top-left", "top-middle", "top-right", "middle-left", "center", "middle-right", "bottom-left", "bottom-middle", "bottom-right"
2023-03-15 19:43:17 +05:00
Andrej730 c6d3598c52 Fixing tests after e9fdc979d 2023-03-15 19:43:17 +05:00
Andrej730 c4d2b30017 black format 2023-03-15 19:43:17 +05:00
Andrej730 ee1e401719 Ifc Text - drop down menu to switch font size
Added drop down menu to Ifc Text section in object properties where you can change text's size and it will automatically change it in `EPset_Annotation.Classes`. You can also preview it in viewport and it will write in IFC only after you finish editing.

Still need to investigate `annotation.Annotator.resize_text(context.active_object)` in `refreshFontSize`.
2023-03-15 19:43:16 +05:00
Andrej730 3c2ef518e8 IfcText - box alignment interface instead of manually typing text position
realigning box widget
2023-03-15 19:43:16 +05:00
Andrej730 f3e327e088 Added classes description for EPset_Annotation 2023-03-15 19:43:16 +05:00
Andrej730 be1d4e06de IfcText - different text sizes in viewport 2023-03-15 19:43:16 +05:00
Dion Moult 32f5a77d07 New shape utilities for getting top / bottom elevations and bbox. 2023-03-15 18:51:31 +11:00
Dion Moult 9121a6b864 Revert "Fix #2418. Object materials are now found in the materials tab."
This reverts commit 7666463751.
2023-03-15 18:30:11 +11:00
Carlos Villagrasa 9946117de1 Add more parameters to material.add_layer 2023-03-15 08:27:46 +01:00
Carlos Villagrasa ee85055d45 Fix bug in which layer.Material was erased 2023-03-15 08:27:27 +01:00
Andrej730 cce0867f63 IfcText - spacing in multiline text now depends on text size #2833 2023-03-14 19:38:15 +05:00
Andrej730 021321eb65 IfcText - support multiline text in viewport preview 2023-03-14 19:38:15 +05:00
Andrej730 6bd1b84b2b IfcText to appear on top of object properties stack
1) Puts IFC Text only on top of ifc panels to make it easier to change it's text
2) I guess it could be a good practive to set `bl_order = 1` by default so it will be possible later to prioritize something since by default blender sets `bl_order = 0` and then even `bl_order = -1` wouldn't help.
3) May not work in previously created files
2023-03-14 19:38:15 +05:00
Massimo Fabbro f5281a0895 Delete unuseful function 2023-03-14 11:24:37 +11:00
Massimo Fabbro 08fdf6014d weight calculator improvement (see #2859) 2023-03-14 11:24:37 +11:00
Andrej730 94f06d9e18 Another fix for dissolve limit in hiped roof generator... 2023-03-13 17:05:08 +05:00
Andrej730 8405ee4926 Fixed bug dissolve limit in generate hipped roof (e69452883)
Now it will work fine in both edit and object mode
2023-03-13 11:28:36 +05:00
Massimo Fabbro 154c4295df Finish mapping mappable quantities with get_weight 2023-03-13 13:18:02 +11:00
Massimo Fabbro 93519c1c63 Now is possible to calculate an object gross weight 2023-03-13 13:18:02 +11:00
Dion Moult 1250a20e35 Fix #2858. Fix #2856. BlenderBIM Add-on drawings and IfcCSV now support the new quoted and escaped selector capabilities. 2023-03-13 11:09:56 +11:00
Thomas Krijnen 9ec54228f8 Update ci-py-only.yml 2023-03-12 12:01:12 +01:00
Dion Moult 3f94184ace Fix bug where IfcURIReference properties wouldn't display 2023-03-12 21:55:07 +11:00
Thomas Krijnen 88c06f5450 Try different way of invoking ccache 2023-03-12 11:46:25 +01:00
Thomas Krijnen e50045bbed Update ci.yml 2023-03-12 10:06:32 +01:00
Thomas Krijnen 41417a77b9 Update ci-py-only.yml 2023-03-12 10:06:29 +01:00
Thomas Krijnen a5774bd02a Update ci-py-only.yml 2023-03-12 09:40:30 +01:00
Thomas Krijnen c38f48ee62 Try to let pip not install outdated ifopsh 2023-03-12 09:04:33 +01:00
Dion Moult 30c850e37d Fix #2140. Voids and fills can now be added, removed, and edited for non-geometric aggregates. 2023-03-12 12:52:30 +11:00
Dion Moult b6fdbd979e Adding existing objects as openings no longer move to cursor which is more intuitive 2023-03-12 12:52:30 +11:00
Thomas Krijnen 7a8bcbee33 #2685 poly curve test cases 2023-03-11 20:44:59 +01:00
Thomas Krijnen 42d7c7d32c #2685 Recompile rule 2023-03-11 20:44:11 +01:00
Thomas Krijnen c71a5a4d65 #2685 Indexing of simple type aggregates; fix index codegen bug; sizeof of indeterminate; repeat over indeterminate 2023-03-11 20:43:00 +01:00
Andrej730 e69452883f Temporarily commented out dissolve_limited in generate_hipped_roof
Currently it causes an error if you run it in object mode and doesn't really work in edit mode either because you may have no vertices selected. Will fix soon.
2023-03-11 20:47:41 +05:00
Sigma Dimensions 8624888bfc You can now specify custom names for types instead of relying on the default "TYPEX" naming 2023-03-11 14:13:56 +01:00
Andrej730 fad5c7c921 Section annotation - custom markers / toggle displaying the markers
Now it's possible to set custom markers in section annotation.

To do so you need to add BBIM_Section pset to the annotation and then you can either toggle displaying some marker with ShowStartArrow/ShowEndArrow or you can write the id of some custom symbol in StartArrowSymbol/EndArrowSymbol (need to make sure the symbol is included in symbols.svg).

Other changes:

- removed vertex sorting in decoration.py so that start and end points will be the same thing both in svg and in viewport representation (previously the sorting was needed of the direction the arrow in shader wasn't inverted));

- fixed bug when in svg section arrow symbols wouldn't rotate if you move individual verts of the annotation, not the entire object (I guess this bug sneaked in after adapting elevation annotation)
2023-03-11 18:02:16 +05:00
Dion Moult 0dad93bf00 See #2140. You can now bulk unassign aggregates, and they are auto directly contained in any previous indirect containers. 2023-03-11 16:31:23 +11:00
Dion Moult c51aa910cb See #2140. You can now select multiple objects and bulk add them to a single aggregate, and customise the aggregate class. 2023-03-11 16:31:23 +11:00
Andrej730 6d486aeb4d Removed debug print 2023-03-11 10:30:24 +05:00
Dion Moult 7041a4a4a9 Fix #2850. Splitting walls now reassigns voids and fills to the appropriate split portion. 2023-03-11 15:08:26 +11:00
Andrej730 381570cd9e Decorators - a bit more consistent geometry parsing between edit/object modes 2023-03-10 19:26:08 +05:00
Andrej730 c9f93b2316 Section annotation option not to draw full line between the markers
Here's the example - https://i.imgur.com/db09OVF.png

To make it work need to add BBIM_Section property set to the annotation and set "HasConnectedSectionLine" to False (by default it's True).
Also added preview for this feature in viewport.
2023-03-10 19:26:08 +05:00
Dion Moult 3706ecc5f2 Fix #2689. Fully disable wall sketches until we come up with a proper UX for it. 2023-03-10 21:21:03 +11:00
Dion Moult 51ad51036e Generated spaces now remember height and origin represents recalculation point. 2023-03-10 19:48:49 +11:00
Dion Moult 3edbcb9ff8 Fix #2849. Brick.ttl is now bundled. 2023-03-10 17:49:11 +11:00
Dion Moult 3e3c1699da Fix #1047. You can now set offsets to the iterator via Python. 2023-03-10 15:49:45 +11:00
Dion Moult 7666463751 Fix #2418. Object materials are now found in the materials tab. 2023-03-10 15:37:21 +11:00
Dion Moult c532b90c92 Minor fix. 2023-03-10 08:50:25 +11:00
Andrej730 7677733850 small fix for tool.Drawing.get_drawing_metadata
Otherwise it always returned a list with 1 empty string like `[ "" ]` which resulted in messy class names in svg like "-87IfcAnnotation0LtaLiEpzAOxEqmIvCV27EFALLSLOPEANGLE".
2023-03-09 18:50:05 +05:00
Andrej730 972d701801 Fall annotations
Added fall annotation - they appear both in viewport and svg.

There are three types of annotations (SLOPE_ANGLE, SLOPE_FRACTION, SLOPE_PERCENT) you can switch them by changing annotation's ObjectType to one of those values.

By default it uses angle representation.
2023-03-09 18:50:05 +05:00
Dion Moult cdee5532b6 Fix #2838. Bug where invalid 3D entity was used for 2D coordinates. 2023-03-09 21:01:54 +11:00
Dion Moult 38019288de Fix #2839. Bug where undo system could store edits of IFC primitives. 2023-03-09 18:18:56 +11:00
Dion Moult 3e2ca328d2 Get side area lets you choose the side axis now in util.shape. 2023-03-09 17:48:42 +11:00
Dion Moult 93b44b43a5 You can now get all materials including materials in sets via the util module. 2023-03-09 17:48:10 +11:00
516 changed files with 56291 additions and 36053 deletions
+104
View File
@@ -0,0 +1,104 @@
import pathlib
import shutil
import requests
import zipfile
import os
# To test this locally, set these environment variables
REPO_OWNER = os.environ.get("REPO_OWNER", "IfcOpenShell/IfcOpenShell")
MY_WORKFLOW = os.environ.get("MY_WORKFLOW", "ci-ifcopenshell-conda-daily")
WORKFLOW_RUN_ID = os.environ.get("WORKFLOW_RUN_ID", None)
TOKEN = os.environ.get("GITHUB_TOKEN", None)
# To test this locally create a fine-grained personal access token for this repo with permissions "actions:read"
# See https://github.com/settings/tokens?type=beta
# This is a list of strings that indicate that a job has stopped abruptly.
SIGNS_OF_STOPPAGE = [
"Error: The operation was canceled.",
"fatal error C1060: compiler is out of heap space",
]
def start_request_session():
s = requests.Session()
headers = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
}
if TOKEN:
headers["Authorization"] = f"Bearer {TOKEN}"
s.headers = headers
return s
def get_ci_run(repo_name, run_id):
url = f"https://api.github.com/repos/{repo_name}/actions/runs/{run_id}"
s = start_request_session()
response = s.get(url)
return response.json()
def evaluate_log_file_for_abrupt_stop(log_file):
with open(log_file) as f:
for i, line in enumerate(f):
for sign in SIGNS_OF_STOPPAGE:
if sign in line:
print(f"Found sign of abrupt stoppage in [line {i}]: '{sign}'")
return True
return False
def get_ci_specific_run_specific_failure_details(repo_name, run_id):
url = f"https://api.github.com/repos/{repo_name}/actions/runs/{run_id}/attempts/1/logs"
s = start_request_session()
response = s.get(url)
# SAVE zip file
with open("logs.zip", "wb") as f:
f.write(response.content)
# unzip file
with zipfile.ZipFile("logs.zip", "r") as zip_ref:
zip_ref.extractall("logs")
failed_logs = []
for file in pathlib.Path("logs").iterdir():
if file.is_dir():
continue
if evaluate_log_file_for_abrupt_stop(file):
failed_logs.append(file)
return failed_logs
def restart_job(repo_name, job_id):
url = f"https://api.github.com/repos/{repo_name}/actions/runs/{job_id}/rerun-failed-jobs"
s = start_request_session()
response = s.post(url)
return response.json()
def eval_jobs():
run = get_ci_run(REPO_OWNER, WORKFLOW_RUN_ID)
if run["run_attempt"] > 1:
print("This is not the first attempt. Exiting")
return
failed_logs = get_ci_specific_run_specific_failure_details(REPO_OWNER, WORKFLOW_RUN_ID)
if len(failed_logs) == 0:
print("No runs exhibit signs of abrupt stoppage")
return
print("restarting job", WORKFLOW_RUN_ID)
r = restart_job(REPO_OWNER, WORKFLOW_RUN_ID)
print(r)
shutil.rmtree("logs")
os.remove("logs.zip")
if __name__ == "__main__":
eval_jobs()
@@ -4,6 +4,7 @@ on:
push:
paths:
- .github/workflows/ci-ifcopenshell-conda-daily.yml
- conda/**
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
@@ -53,11 +54,13 @@ jobs:
sudo mv -v MacOSX10.13.sdk /opt/ && \
ls /opt/
- uses: seanmiddleditch/gha-setup-ninja@master
- uses: conda-incubator/setup-miniconda@v2 # https://github.com/conda-incubator/setup-miniconda
- uses: mamba-org/provision-with-micromamba@main # https://github.com/mamba-org/provision-with-micromamba
with:
activate-environment: conda-build
python-version: ${{ matrix.pyver.distver }}
channels: conda-forge
channel-priority: strict
environment-file: conda/environment.yml
extra-specs: |
python=${{ matrix.pyver.distver }}
- name: build, test and upload ifcopenshell
if: ${{ matrix.platform.upload == 'true' }}
run: |
+57
View File
@@ -0,0 +1,57 @@
name: ci-ifctester-pypi
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# * * * * *
- cron: "0 0 18 * *"
push:
paths:
- '.github/workflows/ci-ifctester-pypi.yml'
env:
major: 0
minor: 0
name: ifcopenshell
jobs:
activate:
runs-on: ubuntu-latest
if: |
github.repository == 'IfcOpenShell/IfcOpenShell'
steps:
- name: Set env
run: echo ok go
build:
needs: activate
name: ${{ matrix.config.name }}-${{ matrix.pyver }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2 # https://github.com/actions/setup-python
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- run: echo ${{ env.DATE }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%y%m%d')"
- name: Compile
run: |
pip install build
cd src/ifctester &&
make dist
- name: Publish a Python distribution to PyPI
uses: ortega2247/pypi-upload-action@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: src/ifctester/dist
+9 -7
View File
@@ -7,7 +7,7 @@ on:
- 'test/**'
- 'conda/**'
- 'cmake/**'
- '.github/workflows/ci_py_only.yml'
- '.github/workflows/ci-py-only.yml'
pull_request:
jobs:
@@ -46,13 +46,14 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${GITHUB_WORKFLOW}
- name: Build ifcopenshell
run: |
sudo /usr/sbin/update-ccache-symlinks
mkdir build && cd build
cmake \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
PATH="/usr/lib/ccache:$PATH" cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr \
-DCMAKE_SYSTEM_PREFIX_PATH=/usr \
@@ -62,7 +63,7 @@ jobs:
-DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 \
-DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so \
-DCOLLADA_SUPPORT=Off \
"-DSCHEMA_VERSIONS=2x3;4" \
"-DSCHEMA_VERSIONS=2x3;4;4x3_add1" \
-DBUILD_CONVERT=Off \
-DGLTF_SUPPORT=On \
-DJSON_INCLUDE_DIR=/usr/include \
@@ -79,13 +80,14 @@ jobs:
- name: Install Python dependencies
run: |
sudo /usr/bin/python -m pip install -U pip
sudo /usr/bin/python -m pip install xmlschema numpy lxml
sudo /usr/bin/python -m pip install src/bcf
sudo /usr/bin/python -m pip install xmlschema xsdata numpy lxml
sudo /usr/bin/python -m pip install src/bcf --no-deps
sudo /usr/bin/python -m pip install pytest
sudo /usr/bin/python -m pip install isodate
sudo /usr/bin/python -m pip install lark
sudo /usr/bin/python -m pip install networkx
sudo /usr/bin/python -m pip install tabulate
sudo /usr/bin/python -m pip install python-dateutil
- name: Test
run: |
@@ -0,0 +1,34 @@
name: Restart failed daily conda builds
on:
workflow_run:
workflows: [ ci-ifcopenshell-conda-daily ]
types:
- completed
env:
REPO_OWNER: IfcOpenShell/IfcOpenShell
MY_WORKFLOW: ci-ifcopenshell-conda-daily
jobs:
restart-failed-runs:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Use python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Check for failed runs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
run: |
python check_repo_ci_jobs.py
working-directory: .github/workflows
+6 -3
View File
@@ -57,6 +57,8 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${GITHUB_WORKFLOW}
- name: Build ifcopenshell
run: |
@@ -73,7 +75,7 @@ jobs:
-DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 \
-DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so \
-DCOLLADA_SUPPORT=Off \
"-DSCHEMA_VERSIONS=2x3;4;4x3" \
"-DSCHEMA_VERSIONS=2x3;4;4x3_add1" \
-DGLTF_SUPPORT=On \
-DJSON_INCLUDE_DIR=/usr/include \
-DCGAL_INCLUDE_DIR=/usr/include \
@@ -103,14 +105,15 @@ jobs:
- name: Install Python dependencies
run: |
sudo /usr/bin/python -m pip install -U pip
sudo /usr/bin/python -m pip install xmlschema numpy lxml
sudo /usr/bin/python -m pip install src/bcf
sudo /usr/bin/python -m pip install xmlschema xsdata numpy lxml
sudo /usr/bin/python -m pip install src/bcf --no-deps
sudo /usr/bin/python -m pip install pytest
sudo /usr/bin/python -m pip install isodate
sudo /usr/bin/python -m pip install lark
sudo /usr/bin/python -m pip install networkx
sudo /usr/bin/python -m pip install https://github.com/Andrej730/aud/archive/refs/heads/master-reduced-size.zip
sudo /usr/bin/python -m pip install tabulate
sudo /usr/bin/python -m pip install python-dateutil
- name: Test
run: |
+5
View File
@@ -86,7 +86,12 @@ src/blenderbim/blenderbim/libs
# blenderbim test temp files
src/blenderbim/test/files/temp
src/blenderbim/drawings
src/blenderbim/layouts
# ifcopenshell swig and compiled files
src/ifcopenshell-python/ifcopenshell/_ifcopenshell_wrapper.so
src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.py
# apple
.DS_Store
+1 -1
View File
@@ -27,7 +27,7 @@ RUN echo "deb http://archive.ubuntu.com/ubuntu focal-proposed main restricted" |
libboost-all-dev \
libocct-foundation-dev libocct-modeling-algorithms-dev libocct-modeling-data-dev \
libocct-ocaf-dev libocct-visualization-dev libocct-data-exchange-dev \
libhdf5-serial-dev ; \
libhdf5-serial-dev python3-pytest ; \
rm -rf /var/lib/apt/lists/* ;
COPY . /home/IfcOpenShell/
+4 -1
View File
@@ -1,9 +1,12 @@
IfcOpenShell
============
<p align="center">
<img src="https://github.com/IfcOpenShell/IfcOpenShell/assets/79010126/9e540403-c79f-446a-88c6-7c1ebc6ba864">
</p>
IfcOpenShell is an open source ([LGPL]) software library for working with Industry Foundation Classes ([IFC]). Complete
parsing support is provided for [IFC2x3 TC1], [IFC4 Add2 TC1], IFC4x1, IFC4x3, and IFC4x3. Extensive geometric support
parsing support is provided for [IFC2x3 TC1], [IFC4 Add2 TC1], IFC4x1, IFC4x2, and IFC4x3. Extensive geometric support
is implemented for the IFC releases [IFC2x3 TC1] and [IFC4 Add2 TC1]. Extending with support for arbitrary IFC schemas
is possible at compile-time when using C++ and at run-time when using Python.
+40
View File
@@ -0,0 +1,40 @@
# Dockerfile for Running AWS Lambda Function with Python and IfcOpenShell
# Base image: Python 3.9 from AWS's public container registry
FROM public.ecr.aws/docker/library/python:3.9 AS build
# Set the location of your Lambda function code
ARG FUNCTION_DIR="/var/task"
# Install necessary packages
RUN apt-get -y update && apt-get -y install unzip curl
# Install AWS Lambda runtime interface client
RUN pip install --target ${FUNCTION_DIR} awslambdaric
# Set the IfcOpenShell build version (check available builds at: https://blenderbim.org/docs-python/ifcopenshell-python/installation.html)
ARG IFC_OPENSHELL_BUILD="39-v0.7.0-476ab50"
# Download and extract IfcOpenShell
RUN curl https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-${IFC_OPENSHELL_BUILD}-linux64.zip -O && \
unzip ifcopenshell-python-${IFC_OPENSHELL_BUILD}-linux64.zip && \
mv ifcopenshell ${FUNCTION_DIR} && \
rm ifcopenshell-python-${IFC_OPENSHELL_BUILD}-linux64.zip
# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy the Lambda function code
COPY ./example_handler ${FUNCTION_DIR}/example_handler
# Set the working directory
WORKDIR ${FUNCTION_DIR}
# Set the entrypoint for the Lambda function
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
# Set the Python import path to the Lambda function handler
# This path is relative to the root of the Lambda function code (FUNCTION_DIR)
# Lambda invocation will look for this path
CMD ["example_handler.extract_wall_psets_handler"]
+48
View File
@@ -0,0 +1,48 @@
Dockerized AWS Lambda Function with Python and IfcOpenShell
===========================================================
This guide provides a Dockerfile and sample code to help you run an AWS Lambda function written in Python and utilizing IfcOpenShell library.
Prerequisites
-------------
Make sure you have Docker installed on your machine. You can download Docker from the official website: [Docker Instalation](https://docs.docker.com/engine/install/)
Getting Started
---------------
1. **Clone this repository to your local machine:**
2. **Customize the Lambda function code:**
- Replace the sample Lambda function code in the `example_handler` directory with your own code.
- Update the import path in the Dockerfile's `CMD` instruction to match your Lambda function's handler function.
3. **Install the required Python packages:**
- Edit the `requirements.txt` file and add any additional dependencies required by your Lambda function.
4. **Build the Docker image:**
```shell
$ docker build -t lambda-ifcopenshell .
```
5. **Run the Docker container:**
```shell
$ docker run lambda-ifcopenshell
```
6. **Test lambda locally**
Follow the steps in this [guide](https://docs.aws.amazon.com/lambda/latest/dg/images-test.html)
7. **Deploy to lambda**
This is beyond the scope of this example. Please refer to AWS documentation. Some tools that could be useful are - AWS CloudFormaton, AWS CDK, pulumi or terraform
---------
> Note: This is a superficial guide, in order to make this work for your usecase you will need a good understanding of other AWS services like SQS, S3, API Gateway etc.
For more information on building lambda containers refer to this [guide](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html).
+27
View File
@@ -0,0 +1,27 @@
import ifcopenshell
import ifcopenshell.util.element
import boto3
s3 = boto3.client('s3')
def extract_wall_psets_handler(event, context):
print("Hello from lambda")
print("Event: {}".format(event))
print("Context: {}".format(context))
filename = event['body']['filename']
s3.download_file('my_ifc_files_bucket', filename, f'/tmp/{filename}')
ifc_file = ifcopenshell.open(f'/tmp/{filename}')
walls = ifc_file.by_type('IfcWall')
psets = []
for wall in walls:
wall_data = ifcopenshell.util.element.get_psets(wall)
wall_data['id'] = wall.GlobalId
psets.append(wall_data)
return {
'statusCode': 200,
'body': psets
}
+1
View File
@@ -0,0 +1 @@
boto3
+69 -12
View File
@@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 3.1.3)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged
project (IfcOpenShell VERSION 0.7.0)
project(IfcOpenShell VERSION 0.7.0)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0074 NEW)
@@ -54,12 +54,14 @@ OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only."
OPTION(USE_MMAP "Adds a command line options to parse IFC files from memory mapped files using Boost.Iostreams" OFF)
OPTION(BUILD_SHARED_LIBS "Build IfcParse and IfcGeom as shared libs (SO/DLL)." OFF)
OPTION(MSVC_PARALLEL_BUILD "Multi-threaded compilation in Microsoft Visual Studio (/MP)" OFF)
OPTION(NO_WARN "Disable all warnings" OFF)
OPTION(WASM_BUILD OFF)
if (${HAS_MAX})
OPTION(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF)
endif()
if (${BUILD_CONVERT})
OPTION(GLTF_SUPPORT "Build IfcConvert with glTF support (requires json.hpp)." OFF)
OPTION(USD_SUPPORT "Build IfcConvert with USD support (requires pixar's USD library)." OFF)
endif()
OPTION(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF)
OPTION(ADD_COMMIT_SHA "Add commit sha and branch in version number, warning results in many rebuilds, requires git" OFF)
@@ -72,6 +74,14 @@ if(MSVC AND MSVC_PARALLEL_BUILD)
add_definitions("/MP")
endif()
if(NO_WARN)
if(MSVC)
add_compile_options("/w")
else()
add_compile_options("-w")
endif()
endif()
# QtViewer requires Qt5
OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer" OFF)
include(GNUInstallDirs)
@@ -137,11 +147,6 @@ UNIFY_ENVVARS_AND_CACHE(PYTHON_EXECUTABLE)
UNIFY_ENVVARS_AND_CACHE(HDF5_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(HDF5_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(HDF5_LIBRARIES)
endif()
UNIFY_ENVVARS_AND_CACHE(BOOST_ROOT)
UNIFY_ENVVARS_AND_CACHE(BOOST_LIBRARYDIR)
if (NOT MINIMAL_BUILD)
UNIFY_ENVVARS_AND_CACHE(CGAL_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(CGAL_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(GMP_INCLUDE_DIR)
@@ -149,6 +154,8 @@ UNIFY_ENVVARS_AND_CACHE(GMP_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_LIBRARY_DIR)
endif()
UNIFY_ENVVARS_AND_CACHE(BOOST_ROOT)
UNIFY_ENVVARS_AND_CACHE(BOOST_LIBRARYDIR)
if(WASM_BUILD)
# when using the nix/build-all.py build script we should not
@@ -170,6 +177,54 @@ add_definitions(-DWITH_GLTF)
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_GLTF)
endif()
# Add USD support to serializers
if(NOT MINIMAL_BUILD AND USD_SUPPORT)
UNIFY_ENVVARS_AND_CACHE(USD_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(USD_LIBRARY_DIR)
if("${USD_INCLUDE_DIR}" STREQUAL "")
find_path(USD_INCLUDE_DIR pxr.h
[PATHS
/usr/include/pxr
/usr/local/include/pxr
]
REQUIRED
)
if(USD_INCLUDE_DIR)
message(STATUS "Found USD include files in: ${USD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Unable to find USD include directory, specify USD_INCLUDE_DIR manually.")
endif()
else()
set(USD_INCLUDE_DIR ${USD_INCLUDE_DIR} CACHE FILEPATH "USD header files")
message(STATUS "Looking for USD include files in: ${USD_INCLUDE_DIR}")
endif()
set(USD_LIBRARIES
usd_usd
usd_usdGeom
usd_usdShade
usd_usdLux
usd_vt
usd_sdf
usd_tf
usd_gf
)
find_library(USD_LIBRARY
NAMES ${USD_LIBRARIES}
PATHS ${USD_LIBRARY_DIR})
if(USD_LIBRARY)
message(STATUS "USD libraries ${USD_LIBRARIES} found in: ${USD_LIBRARY_DIR}")
link_directories(${USD_LIBRARY_DIR})
else()
message(FATAL_ERROR "Unable to find USD libraries in: ${USD_LIBRARY_DIR}")
endif()
add_definitions(-DWITH_USD)
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_USD)
endif()
# Set INSTALL_RPATH for target
MACRO(SET_INSTALL_RPATHS _target _paths)
SET(${_target}_rpaths "")
@@ -633,6 +688,7 @@ ENDIF()
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}
${USD_INCLUDE_DIR}
)
function(files_for_ifc_version IFC_VERSION RESULT_NAME)
@@ -841,9 +897,9 @@ endforeach()
add_library(Serializers ${SERIALIZERS_FILES})
set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS ${CONVERT_PRECISION}" VERSION "0.6.0" SOVERSION "0.6")
TARGET_LINK_LIBRARIES(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES})
TARGET_LINK_LIBRARIES(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES})
endif(BUILD_CONVERT or BUILD_IFCPYTHON)
endif(BUILD_CONVERT OR BUILD_IFCPYTHON)
if (BUILD_CONVERT)
@@ -854,7 +910,7 @@ set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES})
ADD_EXECUTABLE(IfcConvert ${IFCCONVERT_FILES})
set_target_properties(IfcConvert PROPERTIES COMPILE_FLAGS "${CONVERT_PRECISION}")
TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES})
TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES} ${USD_LIBRARIES})
if ((NOT WIN32) AND BUILD_SHARED_LIBS)
# Only set RPATHs when building shared libraries (i.e. IfcParse and
@@ -897,7 +953,7 @@ find_package (Git)
if (GIT_FOUND)
message("git found: ${GIT_EXECUTABLE} with version ${GIT_VERSION_STRING}")
execute_process(
COMMAND ${GIT_EXECUTABLE} branch --contains HEAD
COMMAND ${GIT_EXECUTABLE} branch -a --contains HEAD
OUTPUT_VARIABLE git_branches
OUTPUT_STRIP_TRAILING_WHITESPACE
)
@@ -906,7 +962,8 @@ if (GIT_FOUND)
string(REPLACE "*" "" git_branch_candidate_temp "${git_branch_candidate}")
string(STRIP "${git_branch_candidate_temp}" git_branch_candidate_2)
if (NOT git_branch_candidate_2 MATCHES "^HEAD$")
set(git_branch ${git_branch_candidate_2})
string(REPLACE "/" ";" git_branch_candidate_2_list "${git_branch_candidate_2}")
list(GET git_branch_candidate_2_list -1 git_branch)
endif()
endforeach()
execute_process(
@@ -1017,7 +1074,7 @@ endforeach(COMPONENT)
set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3, libxml2, libocct-foundation-dev, libocct-modeling-algorithms-dev, libocct-modeling-data-dev, libocct-ocaf-dev, libocct-visualization-dev, libocct-data-exchange-dev, libhdf5-serial-dev, libpython3.8 ${BOOST_DEPS}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3, libxml2, libocct-foundation-dev, libocct-modeling-algorithms-dev, libocct-modeling-data-dev, libocct-ocaf-dev, libocct-visualization-dev, libocct-data-exchange-dev, libhdf5-serial-dev, libpython3.8, python3-pytest ${BOOST_DEPS}")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+1 -2
View File
@@ -10,5 +10,4 @@ dependencies:
- ripgrep
- pip
- pip:
- --extra-index-url https://lief.s3-website.fr-par.scw.cloud/latest
- lief==0.13.0.dev0
- lief==0.13
+5 -5
View File
@@ -1,8 +1,6 @@
{% set name = "ifcopenshell" %}
{% set version = "0.7.0" %}
{% set occt_version = "7.6.2" %}
{% set cgal_cpp_version = "5.3" %}
{% set hdf5_version = "1.12.1" %}
package:
name: {{ name }}
@@ -26,7 +24,7 @@ requirements:
host:
- python
- boost-cpp
- occt
- occt ==7.7.0
- libxml2
- cgal-cpp
- hdf5
@@ -34,11 +32,12 @@ requirements:
- gmp # [unix]
- mpir # [win]
- nlohmann_json
- zlib
run:
- python
- boost-cpp
- occt
- occt ==7.7.0
- libxml2
- cgal-cpp
- hdf5
@@ -46,6 +45,7 @@ requirements:
- gmp # [unix]
- mpir # [win]
- nlohmann_json
- zlib
test:
imports:
+4
View File
@@ -59,6 +59,10 @@ import multiprocessing
import platform
import sysconfig
# @todo temporary for expired mpfr.org certificate on 2023-04-08
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
from urllib.request import urlretrieve
+20
View File
@@ -0,0 +1,20 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: bcf
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- name: "IfcOpenShell contributors"
repository-code: >-
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/bcf
abstract: >-
Library to read and write BCF-XML and query OpenCDE
BCF-API modules
keywords:
- BCF
- IFC
license: LGPL-3.0-or-later
+1 -1
View File
@@ -11,7 +11,7 @@ name = "bcf-client"
description = "BCF-XML file handler."
readme = "README.md"
requires-python = ">=3.8"
keywords = ["IFC", "BCF", "BIM", "eingineering"]
keywords = ["IFC", "BCF", "BIM"]
dependencies = [
"xsdata",
"numpy",
+26
View File
@@ -0,0 +1,26 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: BlenderBIM Add-on
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- name: "IfcOpenShell contributors"
repository-code: >-
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/blenderbim
url: 'https://blenderbim.org/'
repository-artifact: 'https://blenderbim.org/download.html'
abstract: >-
Add-on to Blender providing a graphical native IFC
authoring platform
keywords:
- IFC
- Blender
- NativeIFC
license: GPL-3.0-or-later
commit: 1fb6dac
version: v0.0.230506
date-released: '2023-05-23'
+16 -29
View File
@@ -190,7 +190,7 @@ endif
cp -r blenderbim/* dist/blenderbim/
# Provides IfcOpenShell Python functionality
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v0.7.0-476ab50-$(PLATFORM)64.zip
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v0.7.0-8f41ae0-$(PLATFORM)64.zip
cd dist/working && unzip ifcopenshell-python*
cp -r dist/working/ifcopenshell dist/blenderbim/libs/site/packages/
@@ -236,6 +236,11 @@ endif
cp -r dist/working/IfcOpenShell-0.7.0/src/ifc5d/ifc5d dist/blenderbim/libs/site/packages/
# Provides IFCCityJSON functionality
cp -r dist/working/IfcOpenShell-0.7.0/src/ifccityjson dist/blenderbim/libs/site/packages/
# Provides IfcGit functionality
cd dist/working && . env/bin/activate && $(PIP) install GitPython --target=./site-packages
cp -r dist/working/site-packages/smmap dist/blenderbim/libs/site/packages/
cp -r dist/working/site-packages/gitdb dist/blenderbim/libs/site/packages/
cp -r dist/working/site-packages/git dist/blenderbim/libs/site/packages/
rm -rf dist/working
# Provides Mustache templating in construction documentation
@@ -403,7 +408,8 @@ endif
cd dist/working && . env/bin/activate && $(PIP) install cjio --target=./site-packages
# Provides express rule validation for ifcopenshell.validate
cd dist/working && . env/bin/activate && $(PIP) install pytest --target=./site-packages
cd dist/working/site-packages/ && rm -r *dist-info*
# Provides Brickschema functionality
cd dist/working && . env/bin/activate && $(PIP) install brickschema[persistence] --target=./site-packages
cp -r dist/working/site-packages/* dist/blenderbim/libs/site/packages/
rm -rf dist/working
@@ -613,35 +619,9 @@ endif
# Provides Brickschema functionality
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/ca/37/8309da9a72407d2f5eb5489c197ac3cfe96ee3ccba1902d2a0ecc7843f92/brickschema-0.5.1.tar.gz
cd dist/working && tar -xzvf brickschema*
# This is an evil hack because we don't want to bundle flask
echo "" > dist/working/brickschema-0.5.1/brickschema/web.py
cd dist/working/brickschema-0.5.1/ && cp -r brickschema ../../blenderbim/libs/site/packages/
# For now lets bundle the latest nightly schema
cd dist/working && wget https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl
cd dist/working && cp Brick.ttl ../../blenderbim/bim/schema/Brick.ttl
rm -rf dist/working
# Required by brickschema
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/c7/22/37bb938be8e5c20d443b0c9ba0a243573b671b01739efb0a19f81bc5b470/pyshacl-0.17.2.tar.gz
cd dist/working && tar -xzvf pyshacl*
cd dist/working/pyshacl-0.17.2/ && cp -r pyshacl ../../blenderbim/libs/site/packages/
rm -rf dist/working
# Required by brickschema
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/d2/a7/be8244688bfcee37c23733ab4fe8e6afa6d4403bd2674a3ae7bd2cecc77b/rdflib-6.0.2.tar.gz
cd dist/working && tar -xzvf rdflib*
cd dist/working/rdflib-6.0.2/ && cp -r rdflib ../../blenderbim/libs/site/packages/
rm -rf dist/working
# Required by brickschema
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/7d/c7/208aece36279e4f1236e437119358786e39530ecc1719d4e1afeddba5288/owlrl-6.0.2.tar.gz
cd dist/working && tar -xzvf owlrl*
cd dist/working/owlrl-6.0.2/ && cp -r owlrl ../../blenderbim/libs/site/packages/
cd dist/working && cp Brick.ttl ../blenderbim/bim/schema/Brick.ttl
rm -rf dist/working
# Required by brickschema
@@ -659,6 +639,13 @@ endif
cp -r dist/working/bpypolyskel-master/bpypolyskel dist/blenderbim/libs/site/packages/
rm -rf dist/working
# Required for Desktop icon and file association
cp -r blenderbim/libs/desktop dist/blenderbim/libs/
# Remove dependencies also bundled with Blender
rm -rf dist/blenderbim/libs/site/packages/numpy
rm -rf dist/blenderbim/libs/site/packages/numpy.libs
cd dist/blenderbim && $(SED) "s/999999/$(VERSION)/" __init__.py
cd dist && zip -r blenderbim-$(VERSION)-$(PYVERSION)-$(PLATFORM).zip ./*
rm -rf dist/blenderbim
+2 -1
View File
@@ -34,7 +34,8 @@ bl_info = {
if sys.modules.get("bpy", None):
# Process *.pth in /libs/site/packages to setup globally importable modules
# This is 3 levels deep as required by the static RPATH of ../../ from dependencies taken from Anaconda
site.addsitedir(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
# site.addsitedir(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
import blenderbim.bim
+14 -3
View File
@@ -17,6 +17,7 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
import blenderbim
import importlib
from . import handler, ui, prop, operator, helper
@@ -70,6 +71,7 @@ modules = {
"covetool": None,
"augin": None,
"debug": None,
"ifcgit": None,
# Uncomment this line to enable loading of the demo module. Happy hacking!
# The name "demo" must correlate to a folder name in `bim/module/`.
# "demo": None,
@@ -93,6 +95,8 @@ classes = [
operator.SelectIfcFile,
operator.ReloadSelectedIfcFile,
operator.SelectSchemaDir,
operator.FileAssociate,
operator.FileUnassociate,
operator.SelectURIAttribute,
operator.EditBlenderCollection,
operator.BIM_OT_open_webbrowser,
@@ -107,6 +111,7 @@ classes = [
prop.PsetQto,
prop.GlobalId,
prop.BIMObjectProperties,
prop.BIMCollectionProperties,
prop.BIMMaterialProperties,
prop.BIMMeshProperties,
ui.BIM_PT_section_plane,
@@ -152,8 +157,9 @@ def register():
bpy.app.handlers.redo_post.append(handler.redo_post)
bpy.app.handlers.load_post.append(handler.setDefaultProperties)
bpy.app.handlers.load_post.append(handler.loadIfcStore)
bpy.app.handlers.save_pre.append(handler.ensureIfcExported)
bpy.app.handlers.save_post.append(handler.ensureIfcExported)
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties)
bpy.types.Collection.BIMCollectionProperties = bpy.props.PointerProperty(type=prop.BIMCollectionProperties)
bpy.types.Object.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties)
bpy.types.Material.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties)
bpy.types.Material.BIMMaterialProperties = bpy.props.PointerProperty(type=prop.BIMMaterialProperties)
@@ -171,11 +177,16 @@ def register():
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if getattr(cls, "is_registered", None) is None:
bpy.utils.unregister_class(cls)
elif cls.is_registered:
bpy.utils.unregister_class(cls)
bpy.app.handlers.load_post.remove(handler.setDefaultProperties)
bpy.app.handlers.load_post.remove(handler.loadIfcStore)
bpy.app.handlers.save_pre.remove(handler.ensureIfcExported)
bpy.app.handlers.save_post.remove(handler.ensureIfcExported)
del bpy.types.Scene.BIMProperties
del bpy.types.Collection.BIMCollectionProperties
del bpy.types.Object.BIMObjectProperties
del bpy.types.Material.BIMObjectProperties
del bpy.types.Material.BIMMaterialProperties
@@ -19,9 +19,10 @@
*/
* { stroke-linecap: round; stroke-linejoin: round; }
text { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT', 'DejaVu Sans Condensed', 'Liberation Sans', 'Arial Narrow', 'Arial'; font-size: 4.13px; }
text, tspan { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT', 'DejaVu Sans Condensed', 'Liberation Sans', 'Arial Narrow', 'Arial'; font-size: 4.13px; }
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; fill-rule: evenodd; }
.projection { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
.surface { stroke: none; fill: #fff; fill-rule: evenodd; }
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
.IfcAnnotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
.IfcGeographicElement { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 1; }
@@ -33,7 +34,11 @@ text { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT',
.PredefinedType-PLANLEVEL { marker-end: url(#plan-level-marker); }
.PredefinedType-DIMENSION { marker-start: url(#dimension-marker-start); marker-end: url(#dimension-marker-end); }
.PredefinedType-ANGLE { marker-start: url(#angle-marker-start); marker-end: url(#angle-marker-end); }
.PredefinedType-RADIUS { marker-end: url(#radius-marker-end); }
.PredefinedType-RADIUS { marker-end: url(#fall-marker-end); }
.PredefinedType-FALL { marker-end: url(#radius-marker-end); }
.PredefinedType-SLOPEANGLE { marker-end: url(#radius-marker-end); }
.PredefinedType-SLOPEPERCENT { marker-end: url(#radius-marker-end); }
.PredefinedType-SLOPEFRACTION { marker-end: url(#radius-marker-end); }
.PredefinedType-DIAMETER { marker-start: url(#diameter-marker-start); marker-end: url(#diameter-marker-end); }
.PredefinedType-HIDDENLINE { stroke-dasharray: 3, 2; }
.PredefinedType-STAIRARROW { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
@@ -43,13 +48,13 @@ text { /* 2.5mm */ fill: black; stroke: none; font-family: 'OpenGost Type B TT',
.PredefinedType-BREAKLINE { fill: none; stroke: black; stroke-width: 0.25; marker-mid: url(#breakline-marker); }
.PredefinedType-TEXT { fill: black; stroke: none; }
path.PredefinedType-TEXTLEADER { marker-end: url(#leader-marker); }
text.PredefinedType-TEXTLEADER { fill: black; stroke: none; }
text.title { /* 7mm */ font-size: 11.55px; }
text.header { /* 5mm */ font-size: 8.25px; }
text.large { /* 3.5mm */ font-size: 5.78px; }
text.regular { /* 2.5mm */ font-size: 4.13px; }
text.small { /* 1.8mm */ font-size: 2.97px; }
text.GRID { /* 5mm */ font-size: 8.25px; }
text.PredefinedType-TEXTLEADER, tspan.PredefinedType-TEXTLEADER { fill: black; stroke: none; }
text.title, tspan.title { /* 7mm */ font-size: 11.55px; }
text.header, tspan.header { /* 5mm */ font-size: 8.25px; }
text.large, tspan.large { /* 3.5mm */ font-size: 5.78px; }
text.regular, tspan.regular { /* 2.5mm */ font-size: 4.13px; }
text.small, tspan.small { /* 1.8mm */ font-size: 2.97px; }
text.GRID, tspan.GRID { /* 5mm */ font-size: 8.25px; }
.material-blank { fill: white; }
.material-diagonal1 { fill: url(#diagonal1); }
.material-diagonal2 { fill: url(#diagonal2); }
@@ -19,6 +19,12 @@
<path d="M 0 3.5 L 0 10.5 L 10 7" class="annotation" style="fill:black;" />
</g>
</marker>
<!-- same as for the radius -->
<marker id="fall-marker-end" markerHeight="14" markerWidth="11" orient="auto" refX="10" refY="7">
<g>
<path d="M 0 3.5 L 0 10.5 L 10 7" class="annotation" style="fill:black;" />
</g>
</marker>
<marker id="angle-marker-start" markerHeight="14" markerWidth="11" orient="auto" refX="1" refY="7">
<g>
<path d="M 11 3.5 L 11 10.5 L 1 7" class="annotation" style="fill:black;" />
@@ -90,4 +96,12 @@
<path d="M 7.5 10 L 10 0 L 15 10" class="annotation" style="stroke-width:1; fill: white;" />
</g>
</marker>
<filter x="0" y="0" width="1" height="1" id="fill-background">
<feFlood flood-color="white" result="bg" />
<feMerge>
<feMergeNode in="bg"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</svg>

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

@@ -17,16 +17,49 @@
<line x1="0" y1="0" x2="0" y2="3" style="stroke:black; stroke-width:0.25" />
</pattern>
<pattern id="square1" width="1" height="1" patternUnits="userSpaceOnUse">
<line x1="0" y1="0" x2="0" y2="1" style="stroke:black; stroke-width:0.25" />
<line x1="0" y1="0" x2="1" y2="0" style="stroke:black; stroke-width:0.25" />
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 1 0 1 1" />
</pattern>
<pattern id="square2" width="2" height="2" patternUnits="userSpaceOnUse">
<line x1="0" y1="0" x2="0" y2="2" style="stroke:black; stroke-width:0.25" />
<line x1="0" y1="0" x2="2" y2="0" style="stroke:black; stroke-width:0.25" />
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 2 0 2 2" />
</pattern>
<pattern id="square3" width="3" height="3" patternUnits="userSpaceOnUse">
<line x1="0" y1="0" x2="0" y2="3" style="stroke:black; stroke-width:0.25" />
<line x1="0" y1="0" x2="3" y2="0" style="stroke:black; stroke-width:0.25" />
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 3 0 3 3" />
</pattern>
<pattern id="recth1" width="2" height="1" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 2 0 2 1" />
</pattern>
<pattern id="recth2" width="4" height="2" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 4 0 4 2" />
</pattern>
<pattern id="recth3" width="6" height="3" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 6 0 6 3" />
</pattern>
<pattern id="rectv1" width="1" height="2" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 1 0 1 2" />
</pattern>
<pattern id="rectv2" width="2" height="4" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 2 0 2 4" />
</pattern>
<pattern id="rectv3" width="3" height="6" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.25; fill: none;" d="M 0 0 3 0 3 6" />
</pattern>
<pattern id="tile1" width="2" height="2" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 2 0 2 1 0 1 M 1 1 1 2" />
</pattern>
<pattern id="tile2" width="4" height="4" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 4 0 4 2 0 2 M 2 2 2 4" />
</pattern>
<pattern id="tile3" width="6" height="6" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 6 0 6 3 0 3 M 3 3 3 6" />
</pattern>
<pattern id="board1" width="4" height="2" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 4 0 4 1 0 1 M 2 1 2 2" />
</pattern>
<pattern id="board2" width="8" height="4" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 8 0 8 2 0 2 M 4 2 4 4" />
</pattern>
<pattern id="board3" width="12" height="6" patternUnits="userSpaceOnUse">
<path style="stroke: black; stroke-width: 0.15; fill: none;" d="M 0 0 12 0 12 3 0 3 M 6 3 6 6" />
</pattern>
<pattern id="crosshatch1" width="1" height="1" patternTransform="rotate(45 0 0)" patternUnits="userSpaceOnUse">
<line x1="0" y1="0" x2="0" y2="1" style="stroke:black; stroke-width:0.25" />

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 69 KiB

@@ -0,0 +1,755 @@
{
"Technical": {
"render_type": "VIEWPORT",
"raster_style": {
"bpy.data.worlds[0].color": [
1.0,
1.0,
1.0
],
"scene.render.bake_bias": 0.0010000000474974513,
"scene.render.bake_margin": 16,
"scene.render.bake_margin_type": "ADJACENT_FACES",
"scene.render.bake_samples": 256,
"scene.render.bake_type": "NORMALS",
"scene.render.bake_user_scale": 0.0,
"scene.render.border_max_x": 1.0,
"scene.render.border_max_y": 1.0,
"scene.render.border_min_x": 0.0,
"scene.render.border_min_y": 0.0,
"scene.render.dither_intensity": 1.0,
"scene.render.engine": "BLENDER_WORKBENCH",
"scene.render.film_transparent": false,
"scene.render.filter_size": 1.5,
"scene.render.fps": 24,
"scene.render.fps_base": 1.0,
"scene.render.frame_map_new": 100,
"scene.render.frame_map_old": 100,
"scene.render.hair_subdiv": 0,
"scene.render.hair_type": "STRAND",
"scene.render.line_thickness": 1.0,
"scene.render.line_thickness_mode": "ABSOLUTE",
"scene.render.metadata_input": "SCENE",
"scene.render.motion_blur_shutter": 0.5,
"scene.render.pixel_aspect_x": 1.0,
"scene.render.pixel_aspect_y": 1.0,
"scene.render.preview_pixel_size": "AUTO",
"scene.render.resolution_percentage": 100,
"scene.render.resolution_x": 1000,
"scene.render.resolution_y": 1000,
"scene.render.sequencer_gl_preview": "SOLID",
"scene.render.simplify_child_particles": 1.0,
"scene.render.simplify_child_particles_render": 1.0,
"scene.render.simplify_gpencil": false,
"scene.render.simplify_gpencil_antialiasing": true,
"scene.render.simplify_gpencil_modifier": true,
"scene.render.simplify_gpencil_onplay": false,
"scene.render.simplify_gpencil_shader_fx": true,
"scene.render.simplify_gpencil_tint": true,
"scene.render.simplify_gpencil_view_fill": true,
"scene.render.simplify_shadows": 1.0,
"scene.render.simplify_shadows_render": 1.0,
"scene.render.simplify_subdivision": 6,
"scene.render.simplify_subdivision_render": 6,
"scene.render.simplify_volumes": 1.0,
"scene.render.stamp_font_size": 12,
"scene.render.stamp_note_text": "",
"scene.render.threads": 20,
"scene.render.threads_mode": "AUTO",
"scene.render.use_bake_clear": true,
"scene.render.use_bake_lores_mesh": false,
"scene.render.use_bake_multires": false,
"scene.render.use_bake_selected_to_active": false,
"scene.render.use_bake_user_scale": false,
"scene.render.use_border": false,
"scene.render.use_compositing": true,
"scene.render.use_crop_to_border": false,
"scene.render.use_file_extension": true,
"scene.render.use_freestyle": false,
"scene.render.use_high_quality_normals": false,
"scene.render.use_lock_interface": false,
"scene.render.use_motion_blur": false,
"scene.render.use_multiview": false,
"scene.render.use_overwrite": true,
"scene.render.use_persistent_data": false,
"scene.render.use_placeholder": false,
"scene.render.use_render_cache": false,
"scene.render.use_sequencer": true,
"scene.render.use_sequencer_override_scene_strip": false,
"scene.render.use_simplify": false,
"scene.render.use_single_layer": false,
"scene.render.use_stamp": false,
"scene.render.use_stamp_camera": true,
"scene.render.use_stamp_date": true,
"scene.render.use_stamp_filename": true,
"scene.render.use_stamp_frame": true,
"scene.render.use_stamp_frame_range": false,
"scene.render.use_stamp_hostname": false,
"scene.render.use_stamp_labels": true,
"scene.render.use_stamp_lens": false,
"scene.render.use_stamp_marker": false,
"scene.render.use_stamp_memory": false,
"scene.render.use_stamp_note": false,
"scene.render.use_stamp_render_time": true,
"scene.render.use_stamp_scene": true,
"scene.render.use_stamp_sequencer_strip": false,
"scene.render.use_stamp_time": true,
"scene.render.views_format": "STEREO_3D",
"scene.view_settings.exposure": 0.0,
"scene.view_settings.gamma": 1.0,
"scene.view_settings.look": "None",
"scene.view_settings.use_curve_mapping": false,
"scene.view_settings.view_transform": "Standard",
"scene.display.shading.aov_name": "",
"scene.display.shading.background_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.background_type": "THEME",
"scene.display.shading.cavity_ridge_factor": 1.0,
"scene.display.shading.cavity_type": "BOTH",
"scene.display.shading.cavity_valley_factor": 1.0,
"scene.display.shading.color_type": "SINGLE",
"scene.display.shading.curvature_ridge_factor": 1.0,
"scene.display.shading.curvature_valley_factor": 1.0,
"scene.display.shading.light": "FLAT",
"scene.display.shading.object_outline_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.render_pass": "COMBINED",
"scene.display.shading.shadow_intensity": 0.5,
"scene.display.shading.show_backface_culling": false,
"scene.display.shading.show_cavity": false,
"scene.display.shading.show_object_outline": true,
"scene.display.shading.show_shadows": false,
"scene.display.shading.show_specular_highlight": true,
"scene.display.shading.show_xray": false,
"scene.display.shading.show_xray_wireframe": false,
"scene.display.shading.single_color": [
1.0,
1.0,
1.0
],
"scene.display.shading.studio_light": "Default",
"scene.display.shading.studiolight_background_alpha": 0.0,
"scene.display.shading.studiolight_background_blur": 0.0,
"scene.display.shading.studiolight_intensity": 0.0,
"scene.display.shading.studiolight_rotate_z": 0.0,
"scene.display.shading.type": "SOLID",
"scene.display.shading.use_compositor": "DISABLED",
"scene.display.shading.use_dof": false,
"scene.display.shading.use_scene_lights": false,
"scene.display.shading.use_scene_lights_render": false,
"scene.display.shading.use_scene_world": false,
"scene.display.shading.use_scene_world_render": false,
"scene.display.shading.use_studiolight_view_rotation": true,
"scene.display.shading.use_world_space_lighting": false,
"scene.display.shading.wireframe_color_type": "MATERIAL",
"scene.display.shading.xray_alpha": 0.5,
"scene.display.shading.xray_alpha_wireframe": 0.0,
"scene.display.light_direction": [
0.5,
0.5,
0.5
],
"scene.display.matcap_ssao_attenuation": 1.0,
"scene.display.matcap_ssao_distance": 0.20000000298023224,
"scene.display.matcap_ssao_samples": 16,
"scene.display.render_aa": "8",
"scene.display.shadow_focus": 0.0,
"scene.display.shadow_shift": 0.10000000149011612,
"scene.display.viewport_aa": "FXAA",
"space.overlay.backwire_opacity": 0.5,
"space.overlay.bone_wire_alpha": 1.0,
"space.overlay.display_handle": "SELECTED",
"space.overlay.fade_inactive_alpha": 0.4000000059604645,
"space.overlay.gpencil_fade_layer": 0.5,
"space.overlay.gpencil_fade_objects": 0.5,
"space.overlay.gpencil_grid_opacity": 0.5,
"space.overlay.gpencil_vertex_paint_opacity": 1.0,
"space.overlay.grid_lines": 16,
"space.overlay.grid_scale": 1.0,
"space.overlay.grid_subdivisions": 10,
"space.overlay.normals_constant_screen_size": 7.0,
"space.overlay.normals_length": 0.10000000149011612,
"space.overlay.sculpt_curves_cage_opacity": 0.5,
"space.overlay.sculpt_mode_face_sets_opacity": 1.0,
"space.overlay.sculpt_mode_mask_opacity": 0.75,
"space.overlay.show_annotation": true,
"space.overlay.show_axis_x": false,
"space.overlay.show_axis_y": false,
"space.overlay.show_axis_z": false,
"space.overlay.show_bones": true,
"space.overlay.show_cursor": true,
"space.overlay.show_curve_normals": false,
"space.overlay.show_edge_bevel_weight": true,
"space.overlay.show_edge_crease": true,
"space.overlay.show_edge_seams": true,
"space.overlay.show_edge_sharp": true,
"space.overlay.show_edges": false,
"space.overlay.show_extra_edge_angle": false,
"space.overlay.show_extra_edge_length": false,
"space.overlay.show_extra_face_angle": false,
"space.overlay.show_extra_face_area": false,
"space.overlay.show_extra_indices": false,
"space.overlay.show_extras": true,
"space.overlay.show_face_center": false,
"space.overlay.show_face_normals": false,
"space.overlay.show_face_orientation": false,
"space.overlay.show_faces": true,
"space.overlay.show_fade_inactive": false,
"space.overlay.show_floor": false,
"space.overlay.show_freestyle_edge_marks": true,
"space.overlay.show_freestyle_face_marks": true,
"space.overlay.show_look_dev": false,
"space.overlay.show_motion_paths": true,
"space.overlay.show_object_origins": false,
"space.overlay.show_object_origins_all": false,
"space.overlay.show_occlude_wire": false,
"space.overlay.show_onion_skins": false,
"space.overlay.show_ortho_grid": true,
"space.overlay.show_outline_selected": true,
"space.overlay.show_overlays": true,
"space.overlay.show_paint_wire": false,
"space.overlay.show_relationship_lines": false,
"space.overlay.show_sculpt_curves_cage": true,
"space.overlay.show_sculpt_face_sets": true,
"space.overlay.show_sculpt_mask": true,
"space.overlay.show_split_normals": false,
"space.overlay.show_stats": false,
"space.overlay.show_statvis": false,
"space.overlay.show_text": true,
"space.overlay.show_vertex_normals": false,
"space.overlay.show_viewer_attribute": true,
"space.overlay.show_weight": false,
"space.overlay.show_wireframes": true,
"space.overlay.show_wpaint_contours": false,
"space.overlay.show_xray_bone": false,
"space.overlay.texture_paint_mode_opacity": 1.0,
"space.overlay.use_debug_freeze_view_culling": false,
"space.overlay.use_gpencil_canvas_xray": false,
"space.overlay.use_gpencil_edit_lines": true,
"space.overlay.use_gpencil_fade_gp_objects": false,
"space.overlay.use_gpencil_fade_layers": false,
"space.overlay.use_gpencil_fade_objects": false,
"space.overlay.use_gpencil_grid": false,
"space.overlay.use_gpencil_multiedit_line_only": false,
"space.overlay.use_gpencil_onion_skin": false,
"space.overlay.use_gpencil_show_directions": false,
"space.overlay.use_gpencil_show_material_name": false,
"space.overlay.use_normals_constant_screen_size": false,
"space.overlay.vertex_opacity": 1.0,
"space.overlay.vertex_paint_mode_opacity": 1.0,
"space.overlay.viewer_attribute_opacity": 1.0,
"space.overlay.weight_paint_mode_opacity": 1.0,
"space.overlay.wireframe_opacity": 1.0,
"space.overlay.wireframe_threshold": 0.0,
"space.overlay.xray_alpha_bone": 0.0
}
},
"Shaded": {
"render_type": "VIEWPORT",
"raster_style": {
"bpy.data.worlds[0].color": [
1.0,
1.0,
1.0
],
"scene.render.bake_bias": 0.0010000000474974513,
"scene.render.bake_margin": 16,
"scene.render.bake_margin_type": "ADJACENT_FACES",
"scene.render.bake_samples": 256,
"scene.render.bake_type": "NORMALS",
"scene.render.bake_user_scale": 0.0,
"scene.render.border_max_x": 1.0,
"scene.render.border_max_y": 1.0,
"scene.render.border_min_x": 0.0,
"scene.render.border_min_y": 0.0,
"scene.render.dither_intensity": 1.0,
"scene.render.engine": "BLENDER_WORKBENCH",
"scene.render.film_transparent": false,
"scene.render.filter_size": 1.5,
"scene.render.fps": 24,
"scene.render.fps_base": 1.0,
"scene.render.frame_map_new": 100,
"scene.render.frame_map_old": 100,
"scene.render.hair_subdiv": 0,
"scene.render.hair_type": "STRAND",
"scene.render.line_thickness": 1.0,
"scene.render.line_thickness_mode": "ABSOLUTE",
"scene.render.metadata_input": "SCENE",
"scene.render.motion_blur_shutter": 0.5,
"scene.render.pixel_aspect_x": 1.0,
"scene.render.pixel_aspect_y": 1.0,
"scene.render.preview_pixel_size": "AUTO",
"scene.render.resolution_percentage": 100,
"scene.render.resolution_x": 1000,
"scene.render.resolution_y": 1000,
"scene.render.sequencer_gl_preview": "SOLID",
"scene.render.simplify_child_particles": 1.0,
"scene.render.simplify_child_particles_render": 1.0,
"scene.render.simplify_gpencil": false,
"scene.render.simplify_gpencil_antialiasing": true,
"scene.render.simplify_gpencil_modifier": true,
"scene.render.simplify_gpencil_onplay": false,
"scene.render.simplify_gpencil_shader_fx": true,
"scene.render.simplify_gpencil_tint": true,
"scene.render.simplify_gpencil_view_fill": true,
"scene.render.simplify_shadows": 1.0,
"scene.render.simplify_shadows_render": 1.0,
"scene.render.simplify_subdivision": 6,
"scene.render.simplify_subdivision_render": 6,
"scene.render.simplify_volumes": 1.0,
"scene.render.stamp_font_size": 12,
"scene.render.stamp_note_text": "",
"scene.render.threads": 20,
"scene.render.threads_mode": "AUTO",
"scene.render.use_bake_clear": true,
"scene.render.use_bake_lores_mesh": false,
"scene.render.use_bake_multires": false,
"scene.render.use_bake_selected_to_active": false,
"scene.render.use_bake_user_scale": false,
"scene.render.use_border": false,
"scene.render.use_compositing": true,
"scene.render.use_crop_to_border": false,
"scene.render.use_file_extension": true,
"scene.render.use_freestyle": false,
"scene.render.use_high_quality_normals": false,
"scene.render.use_lock_interface": false,
"scene.render.use_motion_blur": false,
"scene.render.use_multiview": false,
"scene.render.use_overwrite": true,
"scene.render.use_persistent_data": false,
"scene.render.use_placeholder": false,
"scene.render.use_render_cache": false,
"scene.render.use_sequencer": true,
"scene.render.use_sequencer_override_scene_strip": false,
"scene.render.use_simplify": false,
"scene.render.use_single_layer": false,
"scene.render.use_stamp": false,
"scene.render.use_stamp_camera": true,
"scene.render.use_stamp_date": true,
"scene.render.use_stamp_filename": true,
"scene.render.use_stamp_frame": true,
"scene.render.use_stamp_frame_range": false,
"scene.render.use_stamp_hostname": false,
"scene.render.use_stamp_labels": true,
"scene.render.use_stamp_lens": false,
"scene.render.use_stamp_marker": false,
"scene.render.use_stamp_memory": false,
"scene.render.use_stamp_note": false,
"scene.render.use_stamp_render_time": true,
"scene.render.use_stamp_scene": true,
"scene.render.use_stamp_sequencer_strip": false,
"scene.render.use_stamp_time": true,
"scene.render.views_format": "STEREO_3D",
"scene.view_settings.exposure": 0.0,
"scene.view_settings.gamma": 1.0,
"scene.view_settings.look": "None",
"scene.view_settings.use_curve_mapping": false,
"scene.view_settings.view_transform": "Standard",
"scene.display.shading.aov_name": "",
"scene.display.shading.background_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.background_type": "THEME",
"scene.display.shading.cavity_ridge_factor": 1.0,
"scene.display.shading.cavity_type": "BOTH",
"scene.display.shading.cavity_valley_factor": 1.0,
"scene.display.shading.color_type": "MATERIAL",
"scene.display.shading.curvature_ridge_factor": 1.0,
"scene.display.shading.curvature_valley_factor": 1.0,
"scene.display.shading.light": "STUDIO",
"scene.display.shading.object_outline_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.render_pass": "COMBINED",
"scene.display.shading.shadow_intensity": 0.5,
"scene.display.shading.show_backface_culling": false,
"scene.display.shading.show_cavity": true,
"scene.display.shading.show_object_outline": true,
"scene.display.shading.show_shadows": true,
"scene.display.shading.show_specular_highlight": true,
"scene.display.shading.show_xray": false,
"scene.display.shading.show_xray_wireframe": false,
"scene.display.shading.single_color": [
1.0,
1.0,
1.0
],
"scene.display.shading.studio_light": "Default",
"scene.display.shading.studiolight_background_alpha": 0.0,
"scene.display.shading.studiolight_background_blur": 0.0,
"scene.display.shading.studiolight_intensity": 0.0,
"scene.display.shading.studiolight_rotate_z": 0.0,
"scene.display.shading.type": "SOLID",
"scene.display.shading.use_compositor": "DISABLED",
"scene.display.shading.use_dof": false,
"scene.display.shading.use_scene_lights": false,
"scene.display.shading.use_scene_lights_render": false,
"scene.display.shading.use_scene_world": false,
"scene.display.shading.use_scene_world_render": false,
"scene.display.shading.use_studiolight_view_rotation": true,
"scene.display.shading.use_world_space_lighting": false,
"scene.display.shading.wireframe_color_type": "MATERIAL",
"scene.display.shading.xray_alpha": 0.5,
"scene.display.shading.xray_alpha_wireframe": 0.0,
"scene.display.light_direction": [
0.5,
0.5,
0.5
],
"scene.display.matcap_ssao_attenuation": 1.0,
"scene.display.matcap_ssao_distance": 0.20000000298023224,
"scene.display.matcap_ssao_samples": 16,
"scene.display.render_aa": "8",
"scene.display.shadow_focus": 0.0,
"scene.display.shadow_shift": 0.10000000149011612,
"scene.display.viewport_aa": "FXAA",
"space.overlay.backwire_opacity": 0.5,
"space.overlay.bone_wire_alpha": 1.0,
"space.overlay.display_handle": "SELECTED",
"space.overlay.fade_inactive_alpha": 0.4000000059604645,
"space.overlay.gpencil_fade_layer": 0.5,
"space.overlay.gpencil_fade_objects": 0.5,
"space.overlay.gpencil_grid_opacity": 0.5,
"space.overlay.gpencil_vertex_paint_opacity": 1.0,
"space.overlay.grid_lines": 16,
"space.overlay.grid_scale": 1.0,
"space.overlay.grid_subdivisions": 10,
"space.overlay.normals_constant_screen_size": 7.0,
"space.overlay.normals_length": 0.10000000149011612,
"space.overlay.sculpt_curves_cage_opacity": 0.5,
"space.overlay.sculpt_mode_face_sets_opacity": 1.0,
"space.overlay.sculpt_mode_mask_opacity": 0.75,
"space.overlay.show_annotation": true,
"space.overlay.show_axis_x": false,
"space.overlay.show_axis_y": false,
"space.overlay.show_axis_z": false,
"space.overlay.show_bones": true,
"space.overlay.show_cursor": true,
"space.overlay.show_curve_normals": false,
"space.overlay.show_edge_bevel_weight": true,
"space.overlay.show_edge_crease": true,
"space.overlay.show_edge_seams": true,
"space.overlay.show_edge_sharp": true,
"space.overlay.show_edges": false,
"space.overlay.show_extra_edge_angle": false,
"space.overlay.show_extra_edge_length": false,
"space.overlay.show_extra_face_angle": false,
"space.overlay.show_extra_face_area": false,
"space.overlay.show_extra_indices": false,
"space.overlay.show_extras": true,
"space.overlay.show_face_center": false,
"space.overlay.show_face_normals": false,
"space.overlay.show_face_orientation": false,
"space.overlay.show_faces": true,
"space.overlay.show_fade_inactive": false,
"space.overlay.show_floor": false,
"space.overlay.show_freestyle_edge_marks": true,
"space.overlay.show_freestyle_face_marks": true,
"space.overlay.show_look_dev": false,
"space.overlay.show_motion_paths": true,
"space.overlay.show_object_origins": false,
"space.overlay.show_object_origins_all": false,
"space.overlay.show_occlude_wire": false,
"space.overlay.show_onion_skins": false,
"space.overlay.show_ortho_grid": true,
"space.overlay.show_outline_selected": true,
"space.overlay.show_overlays": true,
"space.overlay.show_paint_wire": false,
"space.overlay.show_relationship_lines": false,
"space.overlay.show_sculpt_curves_cage": true,
"space.overlay.show_sculpt_face_sets": true,
"space.overlay.show_sculpt_mask": true,
"space.overlay.show_split_normals": false,
"space.overlay.show_stats": false,
"space.overlay.show_statvis": false,
"space.overlay.show_text": true,
"space.overlay.show_vertex_normals": false,
"space.overlay.show_viewer_attribute": true,
"space.overlay.show_weight": false,
"space.overlay.show_wireframes": false,
"space.overlay.show_wpaint_contours": false,
"space.overlay.show_xray_bone": false,
"space.overlay.texture_paint_mode_opacity": 1.0,
"space.overlay.use_debug_freeze_view_culling": false,
"space.overlay.use_gpencil_canvas_xray": false,
"space.overlay.use_gpencil_edit_lines": true,
"space.overlay.use_gpencil_fade_gp_objects": false,
"space.overlay.use_gpencil_fade_layers": false,
"space.overlay.use_gpencil_fade_objects": false,
"space.overlay.use_gpencil_grid": false,
"space.overlay.use_gpencil_multiedit_line_only": false,
"space.overlay.use_gpencil_onion_skin": false,
"space.overlay.use_gpencil_show_directions": false,
"space.overlay.use_gpencil_show_material_name": false,
"space.overlay.use_normals_constant_screen_size": false,
"space.overlay.vertex_opacity": 1.0,
"space.overlay.vertex_paint_mode_opacity": 1.0,
"space.overlay.viewer_attribute_opacity": 1.0,
"space.overlay.weight_paint_mode_opacity": 1.0,
"space.overlay.wireframe_opacity": 1.0,
"space.overlay.wireframe_threshold": 0.0,
"space.overlay.xray_alpha_bone": 0.0
}
},
"Blender Default": {
"render_type": "VIEWPORT",
"raster_style": {
"bpy.data.worlds[0].color": [
0.05087608844041824,
0.05087608844041824,
0.05087608844041824
],
"scene.render.bake_bias": 0.0010000000474974513,
"scene.render.bake_margin": 16,
"scene.render.bake_margin_type": "ADJACENT_FACES",
"scene.render.bake_samples": 256,
"scene.render.bake_type": "NORMALS",
"scene.render.bake_user_scale": 0.0,
"scene.render.border_max_x": 1.0,
"scene.render.border_max_y": 1.0,
"scene.render.border_min_x": 0.0,
"scene.render.border_min_y": 0.0,
"scene.render.dither_intensity": 1.0,
"scene.render.engine": "BLENDER_EEVEE",
"scene.render.film_transparent": false,
"scene.render.filter_size": 1.5,
"scene.render.fps": 24,
"scene.render.fps_base": 1.0,
"scene.render.frame_map_new": 100,
"scene.render.frame_map_old": 100,
"scene.render.hair_subdiv": 0,
"scene.render.hair_type": "STRAND",
"scene.render.line_thickness": 1.0,
"scene.render.line_thickness_mode": "ABSOLUTE",
"scene.render.metadata_input": "SCENE",
"scene.render.motion_blur_shutter": 0.5,
"scene.render.pixel_aspect_x": 1.0,
"scene.render.pixel_aspect_y": 1.0,
"scene.render.preview_pixel_size": "AUTO",
"scene.render.resolution_percentage": 100,
"scene.render.resolution_x": 1000,
"scene.render.resolution_y": 1000,
"scene.render.sequencer_gl_preview": "SOLID",
"scene.render.simplify_child_particles": 1.0,
"scene.render.simplify_child_particles_render": 1.0,
"scene.render.simplify_gpencil": false,
"scene.render.simplify_gpencil_antialiasing": true,
"scene.render.simplify_gpencil_modifier": true,
"scene.render.simplify_gpencil_onplay": false,
"scene.render.simplify_gpencil_shader_fx": true,
"scene.render.simplify_gpencil_tint": true,
"scene.render.simplify_gpencil_view_fill": true,
"scene.render.simplify_shadows": 1.0,
"scene.render.simplify_shadows_render": 1.0,
"scene.render.simplify_subdivision": 6,
"scene.render.simplify_subdivision_render": 6,
"scene.render.simplify_volumes": 1.0,
"scene.render.stamp_font_size": 12,
"scene.render.stamp_note_text": "",
"scene.render.threads": 20,
"scene.render.threads_mode": "AUTO",
"scene.render.use_bake_clear": true,
"scene.render.use_bake_lores_mesh": false,
"scene.render.use_bake_multires": false,
"scene.render.use_bake_selected_to_active": false,
"scene.render.use_bake_user_scale": false,
"scene.render.use_border": false,
"scene.render.use_compositing": true,
"scene.render.use_crop_to_border": false,
"scene.render.use_file_extension": true,
"scene.render.use_freestyle": false,
"scene.render.use_high_quality_normals": false,
"scene.render.use_lock_interface": false,
"scene.render.use_motion_blur": false,
"scene.render.use_multiview": false,
"scene.render.use_overwrite": true,
"scene.render.use_persistent_data": false,
"scene.render.use_placeholder": false,
"scene.render.use_render_cache": false,
"scene.render.use_sequencer": true,
"scene.render.use_sequencer_override_scene_strip": false,
"scene.render.use_simplify": false,
"scene.render.use_single_layer": false,
"scene.render.use_stamp": false,
"scene.render.use_stamp_camera": true,
"scene.render.use_stamp_date": true,
"scene.render.use_stamp_filename": true,
"scene.render.use_stamp_frame": true,
"scene.render.use_stamp_frame_range": false,
"scene.render.use_stamp_hostname": false,
"scene.render.use_stamp_labels": true,
"scene.render.use_stamp_lens": false,
"scene.render.use_stamp_marker": false,
"scene.render.use_stamp_memory": false,
"scene.render.use_stamp_note": false,
"scene.render.use_stamp_render_time": true,
"scene.render.use_stamp_scene": true,
"scene.render.use_stamp_sequencer_strip": false,
"scene.render.use_stamp_time": true,
"scene.render.views_format": "STEREO_3D",
"scene.view_settings.exposure": 0.0,
"scene.view_settings.gamma": 1.0,
"scene.view_settings.look": "None",
"scene.view_settings.use_curve_mapping": false,
"scene.view_settings.view_transform": "Filmic",
"scene.display.shading.aov_name": "",
"scene.display.shading.background_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.background_type": "THEME",
"scene.display.shading.cavity_ridge_factor": 1.0,
"scene.display.shading.cavity_type": "WORLD",
"scene.display.shading.cavity_valley_factor": 1.0,
"scene.display.shading.color_type": "MATERIAL",
"scene.display.shading.curvature_ridge_factor": 0.0,
"scene.display.shading.curvature_valley_factor": 0.0,
"scene.display.shading.light": "STUDIO",
"scene.display.shading.object_outline_color": [
0.0,
0.0,
0.0
],
"scene.display.shading.render_pass": "COMBINED",
"scene.display.shading.shadow_intensity": 0.5,
"scene.display.shading.show_backface_culling": false,
"scene.display.shading.show_cavity": false,
"scene.display.shading.show_object_outline": false,
"scene.display.shading.show_shadows": false,
"scene.display.shading.show_specular_highlight": true,
"scene.display.shading.show_xray": false,
"scene.display.shading.show_xray_wireframe": false,
"scene.display.shading.single_color": [
0.800000011920929,
0.800000011920929,
0.800000011920929
],
"scene.display.shading.studio_light": "Default",
"scene.display.shading.studiolight_background_alpha": 0.0,
"scene.display.shading.studiolight_background_blur": 0.0,
"scene.display.shading.studiolight_intensity": 0.0,
"scene.display.shading.studiolight_rotate_z": 0.0,
"scene.display.shading.type": "SOLID",
"scene.display.shading.use_compositor": "DISABLED",
"scene.display.shading.use_dof": false,
"scene.display.shading.use_scene_lights": false,
"scene.display.shading.use_scene_lights_render": false,
"scene.display.shading.use_scene_world": false,
"scene.display.shading.use_scene_world_render": false,
"scene.display.shading.use_studiolight_view_rotation": true,
"scene.display.shading.use_world_space_lighting": false,
"scene.display.shading.wireframe_color_type": "MATERIAL",
"scene.display.shading.xray_alpha": 0.5,
"scene.display.shading.xray_alpha_wireframe": 0.0,
"scene.display.light_direction": [
0.5773502588272095,
0.5773502588272095,
0.5773502588272095
],
"scene.display.matcap_ssao_attenuation": 1.0,
"scene.display.matcap_ssao_distance": 0.20000000298023224,
"scene.display.matcap_ssao_samples": 16,
"scene.display.render_aa": "8",
"scene.display.shadow_focus": 0.0,
"scene.display.shadow_shift": 0.10000000149011612,
"scene.display.viewport_aa": "FXAA",
"space.overlay.backwire_opacity": 0.5,
"space.overlay.bone_wire_alpha": 1.0,
"space.overlay.display_handle": "SELECTED",
"space.overlay.fade_inactive_alpha": 0.4000000059604645,
"space.overlay.gpencil_fade_layer": 0.5,
"space.overlay.gpencil_fade_objects": 0.5,
"space.overlay.gpencil_grid_opacity": 0.5,
"space.overlay.gpencil_vertex_paint_opacity": 1.0,
"space.overlay.grid_lines": 16,
"space.overlay.grid_scale": 1.0,
"space.overlay.grid_subdivisions": 10,
"space.overlay.normals_constant_screen_size": 7.0,
"space.overlay.normals_length": 0.10000000149011612,
"space.overlay.sculpt_curves_cage_opacity": 0.5,
"space.overlay.sculpt_mode_face_sets_opacity": 1.0,
"space.overlay.sculpt_mode_mask_opacity": 0.75,
"space.overlay.show_annotation": true,
"space.overlay.show_axis_x": true,
"space.overlay.show_axis_y": true,
"space.overlay.show_axis_z": false,
"space.overlay.show_bones": true,
"space.overlay.show_cursor": true,
"space.overlay.show_curve_normals": false,
"space.overlay.show_edge_bevel_weight": true,
"space.overlay.show_edge_crease": true,
"space.overlay.show_edge_seams": true,
"space.overlay.show_edge_sharp": true,
"space.overlay.show_edges": false,
"space.overlay.show_extra_edge_angle": false,
"space.overlay.show_extra_edge_length": false,
"space.overlay.show_extra_face_angle": false,
"space.overlay.show_extra_face_area": false,
"space.overlay.show_extra_indices": false,
"space.overlay.show_extras": true,
"space.overlay.show_face_center": false,
"space.overlay.show_face_normals": false,
"space.overlay.show_face_orientation": false,
"space.overlay.show_faces": true,
"space.overlay.show_fade_inactive": false,
"space.overlay.show_floor": true,
"space.overlay.show_freestyle_edge_marks": true,
"space.overlay.show_freestyle_face_marks": true,
"space.overlay.show_look_dev": false,
"space.overlay.show_motion_paths": true,
"space.overlay.show_object_origins": true,
"space.overlay.show_object_origins_all": false,
"space.overlay.show_occlude_wire": false,
"space.overlay.show_onion_skins": false,
"space.overlay.show_ortho_grid": true,
"space.overlay.show_outline_selected": true,
"space.overlay.show_overlays": true,
"space.overlay.show_paint_wire": false,
"space.overlay.show_relationship_lines": true,
"space.overlay.show_sculpt_curves_cage": true,
"space.overlay.show_sculpt_face_sets": true,
"space.overlay.show_sculpt_mask": true,
"space.overlay.show_split_normals": false,
"space.overlay.show_stats": false,
"space.overlay.show_statvis": false,
"space.overlay.show_text": true,
"space.overlay.show_vertex_normals": false,
"space.overlay.show_viewer_attribute": true,
"space.overlay.show_weight": false,
"space.overlay.show_wireframes": false,
"space.overlay.show_wpaint_contours": false,
"space.overlay.show_xray_bone": false,
"space.overlay.texture_paint_mode_opacity": 1.0,
"space.overlay.use_debug_freeze_view_culling": false,
"space.overlay.use_gpencil_canvas_xray": false,
"space.overlay.use_gpencil_edit_lines": true,
"space.overlay.use_gpencil_fade_gp_objects": false,
"space.overlay.use_gpencil_fade_layers": false,
"space.overlay.use_gpencil_fade_objects": false,
"space.overlay.use_gpencil_grid": false,
"space.overlay.use_gpencil_multiedit_line_only": false,
"space.overlay.use_gpencil_onion_skin": false,
"space.overlay.use_gpencil_show_directions": false,
"space.overlay.use_gpencil_show_material_name": false,
"space.overlay.use_normals_constant_screen_size": false,
"space.overlay.vertex_opacity": 1.0,
"space.overlay.vertex_paint_mode_opacity": 1.0,
"space.overlay.viewer_attribute_opacity": 1.0,
"space.overlay.weight_paint_mode_opacity": 1.0,
"space.overlay.wireframe_opacity": 1.0,
"space.overlay.wireframe_threshold": 1.0,
"space.overlay.xray_alpha_bone": 0.0
}
}
}
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="rectangle-tag">
<rect x="-6" y="-2.5" width="12" height="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
</g>
<g id="triangle-tag">
<path style="fill: white; stroke: black; stroke-width: 0.25;" d="M 3.1409425e-7,-7.1069207 5.7650623,2.8784603 l -11.5301246,-6e-7 z" />
</g>
<g id="hexagon-tag">
<path style="fill: white; stroke: black; stroke-width: 0.25;" d="m 0.0161133,-6.0583333 5.2339915,3.8366023 -2.031433,6.1633977 c 0,0 -6.4894866,-0.027414 -6.4894866,-0.027414 l -1.97929,-6.1803395 5.2662181,-3.7922467" />
</g>
<g id="capsule-tag">
<rect x="-6" y="-2.5" width="12" height="5" rx="2.5" ry="2.5" fill="white" stroke="black" style="stroke-width: 0.25;" />
</g>
<g id="circle-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
</g>
<g id="door-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<text y="-1.75" class="regular" text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>
<line x1="-5" x2="5" style="stroke: black; stroke-width: 0.25;" />
<text y="2.5" class="regular" text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>
</g>
<g id="space-tag">
<text y="-5" class="large" text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>
<rect x="-6" y="-2.5" width="12" height="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<text class="regular" text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>
<text y="5" class="regular" text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>
</g>
<g id="elevation-arrow">
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
</g>
<g id="elevation-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<line x1="-5" y1="0" x2="5" y2="0" style="stroke: black; stroke-width: 0.25;" />
</g>
<g id="section-arrow">
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
</g>
<g id="section-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<line x1="-5" y1="0" x2="5" y2="0" style="stroke: black; stroke-width: 0.25;" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

@@ -1,67 +1,55 @@
<link href="jsgantt.css" rel="stylesheet" type="text/css"/>
<link href="../../module/sequence/gantt/main.css" rel="stylesheet" type="text/css"/>
<script src="jsgantt.js" type="text/javascript"></script>
<style>
.gtaskcellwkend,
.gtaskcellcurrent,
.gminorheadingwkend {
background-color: #e1e1e1;
}
.gitemhighlight td {
background-color: #ffdaaa;
}
.gtaskblue {
background: #4281A4;
}
.gtaskred {
background: #C1666B;
}
.gtaskgreen {
background: #48A9A6;
}
.gtaskyellow {
background: #D4B483;
}
.gmainleft {
overflow: visible;
flex: 0 1 auto;
}
</style>
<a href="#print" id="print">Print Mode</a>
<div style="position:relative" class="gantt" id="GanttChartDIV"></div>
<script type="text/javascript">
var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'day');
g.setOptions({
vCaptionType: 'Caption', // Set to Show Caption : None,Caption,Resource,Duration,Complete,
vQuarterColWidth: 36,
vDateTaskDisplayFormat: 'day dd month yyyy', // Shown in tool tip box
vDayMajorDateDisplayFormat: 'mon yyyy - Week ww',// Set format to dates in the "Major" header of the "Day" view
vWeekMinorDateDisplayFormat: 'dd mon', // Set format to display dates in the "Minor" header of the "Week" view
vLang: 'en',
vShowTaskInfoLink: 1, // Show link in tool tip (0/1)
vShowEndWeekDate: 0, // Show/Hide the date for the last day of the week in header for daily
vUseSingleCell: 10000, // Set the threshold cell per table row (Helps performance for large data.
vFormatArr: ['Day', 'Week', 'Month', 'Quarter'], // Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers,
vShowRes: false, // Disable the resource column.
vShowComp: false, // Disable the completion column.
vShowDur: false, // Disable the duration column, because jsgantt doesn't calculate durations the way we want.
vAdditionalHeaders: {ifcduration: {title: 'Duration'}},
vUseToolTip: false, // Disable tooltips.
vTotalHeight: 900,
});
document.getElementById('print').addEventListener('click', function() {
g.setTotalHeight("");
g.Draw();
});
var json_data = `
{{{json_data}}}
`;
JSGantt.parseJSONString(json_data, g);
g.Draw();
<script type="text/javascript" src="../../module/sequence/gantt/index.js"></script>
<script>
var json_data = `{{{json_data}}}`;
</script>
<div id="options" class="no-print">
<h4>Choose a language:
<select id="lang" class="sweet_button" onchange="set_language(event)">
<option value='cn'>Chinese (cn)</option>
<option value='cs'>Czech (cs)</option>
<option value='nl'>Dutch (Standard)</option>
<option value='en' selected>English (en)</option>
<option value='fr'>French (fr)</option>
<option value='de'>German (de)</option>
<option value='hu'>Hungarian (hu)</option>
<option value='id'>Indonesian (id)</option>
<option value='it'>Italian (it)</option>
<option value='ja'>Japanese (ja)</option>
<option value='pt'>Portuguese (pt)</option>
<option value='ru'>Russian (ru)</option>
<option value='es'>Spanish (es)</option>
<option value='sv'>Swedish (sv)</option>
<option value='tr'>Turkish (tr)</option>
</select>
</h4>
<br>
</div>
<div class="top-right no-print" id="print_options">
<select class="sweet_button" id="print_page_size">
<option value="210,297">A4 Portrait</option>
<option value="297,210">A4 Landscape</option>
<option value="297,420">A3 Portrait</option>
<option value="420,297">A3 Landscape</option>
<option value="420,594">A2 Portrait</option>
<option value="594,420">A2 Landscape</option>
<option value="594,841">A1 Portrait</option>
<option value="841,594">A1 Landscape</option>
<option value="841,1189">A0 Portrait</option>
<option value="1189,841">A0 Landscape</option>
</select>
</div>
<div id="schedule-data" class="no-print"></div>
<div id="schedule-header" style=""></div>
<div style="position:relative" class="gantt" id="GanttChartDIV"></div>
<script>
var data = `{{{data}}}`;
setupPage(data);
create_gantt_chart(json_data)
</script>
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,20 +5,27 @@ FILE_NAME('EPset_Drawing.ifc','2020-01-01T00:00:00',(),(),'EPset_Drawing','EPset
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROPERTYSETTEMPLATE('2JhNIvqZrFnAgxfhK0XVQX',$,'EPset_Drawing','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13,#14,#15));
#1=IFCPROPERTYSETTEMPLATE('2JhNIvqZrFnAgxfhK0XVQX',$,'EPset_Drawing','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13,#14,#15,#16,#17,#18,#19,#20,#21));
#2=IFCSIMPLEPROPERTYTEMPLATE('23JavTMk98ZxXhrUEnjAcf',$,'TargetView','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('1yVWUt5H9DAOuu0OaMMLpe',$,'Scale','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('3gsuPBtU93b8f0gg1pjkq6',$,'HumanScale','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('1yVWUt5H9DAOuu0OaMMLpe',$,'Scale','The scale of this drawing represented as a numerator and denominator, such as 1/100',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('3gsuPBtU93b8f0gg1pjkq6',$,'HumanScale','The scale of this drawing in human readable format, such as 1:100',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('2T$a4OFsv2LeD5JeBKEV4f',$,'IsNTS','Whether or not the scale is intended to be significant',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#5=IFCSIMPLEPROPERTYTEMPLATE('0AK5C2UpL4$eaac2LszAx$',$,'HasUnderlay','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#6=IFCSIMPLEPROPERTYTEMPLATE('2j2ZEZR8X5tONm7kli5hM6',$,'HasLinework','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#7=IFCSIMPLEPROPERTYTEMPLATE('1ttChRysH9UuEX2FeMj5Hu',$,'HasAnnotation','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#8=IFCSIMPLEPROPERTYTEMPLATE('2NPPxuABv1huDTVh32TFgw',$,'GlobalReferencing','',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#9=IFCSIMPLEPROPERTYTEMPLATE('10hT_1zrzEbRRKMXYAWvtD',$,'Metadata','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#10=IFCSIMPLEPROPERTYTEMPLATE('3Z0BXPSG5CWgtI33ioV7aj',$,'Include','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#11=IFCSIMPLEPROPERTYTEMPLATE('1RVts_g3PAw98PJA2yL3bO',$,'Exclude','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#12=IFCSIMPLEPROPERTYTEMPLATE('0c1$8NpYDEaBiJrj16jHIo',$,'Stylesheet','',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
#13=IFCSIMPLEPROPERTYTEMPLATE('3mRF52q81FQB$h4oTh7M45',$,'Markers','',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
#14=IFCSIMPLEPROPERTYTEMPLATE('1rhr_0N3LDtuORcEJP0KXM',$,'Symbols','',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
#15=IFCSIMPLEPROPERTYTEMPLATE('2sHDBuW7P4TROy$hL2w7ct',$,'Patterns','',.P_SINGLEVALUE.,'IfcURIReference',$,$,$,$,$,.READWRITE.);
#10=IFCSIMPLEPROPERTYTEMPLATE('3Z0BXPSG5CWgtI33ioV7aj',$,'Include','Selector expression to include ifc elements in the drawing',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#11=IFCSIMPLEPROPERTYTEMPLATE('1RVts_g3PAw98PJA2yL3bO',$,'Exclude','Selector expression to exclude ifc elements in the drawing',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#12=IFCSIMPLEPROPERTYTEMPLATE('0c1$8NpYDEaBiJrj16jHIo',$,'Stylesheet','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#13=IFCSIMPLEPROPERTYTEMPLATE('3mRF52q81FQB$h4oTh7M45',$,'Markers','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#14=IFCSIMPLEPROPERTYTEMPLATE('1rhr_0N3LDtuORcEJP0KXM',$,'Symbols','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#15=IFCSIMPLEPROPERTYTEMPLATE('2sHDBuW7P4TROy$hL2w7ct',$,'Patterns','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#16=IFCSIMPLEPROPERTYTEMPLATE('1$xfo9EVb26QLqmPll2_RK',$,'MetricPrecision','',.P_SINGLEVALUE.,'IfcReal',$,$,$,$,$,.READWRITE.);
#17=IFCSIMPLEPROPERTYTEMPLATE('38uAtrp9nD_901NO42zd$7',$,'ImperialPrecision','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#18=IFCSIMPLEPROPERTYTEMPLATE('1MX0uffTL6TOvtvEJpxFmk',$,'DecimalPlaces','',.P_SINGLEVALUE.,'IfcInteger',$,$,$,$,$,.READWRITE.);
#19=IFCSIMPLEPROPERTYTEMPLATE('0joEq0Rd10cxweEh0NeHT6',$,'JoinCriteria','Comma separated selection keys which determine what cut objects are to be joined.',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#20=IFCSIMPLEPROPERTYTEMPLATE('0nYMT3OSj5gArVniCWZRtv',$,'ShadingStyles','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#21=IFCSIMPLEPROPERTYTEMPLATE('3VWG22eZXBdQwdKlzMeVQH',$,'CurrentShadingStyle','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
@@ -1,16 +1,38 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((),'2;1');
FILE_NAME('EPset_Annotation.ifc','2020-01-01T00:00:00',(),(),'EPset_Annotation','EPset_Annotation',$);
FILE_NAME('Psets_BBIM_Annotation.ifc','2020-01-01T00:00:00',(),(),'Psets_BBIM_Annotation','Psets_BBIM_Annotation',$);
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROPERTYSETTEMPLATE('3VuPUwdCD2Qx3XDDRs0R1N',$,'EPset_Annotation','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#2,#3,#4));
#1=IFCPROPERTYSETTEMPLATE('3VuPUwdCD2Qx3XDDRs0R1N',$,'EPset_Annotation','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#2,#3,#4));
#2=IFCSIMPLEPROPERTYTEMPLATE('2P7JN79n96Q9pElZ83LKe4',$,'ZIndex','',.P_SINGLEVALUE.,'IfcInteger',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('1Wpx_r2xj1_9w5JpI0QRJy',$,'Symbol','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('3q0oxMUKP47vZ4jnyG$dDb',$,'Classes','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#5=IFCPROPERTYSETTEMPLATE('0iKwujnQL9IevVQato8f7Z',$,'BBIM_Batting','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation',(#6,#7));
#4=IFCSIMPLEPROPERTYTEMPLATE('3q0oxMUKP47vZ4jnyG$dDb',$,'Classes','Classes separarated by spaces that end up in classes for this element in svg. Can be used to specify the text font size: small - 1.8mm; regular - 2.5mm; large - 3.5mm; header - 5mm; title - 7mm. By default regular size is used.',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#5=IFCPROPERTYSETTEMPLATE('0iKwujnQL9IevVQato8f7Z',$,'BBIM_Batting','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#6,#7));
#6=IFCSIMPLEPROPERTYTEMPLATE('0t2LEesGT1QRQtrIZUAR8L',$,'Thickness','Batting thickness',.P_SINGLEVALUE.,'IfcPositiveLengthMeasure',$,$,$,$,$,.READWRITE.);
#7=IFCSIMPLEPROPERTYTEMPLATE('082PndS6v2kBOiJoSboMnh',$,'Reverse pattern direction','Reverse batting pattern (swap starting and ending points)',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#8=IFCPROPERTYSETTEMPLATE('1Dx2EiZnP67xotInXpwz90',$,'BBIM_Section','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#9,#10,#11,#12,#13));
#9=IFCSIMPLEPROPERTYTEMPLATE('2a_9s8spHDc9dZHtgg71XL',$,'ShowStartArrow','Display start arrow.',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#10=IFCSIMPLEPROPERTYTEMPLATE('3i6SH_GbT7zhKea$wVE56A',$,'StartArrowSymbol','Custom symbol for the start of the section marker arrow. Need to make sure it''s present in "symbols.svg".',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#11=IFCSIMPLEPROPERTYTEMPLATE('1DtsPn5a9FG8$zXHDDMavY',$,'ShowEndArrow','Display end arrow.',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#12=IFCSIMPLEPROPERTYTEMPLATE('2$6U0mLI9AiPRWeBabdY3u',$,'EndArrowSymbol','Custom symbol for the end of the section marker arrow. Need to make sure it''s present in "symbols.svg".',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#13=IFCSIMPLEPROPERTYTEMPLATE('1naFqntIL7igCY7hCaE7kq',$,'HasConnectedSectionLine','Connect or disconnect section markers with line (by default = True).',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#14=IFCPROPERTYSETTEMPLATE('3V8oZ8YRD3_O7uR5vcUleS',$,'BBIM_Documentation','',.PSET_OCCURRENCEDRIVEN.,'IfcProject',(#15,#16,#17,#18,#19,#20,#21,#22,#23));
#15=IFCSIMPLEPROPERTYTEMPLATE('0ulAhgk3v9qfGlDILauR6J',$,'SheetsDir','Default sheets directory',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#16=IFCSIMPLEPROPERTYTEMPLATE('2yvlVKiQXASucfH40deCvu',$,'LayoutsDir','Default layouts directory',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#17=IFCSIMPLEPROPERTYTEMPLATE('2kXZqXicL3jRwsOnLM_0ho',$,'TitleblocksDir','Default titleblocks directory',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#18=IFCSIMPLEPROPERTYTEMPLATE('1lmOfo9Bf9beMBJkCZKf5Y',$,'DrawingsDir','Default drawings directory',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#19=IFCSIMPLEPROPERTYTEMPLATE('30cOKpb4D9CADKM04$N9X3',$,'StylesheetPath','Default stylesheet CSS',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#20=IFCSIMPLEPROPERTYTEMPLATE('23tejOrxj859R_eCRp1AFP',$,'MarkersPath','Default markers SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#21=IFCSIMPLEPROPERTYTEMPLATE('1UDakJ5_f7kBhggNSW4$h5',$,'SymbolsPath','Default symbols SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#22=IFCSIMPLEPROPERTYTEMPLATE('0d53LEtgLDQxnv__NfgH7i',$,'PatternsPath','Default patterns SVG',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#23=IFCSIMPLEPROPERTYTEMPLATE('26qFNMv7nCHgU6Jd7Anga5',$,'ShadingStylesPath','Default shading styles',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#24=IFCPROPERTYSETTEMPLATE('0I9merLinF5Ap$aZwaclgm',$,'BBIM_Dimension','',.PSET_OCCURRENCEDRIVEN.,'IfcAnnotation,IfcTypeProduct',(#25,#26,#27,#28));
#25=IFCSIMPLEPROPERTYTEMPLATE('1rL2AbQsXD8RbpoWH5pYOV',$,'ShowDescriptionOnly','Hide the measurement values and show only annotation description',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#26=IFCSIMPLEPROPERTYTEMPLATE('0SVyOfB0rC2xNfdRYf3XvY',$,'SuppressZeroInches','Suppress 0 inch values in dimension annotation text (for example: 12'' - 0" -> 12'')',.P_SINGLEVALUE.,'IfcBoolean',$,$,$,$,$,.READWRITE.);
#27=IFCSIMPLEPROPERTYTEMPLATE('2bUmj458PBqPAtUoI3MXsb',$,'TextPrefix','Text to add before annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#28=IFCSIMPLEPROPERTYTEMPLATE('0bnzttUb9BPuN597uNTXOE',$,'TextSuffix','Text to add after annotation measurement value',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="rectangle-tag">
<rect x="-6" y="-2.5" width="12" height="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
</g>
<g id="door-tag">
<circle cy="1.75" r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<line x1="-5" y1="1.75" x2="5" y2="1.75" style="stroke: black; stroke-width: 0.25;" />
</g>
<g id="elevation-arrow">
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
</g>
<g id="elevation-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<line x1="-5" y1="0" x2="5" y2="0" style="stroke: black; stroke-width: 0.25;" />
</g>
<g id="section-arrow">
<path style="fill: black;" d="M -7.07106 0 0 -7.07106 7.07106 0" />
</g>
<g id="section-tag">
<circle r="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
<line x1="-5" y1="0" x2="5" y2="0" style="stroke: black; stroke-width: 0.25;" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

+4 -23
View File
@@ -44,10 +44,8 @@ class IfcExporter:
self.file = IfcStore.get_file()
self.set_header()
IfcStore.update_cache()
if bpy.context.scene.BIMProjectProperties.is_authoring:
self.sync_deletions()
self.sync_all_objects()
self.sync_edited_objects()
self.sync_all_objects()
self.sync_edited_objects()
extension = self.ifc_export_settings.output_file.split(".")[-1].lower()
if extension == "ifczip":
with tempfile.TemporaryDirectory() as unzipped_path:
@@ -87,19 +85,6 @@ class IfcExporter:
self.get_application_name(), self.get_application_version()
)
def sync_deletions(self):
results = []
for ifc_definition_id in IfcStore.deleted_ids:
try:
product = self.file.by_id(ifc_definition_id)
if hasattr(product, "GlobalId"):
results.append(product.GlobalId)
except:
continue
ifcopenshell.api.run("root.remove_product", self.file, **{"product": product})
IfcStore.deleted_ids.clear()
return results
def sync_all_objects(self):
results = []
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
@@ -126,7 +111,7 @@ class IfcExporter:
continue
try:
if isinstance(obj, bpy.types.Material):
if self.has_changed_shading(obj):
if tool.Ifc.has_changed_shading(obj):
blenderbim.core.style.update_style_colours(tool.Ifc, tool.Style, obj=obj)
else:
element = tool.Ifc.get_entity(obj)
@@ -149,15 +134,11 @@ class IfcExporter:
checksum = obj.data.BIMMeshProperties.material_checksum
return checksum != str([s.id() for s in tool.Geometry.get_styles(obj) if s])
def has_changed_shading(self, obj):
checksum = obj.BIMMaterialProperties.shading_checksum
return checksum != repr(np.array(obj.diffuse_color).tobytes())
def sync_object_placement(self, obj):
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if not tool.Ifc.is_moved(obj):
return
blender_matrix = np.array(obj.matrix_world)
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if (obj.scale - Vector((1.0, 1.0, 1.0))).length > 1e-4:
bpy.ops.bim.update_representation(obj=obj.name)
return element
+84 -92
View File
@@ -22,19 +22,18 @@ import addon_utils
import ifcopenshell.api.owner.settings
import blenderbim.tool as tool
import blenderbim.core.owner as core_owner
from blenderbim.bim.module.drawing.prop import RasterStyleProperty
from bpy.app.handlers import persistent
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.owner.prop import get_user_person, get_user_organisation
from blenderbim.bim.module.model.data import AuthoringData
from mathutils import Vector
from math import cos, degrees
global_subscription_owner = object()
def mode_callback(obj, data):
if not bpy.context.scene.BIMProjectProperties.is_authoring:
return
objects = bpy.context.selected_objects
if bpy.context.active_object:
objects += [bpy.context.active_object]
@@ -47,9 +46,9 @@ def mode_callback(obj, data):
):
continue
if obj.data.BIMMeshProperties.ifc_definition_id:
IfcStore.edited_objs.add(obj)
tool.Ifc.edit(obj)
elif IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id).is_a("IfcGridAxis"):
IfcStore.edited_objs.add(obj)
tool.Ifc.edit(obj)
def name_callback(obj, data):
@@ -75,42 +74,82 @@ def name_callback(obj, data):
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
if not element.is_a("IfcRoot"):
return
if element.is_a("IfcSpatialStructureElement") or (hasattr(element, "IsDecomposedBy") and element.IsDecomposedBy):
collection = obj.users_collection[0]
collection.name = obj.name
if element.is_a("IfcGrid"):
axis_obj = IfcStore.get_element(element.UAxes[0].id())
axis_collection = axis_obj.users_collection[0]
grid_collection = None
for collection in bpy.data.collections:
if axis_collection.name in collection.children.keys():
grid_collection = collection
break
if grid_collection:
grid_collection.name = obj.name
if obj.BIMObjectProperties.collection:
obj.BIMObjectProperties.collection.name = obj.name
element.Name = "/".join(obj.name.split("/")[1:])
refresh_ui_data()
def color_callback(obj, data):
if obj.BIMMaterialProperties.ifc_style_id:
IfcStore.edited_objs.add(obj)
tool.Ifc.edit(obj)
def active_object_callback():
refresh_ui_data()
update_bim_tool_props()
def subscribe_to(object, data_path, callback):
def update_bim_tool_props():
"""update BIM Tools props (such as extrusion_depth, length and x_angle) when active object changes"""
obj = bpy.context.active_object
# bunch of checks to see if we're in a valid state
if not obj:
return
mode = bpy.context.mode
current_tool = bpy.context.workspace.tools.from_space_view3d_mode(mode).idname
if current_tool != "bim.bim_tool":
return
element = tool.Ifc.get_entity(obj)
if not element:
return
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
if not representation:
return
extrusion = tool.Model.get_extrusion(representation)
if not extrusion:
return
def get_x_angle(extrusion):
x, y, z = extrusion.ExtrudedDirection.DirectionRatios
x_angle = Vector((0, 1)).angle_signed(Vector((y, z)))
return x_angle
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
props = bpy.context.scene.BIMModelProperties
if not AuthoringData.is_loaded:
AuthoringData.load()
if AuthoringData.data["active_material_usage"] == "LAYER2":
x_angle = get_x_angle(extrusion)
axis = tool.Model.get_wall_axis(obj)["reference"]
props.extrusion_depth = extrusion.Depth * si_conversion * cos(x_angle)
props.length = (axis[1] - axis[0]).length
props.x_angle = x_angle
elif AuthoringData.data["active_material_usage"] == "LAYER3":
x_angle = get_x_angle(extrusion)
props.x_angle = x_angle
elif AuthoringData.data["active_material_usage"] == "PROFILE":
props.extrusion_depth = extrusion.Depth * si_conversion
def active_material_index_callback(obj, data):
refresh_ui_data()
def subscribe_to(obj, data_path, callback):
try:
subscribe_to = object.path_resolve(data_path, False)
subscribe_to = obj.path_resolve(data_path, False)
except:
return
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=object,
owner=obj,
args=(
object,
obj,
data_path,
),
notify=callback,
@@ -220,6 +259,12 @@ def get_application_version():
)
def viewport_shading_changed_callback(area):
shading = area.spaces.active.shading.type
if shading == "RENDERED":
bpy.context.scene.BIMStylesProperties.active_style_type = "External"
@persistent
def setDefaultProperties(scene):
global global_subscription_owner
@@ -227,74 +272,21 @@ def setDefaultProperties(scene):
bpy.msgbus.subscribe_rna(
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
)
# subscribe to changes in viewport shading mode
# NOTE: couldn't find a way to make it work for new areas too
# it starts working for them after blender restart though
for screen in bpy.data.screens:
for area in screen.areas:
if area.type != "VIEW_3D":
continue
shading = area.spaces.active.shading
key = shading.path_resolve("type", False)
bpy.msgbus.subscribe_rna(
key=key, owner=global_subscription_owner, args=(area,), notify=viewport_shading_changed_callback
)
ifcopenshell.api.owner.settings.get_user = lambda ifc: core_owner.get_user(tool.Owner)
ifcopenshell.api.owner.settings.get_application = get_application
# TODO: Move to drawing module
if len(bpy.context.scene.DocProperties.drawing_styles) == 0:
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
drawing_style.name = "Technical"
drawing_style.render_type = "VIEWPORT"
drawing_style.raster_style = json.dumps(
{
RasterStyleProperty.WORLD_COLOR.value: (1, 1, 1),
RasterStyleProperty.RENDER_ENGINE.value: "BLENDER_WORKBENCH",
RasterStyleProperty.RENDER_TRANSPARENT.value: False,
RasterStyleProperty.SHADING_SHOW_OBJECT_OUTLINE.value: True,
RasterStyleProperty.SHADING_SHOW_CAVITY.value: False,
RasterStyleProperty.SHADING_CAVITY_TYPE.value: "BOTH",
RasterStyleProperty.SHADING_CURVATURE_RIDGE_FACTOR.value: 1,
RasterStyleProperty.SHADING_CURVATURE_VALLEY_FACTOR.value: 1,
RasterStyleProperty.VIEW_TRANSFORM.value: "Standard",
RasterStyleProperty.SHADING_LIGHT.value: "FLAT",
RasterStyleProperty.SHADING_COLOR_TYPE.value: "SINGLE",
RasterStyleProperty.SHADING_SINGLE_COLOR.value: (1, 1, 1),
RasterStyleProperty.SHADING_SHOW_SHADOWS.value: False,
RasterStyleProperty.SHADING_SHADOW_INTENSITY.value: 0.5,
RasterStyleProperty.DISPLAY_LIGHT_DIRECTION.value: (0.5, 0.5, 0.5),
RasterStyleProperty.VIEW_USE_CURVE_MAPPING.value: False,
RasterStyleProperty.OVERLAY_SHOW_WIREFRAMES.value: True,
RasterStyleProperty.OVERLAY_WIREFRAME_THRESHOLD.value: 0,
RasterStyleProperty.OVERLAY_SHOW_FLOOR.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_X.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_Y.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_Z.value: False,
RasterStyleProperty.OVERLAY_SHOW_OBJECT_ORIGINS.value: False,
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
}
)
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
drawing_style.name = "Shaded"
drawing_style.render_type = "VIEWPORT"
drawing_style.raster_style = json.dumps(
{
RasterStyleProperty.WORLD_COLOR.value: (1, 1, 1),
RasterStyleProperty.RENDER_ENGINE.value: "BLENDER_WORKBENCH",
RasterStyleProperty.RENDER_TRANSPARENT.value: False,
RasterStyleProperty.SHADING_SHOW_OBJECT_OUTLINE.value: True,
RasterStyleProperty.SHADING_SHOW_CAVITY.value: True,
RasterStyleProperty.SHADING_CAVITY_TYPE.value: "BOTH",
RasterStyleProperty.SHADING_CURVATURE_RIDGE_FACTOR.value: 1,
RasterStyleProperty.SHADING_CURVATURE_VALLEY_FACTOR.value: 1,
RasterStyleProperty.VIEW_TRANSFORM.value: "Standard",
RasterStyleProperty.SHADING_LIGHT.value: "STUDIO",
RasterStyleProperty.SHADING_COLOR_TYPE.value: "MATERIAL",
RasterStyleProperty.SHADING_SINGLE_COLOR.value: (1, 1, 1),
RasterStyleProperty.SHADING_SHOW_SHADOWS.value: True,
RasterStyleProperty.SHADING_SHADOW_INTENSITY.value: 0.5,
RasterStyleProperty.DISPLAY_LIGHT_DIRECTION.value: (0.5, 0.5, 0.5),
RasterStyleProperty.VIEW_USE_CURVE_MAPPING.value: False,
RasterStyleProperty.OVERLAY_SHOW_WIREFRAMES.value: False,
RasterStyleProperty.OVERLAY_WIREFRAME_THRESHOLD.value: 0,
RasterStyleProperty.OVERLAY_SHOW_FLOOR.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_X.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_Y.value: False,
RasterStyleProperty.OVERLAY_SHOW_AXIS_Z.value: False,
RasterStyleProperty.OVERLAY_SHOW_OBJECT_ORIGINS.value: False,
RasterStyleProperty.OVERLAY_SHOW_RELATIONSHIP_LINES.value: False,
}
)
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
drawing_style.name = "Blender Default"
drawing_style.render_type = "DEFAULT"
bpy.ops.bim.save_drawing_style(index="2")
AuthoringData.type_thumbnails = {}
AuthoringData.type_thumbnails = {}
+10 -4
View File
@@ -31,9 +31,15 @@ import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
def draw_attributes(props, layout, copy_operator=None):
def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None):
"""you can set attribute active in popup with `active_attribute`
meaning you will be able to type into attribute's field without having to click
on it first
"""
for attribute in props:
row = layout.row(align=True)
if attribute == popup_active_attribute:
row.activate_init = True
draw_attribute(attribute, row, copy_operator)
@@ -64,14 +70,14 @@ def draw_attribute(attribute, layout, copy_operator=None):
text=attribute.name,
)
if attribute.is_uri:
op = layout.operator("bim.select_uri_attribute", text="", icon="FILE_FOLDER")
op.data_path = attribute.path_from_id("string_value")
if attribute.is_optional:
layout.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
if copy_operator:
op = layout.operator(f"{copy_operator}", text="", icon="COPYDOWN")
op.name = attribute.name
if attribute.is_uri:
op = layout.operator("bim.select_uri_attribute", text="", icon="FILE_FOLDER")
op.data_path = attribute.path_from_id("string_value")
def import_attributes(ifc_class, props, data, callback=None):
+3 -20
View File
@@ -24,6 +24,7 @@ import zipfile
import tempfile
import ifcopenshell
import blenderbim.bim.handler
import blenderbim.tool as tool
from pathlib import Path
@@ -35,7 +36,6 @@ class IfcStore:
cache_path = None
id_map = {}
guid_map = {}
deleted_ids = set()
edited_objs = set()
pset_template_path = ""
pset_template_file = None
@@ -62,7 +62,6 @@ class IfcStore:
IfcStore.cache_path = None
IfcStore.id_map = {}
IfcStore.guid_map = {}
IfcStore.deleted_ids = set()
IfcStore.edited_objs = set()
IfcStore.pset_template_path = ""
IfcStore.pset_template_file = None
@@ -277,23 +276,6 @@ class IfcStore:
data = {"id": element.id(), "obj": obj.name}
IfcStore.commit_link_element(data)
@staticmethod
def delete_element(element):
IfcStore.deleted_ids.add(element.id())
if IfcStore.history:
data = {"id": element.id()}
IfcStore.history[-1]["operations"].append(
{"rollback": IfcStore.rollback_delete_element, "commit": IfcStore.commit_delete_element, "data": data}
)
@staticmethod
def rollback_delete_element(data):
IfcStore.deleted_ids.remove(data["id"])
@staticmethod
def commit_delete_element(data):
IfcStore.deleted_ids.add(data["id"])
@staticmethod
def link_element(element, obj):
existing_obj = IfcStore.id_map.get(element.id(), None)
@@ -320,6 +302,7 @@ class IfcStore:
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
elif isinstance(obj, bpy.types.Object):
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
blenderbim.bim.handler.subscribe_to(obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback)
for listener in IfcStore.element_listeners:
listener(element, obj)
@@ -370,7 +353,7 @@ class IfcStore:
def unlink_element(element=None, obj=None):
if element is None:
try:
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
element = tool.Ifc.get_entity(obj)
except:
pass
+94 -344
View File
@@ -36,7 +36,7 @@ import ifcopenshell.util.geolocation
import blenderbim.tool as tool
from itertools import chain, accumulate
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.drawing.prop import get_diagram_scales
from blenderbim.bim.module.drawing.prop import ANNOTATION_TYPES_DATA
class FileCopy(threading.Thread):
@@ -60,7 +60,6 @@ class MaterialCreator:
def create(self, element, obj, mesh):
self.mesh = mesh
self.obj = obj
if (hasattr(element, "Representation") and not element.Representation) or (
hasattr(element, "RepresentationMaps") and not element.RepresentationMaps
):
@@ -140,11 +139,11 @@ class MaterialCreator:
def assign_material_slots_to_faces(self):
if "ios_materials" not in self.mesh or not self.mesh["ios_materials"]:
return
if len(self.obj.material_slots) == 1:
if len(self.mesh.materials) == 1:
return
material_to_slot = {}
for i, material in enumerate(self.mesh["ios_materials"]):
slot_index = self.obj.material_slots.find(self.styles[material].name)
slot_index = self.mesh.materials.find(self.styles[material].name)
material_to_slot[i] = slot_index
if len(self.mesh.polygons) == len(self.mesh["ios_material_ids"]):
@@ -179,11 +178,16 @@ class IfcImporter:
self.settings.set_deflection_tolerance(self.ifc_import_settings.deflection_tolerance)
self.settings.set_angular_tolerance(self.ifc_import_settings.angular_tolerance)
self.settings.set(self.settings.STRICT_TOLERANCE, True)
self.settings_curve = ifcopenshell.geom.settings()
self.settings_curve.set_deflection_tolerance(self.ifc_import_settings.deflection_tolerance)
self.settings_curve.set_angular_tolerance(self.ifc_import_settings.angular_tolerance)
self.settings_curve.set(self.settings_curve.STRICT_TOLERANCE, True)
self.settings_curve.set(self.settings_curve.INCLUDE_CURVES, True)
self.settings_native = ifcopenshell.geom.settings()
self.settings_native.set(self.settings_native.INCLUDE_CURVES, True)
self.settings_2d = ifcopenshell.geom.settings()
self.settings_2d.set(self.settings_2d.INCLUDE_CURVES, True)
self.settings_2d.set(self.settings.STRICT_TOLERANCE, True)
self.settings_2d.set(self.settings_2d.STRICT_TOLERANCE, True)
self.project = None
self.has_existing_project = False
self.collections = {}
@@ -242,6 +246,8 @@ class IfcImporter:
self.profile_code("Create native elements")
self.create_elements()
self.profile_code("Create elements")
self.create_generic_elements(self.annotations)
self.profile_code("Create annotations")
self.create_grids()
self.profile_code("Create grids")
self.create_spatial_elements()
@@ -302,12 +308,12 @@ class IfcImporter:
)
if self.body_contexts:
self.settings.set_context_ids(self.body_contexts)
# Annotation is to accommodate broken Revit files
# Annotation ContextType is to accommodate broken Revit files
# See https://github.com/Autodesk/revit-ifc/issues/187
self.plan_contexts = [
c.id()
for c in self.file.by_type("IfcGeometricRepresentationContext")
if c.ContextType in ["Plan", "Annotation"]
if c.ContextType in ["Plan", "Annotation"] or c.ContextIdentifier == "Annotation"
]
if self.plan_contexts:
self.settings_2d.set_context_ids(self.plan_contexts)
@@ -321,10 +327,13 @@ class IfcImporter:
if isinstance(self.elements, set):
self.elements = list(self.elements)
# TODO: enable filtering for annotations
self.annotations = set(self.file.by_type("IfcAnnotation"))
self.annotations = set([a for a in self.file.by_type("IfcAnnotation") if not a.HasAssignments])
else:
self.elements = self.file.by_type("IfcElement")
self.annotations = set(self.file.by_type("IfcAnnotation"))
if self.file.schema in ("IFC2X3", "IFC4"):
self.elements = self.file.by_type("IfcElement") + self.file.by_type("IfcProxy")
else:
self.elements = self.file.by_type("IfcElement")
self.annotations = set([a for a in self.file.by_type("IfcAnnotation") if not a.HasAssignments])
self.elements = [e for e in self.elements if not e.is_a("IfcFeatureElement")]
if self.ifc_import_settings.is_coordinating:
@@ -335,26 +344,11 @@ class IfcImporter:
if self.ifc_import_settings.has_filter or offset or offset_limit < len(self.elements):
self.element_types = set([ifcopenshell.util.element.get_type(e) for e in self.elements])
else:
if self.file.schema == "IFC2X3":
self.element_types = set(
self.file.by_type("IfcElementType")
+ self.file.by_type("IfcDoorStyle")
+ self.file.by_type("IfcWindowStyle")
)
elif self.file.schema == "IFC4":
self.element_types = set(
self.file.by_type("IfcElementType")
+ self.file.by_type("IfcDoorStyle")
+ self.file.by_type("IfcWindowStyle")
+ self.file.by_type("IfcSpatialElementType")
)
else:
self.element_types = set(
self.file.by_type("IfcElementType") + self.file.by_type("IfcSpatialElementType")
)
self.element_types = set(self.file.by_type("IfcTypeProduct"))
if self.ifc_import_settings.has_filter and self.ifc_import_settings.should_filter_spatial_elements:
self.spatial_elements = self.get_spatial_elements_filtered_by_elements(self.elements)
filtered_elements = self.elements | set(self.file.by_type("IfcGrid"))
self.spatial_elements = self.get_spatial_elements_filtered_by_elements(filtered_elements)
else:
if self.file.schema == "IFC2X3":
self.spatial_elements = set(self.file.by_type("IfcSpatialStructureElement"))
@@ -368,7 +362,7 @@ class IfcImporter:
while True:
results.add(spatial_element)
spatial_element = ifcopenshell.util.element.get_aggregate(spatial_element)
if not spatial_element or spatial_element.is_a("IfcContext"):
if not spatial_element or spatial_element.is_a() in ("IfcContext", "IfcProject"):
break
return results
@@ -388,7 +382,7 @@ class IfcImporter:
representations = self.get_transformed_body_representations(element.Representation.Representations)
# Single swept disk solids (e.g. rebar) are better natively represented as beveled curves
if self.is_native_swept_disk_solid(representations):
if self.is_native_swept_disk_solid(element, representations):
self.native_data[element.GlobalId] = {
"representations": representations,
"representation": self.get_body_representation(element.Representation.Representations),
@@ -416,16 +410,20 @@ class IfcImporter:
}
return True
def is_native_swept_disk_solid(self, representations):
def is_native_swept_disk_solid(self, element, representations):
for representation in representations:
items = representation["raw"].Items or [] # Be forgiving of invalid IFCs because Revit :(
if len(items) == 1 and items[0].is_a("IfcSweptDiskSolid"):
if tool.Pset.get_element_pset(element, "BBIM_Railing"):
return False
return True
elif len(items) and ( # See #2508 why we accommodate for invalid IFCs here
items[0].is_a("IfcSweptDiskSolid")
and len({i.is_a() for i in items}) == 1
and len({i.Radius for i in items}) == 1
):
if tool.Pset.get_element_pset(element, "BBIM_Railing"):
return False
return True
return False
@@ -625,37 +623,33 @@ class IfcImporter:
def create_element_type(self, element):
self.ifc_import_settings.logger.info("Creating object %s", element)
representation_map = self.get_type_product_body_representation_map(element)
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
if not representation:
representation = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
if not representation:
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Annotation")
mesh = None
if representation_map:
representation = representation_map.MappedRepresentation
if representation:
mesh_name = "{}/{}".format(representation.ContextOfItems.id(), representation.id())
mesh = self.meshes.get(mesh_name)
if mesh is None:
shape = None
try:
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation)
shape = ifcopenshell.geom.create_shape(self.settings, representation)
except:
try:
shape = ifcopenshell.geom.create_shape(self.settings_2d, representation)
except:
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
if shape:
mesh = self.create_mesh(element, shape)
tool.Loader.link_mesh(shape, mesh)
self.meshes[mesh_name] = mesh
except:
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
obj = bpy.data.objects.new(tool.Loader.get_name(element), mesh)
self.link_element(element, obj)
self.material_creator.create(element, obj, mesh)
self.type_products[element.GlobalId] = obj
def get_type_product_body_representation_map(self, element):
if not element.RepresentationMaps:
return
for representation_map in element.RepresentationMaps:
context = representation_map.MappedRepresentation.ContextOfItems
if (
context.ContextType == "Model"
and context.ContextIdentifier == "Body"
and context.TargetView == "MODEL_VIEW"
):
return representation_map
def create_native_elements(self):
progress = 0
checkpoint = time.time()
@@ -699,28 +693,31 @@ class IfcImporter:
def create_generic_elements(self, elements):
# Based on my experience in viewing BIM models, representations are prioritised as follows:
# 1. 3D Body, 2. 2D Plans, 3. Point clouds, 4. No representation
# If an element has a representation that doesn't follow 1, 2, or 3, it will not show by default.
# 1. 3D Body, 2. 2D Body, 3. 2D Plans / annotations, 4. Point clouds, 5. No representation
# If an element has a representation that doesn't follow 1, 2, 3, or 4, it will not show by default.
# The user can load them later if they want to view them.
products = self.create_products(elements)
elements -= products
products = self.create_curve_products(elements)
products = self.create_products(elements, settings=self.settings_curve)
elements -= products
products = self.create_products(elements, settings=self.settings_2d)
elements -= products
products = self.create_pointclouds(elements)
elements -= products
for element in elements:
self.create_product(element)
def create_products(self, products):
def create_products(self, products, settings=None):
if settings is None:
settings = self.settings
results = set()
if not products:
return results
if self.ifc_import_settings.should_use_cpu_multiprocessing:
iterator = ifcopenshell.geom.iterator(
self.settings, self.file, multiprocessing.cpu_count(), include=products
)
iterator = ifcopenshell.geom.iterator(settings, self.file, multiprocessing.cpu_count(), include=products)
else:
iterator = ifcopenshell.geom.iterator(self.settings, self.file, include=products)
iterator = ifcopenshell.geom.iterator(settings, self.file, include=products)
if self.ifc_import_settings.should_cache:
cache = IfcStore.get_cache()
if cache:
@@ -787,10 +784,10 @@ class IfcImporter:
self.structural_collection.children.link(self.structural_connection_collection)
self.project["blender"].children.link(self.structural_collection)
self.create_curve_products(self.file.by_type("IfcStructuralCurveMember"))
self.create_curve_products(self.file.by_type("IfcStructuralCurveConnection"))
self.create_curve_products(self.file.by_type("IfcStructuralSurfaceMember"))
self.create_curve_products(self.file.by_type("IfcStructuralSurfaceConnection"))
self.create_products(self.file.by_type("IfcStructuralCurveMember"), settings=self.settings_2d)
self.create_products(self.file.by_type("IfcStructuralCurveConnection"), settings=self.settings_2d)
self.create_products(self.file.by_type("IfcStructuralSurfaceMember"), settings=self.settings_2d)
self.create_products(self.file.by_type("IfcStructuralSurfaceConnection"), settings=self.settings_2d)
self.create_structural_point_connections()
def create_structural_point_connections(self):
@@ -878,40 +875,6 @@ class IfcImporter:
self.link_element(product, obj)
return product
def create_curve_products(self, products):
results = set()
if not products:
return results
if self.ifc_import_settings.should_use_cpu_multiprocessing:
iterator = ifcopenshell.geom.iterator(
self.settings_2d, self.file, multiprocessing.cpu_count(), include=products
)
else:
iterator = ifcopenshell.geom.iterator(self.settings_2d, self.file, include=products)
if self.ifc_import_settings.should_cache:
cache = IfcStore.get_cache()
if cache:
iterator.set_cache(cache)
valid_file = iterator.initialize()
if not valid_file:
return results
checkpoint = time.time()
total = 0
while True:
total += 1
if total % 250 == 0:
print("{} elements processed in {:.2f}s ...".format(total, time.time() - checkpoint))
checkpoint = time.time()
shape = iterator.get()
if shape:
product = self.file.by_id(shape.id)
self.create_product(product, shape)
results.add(product)
if not iterator.next():
break
print("Done creating geometry")
return results
def create_product(self, element, shape=None, mesh=None):
if element is None:
return
@@ -925,9 +888,6 @@ class IfcImporter:
if mesh:
pass
elif element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
mesh = self.create_camera(element, shape)
tool.Loader.link_mesh(shape, mesh)
elif element.is_a("IfcAnnotation") and self.is_curve_annotation(element) and shape:
mesh = self.create_curve(element, shape)
tool.Loader.link_mesh(shape, mesh)
@@ -1317,7 +1277,6 @@ class IfcImporter:
bpy.context.view_layer.objects.active = last_obj
context_override = {}
bpy.ops.object.editmode_toggle(context_override)
bpy.ops.mesh.remove_doubles(context_override)
bpy.ops.mesh.tris_convert_to_quads(context_override)
bpy.ops.mesh.normals_make_consistent(context_override)
bpy.ops.object.editmode_toggle(context_override)
@@ -1352,39 +1311,43 @@ class IfcImporter:
bpy.context.scene.unit_settings.length_unit = "FEET"
elif unit.is_a("IfcNamedUnit") and unit.UnitType == "AREAUNIT":
name = unit.Name if unit.is_a("IfcSIUnit") else unit.Name.lower()
bpy.context.scene.BIMProperties.area_unit = "{}{}".format(
unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name
)
try:
bpy.context.scene.BIMProperties.area_unit = "{}{}".format(
unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name
)
except: # Probably an invalid unit.
bpy.context.scene.BIMProperties.area_unit = "SQUARE_METRE"
elif unit.is_a("IfcNamedUnit") and unit.UnitType == "VOLUMEUNIT":
name = unit.Name if unit.is_a("IfcSIUnit") else unit.Name.lower()
bpy.context.scene.BIMProperties.volume_unit = "{}{}".format(
unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name
)
try:
bpy.context.scene.BIMProperties.volume_unit = "{}{}".format(
unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name
)
except: # Probably an invalid unit.
bpy.context.scene.BIMProperties.volume_unit = "CUBIC_METRE"
def create_project(self):
project = self.file.by_type("IfcProject")[0]
self.project = {"ifc": project}
obj = tool.Ifc.get_object(project)
if obj:
self.project["blender"] = obj.users_collection[0]
self.project["blender"] = obj.BIMObjectProperties.collection
self.has_existing_project = True
return
self.project["blender"] = bpy.data.collections.new(
"{}/{}".format(self.project["ifc"].is_a(), self.project["ifc"].Name)
)
obj = self.create_product(self.project["ifc"])
if obj:
self.project["blender"].objects.link(obj)
self.project["blender"].objects.link(obj)
self.project["blender"].BIMCollectionProperties.obj = obj
obj.BIMObjectProperties.collection = self.project["blender"]
def create_collections(self):
if self.ifc_import_settings.collection_mode == "DECOMPOSITION":
self.create_decomposition_collections()
elif self.ifc_import_settings.collection_mode == "SPATIAL_DECOMPOSITION":
self.create_spatial_decomposition_collections()
def create_decomposition_collections(self):
self.create_spatial_decomposition_collections()
self.create_aggregate_collections()
if self.ifc_import_settings.collection_mode == "DECOMPOSITION":
self.create_aggregate_collections()
elif self.ifc_import_settings.collection_mode == "SPATIAL_DECOMPOSITION":
pass
def create_spatial_decomposition_collections(self):
for rel_aggregate in self.project["ifc"].IsDecomposedBy or []:
@@ -1427,7 +1390,7 @@ class IfcImporter:
obj = tool.Ifc.get_object(element)
if obj:
is_existing = True
collection = obj.users_collection[0]
collection = obj.BIMObjectProperties.collection
self.collections[element.GlobalId] = collection
if not is_existing:
collection = bpy.data.collections.new(tool.Loader.get_name(element))
@@ -1513,183 +1476,18 @@ class IfcImporter:
if not blender_material:
name = style.Name or str(style.id())
blender_material = bpy.data.materials.new(name)
blender_material.use_fake_user = True
self.link_element(style, blender_material)
blender_material.BIMMaterialProperties.ifc_style_id = style.id()
self.material_creator.styles[style.id()] = blender_material
rendering_style = None
texture_style = None
for surface_style in style.Styles:
if surface_style.is_a() == "IfcSurfaceStyleShading":
self.create_surface_style_shading(blender_material, surface_style)
elif surface_style.is_a("IfcSurfaceStyleRendering"):
rendering_style = surface_style
self.create_surface_style_rendering(blender_material, surface_style)
elif surface_style.is_a("IfcSurfaceStyleWithTextures"):
texture_style = surface_style
if rendering_style and texture_style:
self.create_surface_style_with_textures(blender_material, rendering_style, texture_style)
tool.Style.record_shading(blender_material)
def create_surface_style_shading(self, blender_material, surface_style):
alpha = 1.0
# Transparency was added in IFC4
if hasattr(surface_style, "Transparency") and surface_style.Transparency:
alpha = 1 - surface_style.Transparency
blender_material.diffuse_color = (
surface_style.SurfaceColour.Red,
surface_style.SurfaceColour.Green,
surface_style.SurfaceColour.Blue,
alpha,
)
def create_surface_style_rendering(self, blender_material, surface_style):
self.create_surface_style_shading(blender_material, surface_style)
if surface_style.ReflectanceMethod in ["PHYSICAL", "NOTDEFINED"]:
blender_material.use_nodes = True
bsdf = blender_material.node_tree.nodes["Principled BSDF"]
if surface_style.DiffuseColour:
if surface_style.DiffuseColour.is_a("IfcColourRgb"):
bsdf.inputs["Base Color"].default_value = (
surface_style.DiffuseColour.Red,
surface_style.DiffuseColour.Green,
surface_style.DiffuseColour.Blue,
1,
)
elif surface_style.DiffuseColour.is_a("IfcNormalisedRatioMeasure"):
bsdf.inputs["Base Color"].default_value = (
surface_style.SurfaceColour.Red * surface_style.DiffuseColour.wrappedValue,
surface_style.SurfaceColour.Green * surface_style.DiffuseColour.wrappedValue,
surface_style.SurfaceColour.Blue * surface_style.DiffuseColour.wrappedValue,
1,
)
if surface_style.SpecularColour and surface_style.SpecularColour.is_a("IfcNormalisedRatioMeasure"):
bsdf.inputs["Metallic"].default_value = surface_style.SpecularColour.wrappedValue
if surface_style.SpecularHighlight and surface_style.SpecularHighlight.is_a("IfcSpecularRoughness"):
bsdf.inputs["Roughness"].default_value = surface_style.SpecularHighlight.wrappedValue
if hasattr(surface_style, "Transparency") and surface_style.Transparency:
bsdf.inputs["Alpha"].default_value = 1 - surface_style.Transparency
blender_material.blend_method = "BLEND"
elif surface_style.ReflectanceMethod == "FLAT":
blender_material.use_nodes = True
output = {n.type: n for n in blender_material.node_tree.nodes}.get("OUTPUT_MATERIAL", None)
bsdf = blender_material.node_tree.nodes["Principled BSDF"]
mix = blender_material.node_tree.nodes.new(type="ShaderNodeMixShader")
mix.location = bsdf.location
blender_material.node_tree.links.new(mix.outputs[0], output.inputs["Surface"])
blender_material.node_tree.nodes.remove(bsdf)
lightpath = blender_material.node_tree.nodes.new(type="ShaderNodeLightPath")
lightpath.location = mix.location - mathutils.Vector((200, -200))
blender_material.node_tree.links.new(lightpath.outputs[0], mix.inputs[0])
bsdf = blender_material.node_tree.nodes.new(type="ShaderNodeBsdfTransparent")
bsdf.location = mix.location - mathutils.Vector((200, 0))
blender_material.node_tree.links.new(bsdf.outputs[0], mix.inputs[1])
rgb = blender_material.node_tree.nodes.new(type="ShaderNodeRGB")
rgb.location = mix.location - mathutils.Vector((200, 200))
blender_material.node_tree.links.new(rgb.outputs[0], mix.inputs[2])
if surface_style.DiffuseColour and surface_style.DiffuseColour.is_a("IfcColourRgb"):
rgb.outputs[0].default_value = (
surface_style.DiffuseColour.Red,
surface_style.DiffuseColour.Green,
surface_style.DiffuseColour.Blue,
1,
)
def create_surface_style_with_textures(self, blender_material, rendering_style, texture_style):
for texture in texture_style.Textures:
mode = getattr(texture, "Mode", None)
node = None
if texture.is_a("IfcImageTexture"):
image_url = texture.URLReference
if not os.path.abspath(texture.URLReference) and tool.Ifc.get_path():
image_url = os.path.join(os.path.dirname(tool.Ifc.get_path()), texture.URLReference)
if rendering_style.ReflectanceMethod in ["PHYSICAL", "NOTDEFINED"]:
bsdf = blender_material.node_tree.nodes["Principled BSDF"]
if mode == "NORMAL":
normalmap = blender_material.node_tree.nodes.new(type="ShaderNodeNormalMap")
normalmap.location = bsdf.location - mathutils.Vector((200, 0))
blender_material.node_tree.links.new(normalmap.outputs[0], bsdf.inputs["Normal"])
node = blender_material.node_tree.nodes.new(type="ShaderNodeTexImage")
node.location = normalmap.location - mathutils.Vector((200, 0))
image = bpy.data.images.load(image_url)
image.colorspace_settings.name = "Non-Color"
node.image = image
blender_material.node_tree.links.new(node.outputs[0], normalmap.inputs["Color"])
elif mode == "EMISSIVE":
output = {n.type: n for n in blender_material.node_tree.nodes}.get("OUTPUT_MATERIAL", None)
add = blender_material.node_tree.nodes.new(type="ShaderNodeAddShader")
add.location = bsdf.location + mathutils.Vector((200, 0))
blender_material.node_tree.links.new(bsdf.outputs[0], add.inputs[1])
blender_material.node_tree.links.new(add.outputs[0], output.inputs[0])
emission = blender_material.node_tree.nodes.new(type="ShaderNodeEmission")
emission.location = add.location - mathutils.Vector((200, 0))
blender_material.node_tree.links.new(emission.outputs[0], add.inputs[0])
node = blender_material.node_tree.nodes.new(type="ShaderNodeTexImage")
node.location = emission.location - mathutils.Vector((200, 0))
image = bpy.data.images.load(image_url)
node.image = image
blender_material.node_tree.links.new(node.outputs[0], emission.inputs[0])
elif mode == "METALLICROUGHNESS":
separate = blender_material.node_tree.nodes.new(type="ShaderNodeSeparateRGB")
separate.location = bsdf.location - mathutils.Vector((200, 0))
blender_material.node_tree.links.new(separate.outputs[1], bsdf.inputs["Roughness"])
blender_material.node_tree.links.new(separate.outputs[2], bsdf.inputs["Metallic"])
node = blender_material.node_tree.nodes.new(type="ShaderNodeTexImage")
node.location = separate.location - mathutils.Vector((200, 0))
image = bpy.data.images.load(image_url)
image.colorspace_settings.name = "Non-Color"
node.image = image
blender_material.node_tree.links.new(node.outputs[0], separate.inputs[0])
elif mode == "OCCLUSION":
# TODO work out how to implement glTF settings here
# https://docs.blender.org/manual/en/dev/addons/import_export/scene_gltf2.html
pass
elif mode == "DIFFUSE":
node = blender_material.node_tree.nodes.new(type="ShaderNodeTexImage")
node.location = bsdf.location - mathutils.Vector((400, 0))
image = bpy.data.images.load(image_url)
node.image = image
blender_material.node_tree.links.new(node.outputs[0], bsdf.inputs["Base Color"])
blender_material.node_tree.links.new(node.outputs[1], bsdf.inputs["Alpha"])
blender_material.blend_method = "BLEND"
elif rendering_style.ReflectanceMethod == "FLAT":
bsdf = blender_material.node_tree.nodes["Mix Shader"]
if mode == "EMISSIVE":
node = blender_material.node_tree.nodes.new(type="ShaderNodeTexImage")
node.location = bsdf.location - mathutils.Vector((200, 0))
image = bpy.data.images.load(image_url)
node.image = image
blender_material.node_tree.links.new(node.outputs[0], bsdf.inputs[2])
if node and getattr(texture, "IsMappedBy", None):
coordinates = texture.IsMappedBy[0]
coord = blender_material.node_tree.nodes.new(type="ShaderNodeTexCoord")
coord.location = node.location - mathutils.Vector((200, 0))
if coordinates.is_a("IfcTextureCoordinateGenerator") and coordinates.Mode == "COORD":
blender_material.node_tree.links.new(coord.outputs["Generated"], node.inputs["Vector"])
elif coordinates.is_a("IfcTextureCoordinateGenerator") and coordinates.Mode == "COORD-EYE":
blender_material.node_tree.links.new(coord.outputs["Camera"], node.inputs["Vector"])
else:
blender_material.node_tree.links.new(coord.outputs["UV"], node.inputs["Vector"])
style_elements = tool.Style.get_style_elements(blender_material)
if tool.Style.has_blender_external_style(style_elements):
blender_material.BIMStyleProperties.active_style_type = "External"
else:
blender_material.BIMStyleProperties.active_style_type = "Shading"
def place_objects_in_collections(self):
for ifc_definition_id, obj in self.added_data.items():
@@ -1709,6 +1507,8 @@ class IfcImporter:
return
elif element.GlobalId in self.collections:
collection = self.collections[element.GlobalId]
collection.BIMCollectionProperties.obj = obj
obj.BIMObjectProperties.collection = collection
collection.name = obj.name
return collection.objects.link(obj)
elif getattr(element, "Decomposes", None):
@@ -1723,7 +1523,10 @@ class IfcImporter:
elif element.is_a("IfcGridAxis"):
return
elif element.GlobalId in self.collections:
return self.collections[element.GlobalId].objects.link(obj)
collection = self.collections[element.GlobalId]
collection.BIMCollectionProperties.obj = obj
obj.BIMObjectProperties.collection = collection
return collection.objects.link(obj)
elif element.is_a("IfcTypeObject"):
return self.type_collection.objects.link(obj)
elif element.is_a("IfcStructuralMember"):
@@ -1750,14 +1553,8 @@ class IfcImporter:
bpy.context.scene.collection.objects.link(obj)
def is_curve_annotation(self, element):
return element.ObjectType in [
"DIMENSION",
"EQUAL_DIMENSION",
"PLAN_LEVEL",
"SECTION_LEVEL",
"STAIR_ARROW",
"TEXT_LEADER",
]
object_type = element.ObjectType
return object_type in ANNOTATION_TYPES_DATA and ANNOTATION_TYPES_DATA[object_type][3] == "curve"
def get_drawing_group(self, element):
for rel in element.HasAssignments or []:
@@ -1838,54 +1635,6 @@ class IfcImporter:
):
return representation.Items[0].MappingTarget
def create_camera(self, element, shape):
if hasattr(shape, "geometry"):
geometry = shape.geometry
else:
geometry = shape
v = geometry.verts
x = [v[i] for i in range(0, len(v), 3)]
y = [v[i + 1] for i in range(0, len(v), 3)]
z = [v[i + 2] for i in range(0, len(v), 3)]
width = max(x) - min(x)
height = max(y) - min(y)
depth = max(z) - min(z)
camera = bpy.data.cameras.new(tool.Loader.get_mesh_name(geometry))
camera.type = "ORTHO"
camera.ortho_scale = width if width > height else height
camera.clip_end = depth
if width > height:
camera.BIMCameraProperties.raster_x = 1000
camera.BIMCameraProperties.raster_y = round(1000 * (height / width))
else:
camera.BIMCameraProperties.raster_x = round(1000 * (width / height))
camera.BIMCameraProperties.raster_y = 1000
psets = ifcopenshell.util.element.get_psets(element)
pset = psets.get("EPset_Drawing")
if pset:
if "TargetView" in pset:
camera.BIMCameraProperties.target_view = pset["TargetView"]
if "Scale" in pset:
valid_scales = [
i[0] for i in get_diagram_scales(None, bpy.context) if pset["Scale"] == i[0].split("|")[-1]
]
if valid_scales:
camera.BIMCameraProperties.diagram_scale = valid_scales[0]
else:
camera.BIMCameraProperties.diagram_scale = "CUSTOM"
camera.BIMCameraProperties.custom_diagram_scale = pset["Scale"]
if "HasUnderlay" in pset:
camera.BIMCameraProperties.has_underlay = pset["HasUnderlay"]
if "HasLinework" in pset:
camera.BIMCameraProperties.has_linework = pset["HasLinework"]
if "HasAnnotation" in pset:
camera.BIMCameraProperties.has_annotation = pset["HasAnnotation"]
return camera
def create_curve(self, element, shape):
if hasattr(shape, "geometry"):
geometry = shape.geometry
@@ -1970,6 +1719,7 @@ class IfcImporter:
mesh.polygons.add(num_loops)
mesh.polygons.foreach_set("loop_start", loop_start)
mesh.polygons.foreach_set("loop_total", loop_total)
mesh.polygons.foreach_set("use_smooth", [0]*total_faces)
mesh.update()
else:
e = geometry.edges
@@ -34,7 +34,6 @@ class AggregateData:
cls.data = {
"has_relating_object": cls.has_relating_object(),
"relating_object_label": cls.get_relating_object_label(),
"relating_object_id": cls.get_relating_object_id(),
"has_related_objects": cls.has_related_objects(),
"related_objects_amount": cls.get_related_objects_amount(),
"ifc_class": cls.ifc_class(),
@@ -55,12 +54,6 @@ class AggregateData:
if aggregate:
return f"{aggregate.is_a()}/{aggregate.Name or ''}"
@classmethod
def get_relating_object_id(cls) -> int:
aggregate = cls.get_relating_object()
if aggregate:
return aggregate.id()
@classmethod
def get_related_objects(cls):
return ifcopenshell.util.element.get_parts(tool.Ifc.get_entity(bpy.context.active_object))
@@ -40,16 +40,31 @@ class BIM_OT_assign_object(bpy.types.Operator, Operator):
bl_label = "Assign Object"
bl_options = {"REGISTER", "UNDO"}
relating_object: bpy.props.IntProperty()
related_object: bpy.props.IntProperty()
def _execute(self, context):
core.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(tool.Ifc.get().by_id(self.relating_object)),
related_obj=tool.Ifc.get_object(tool.Ifc.get().by_id(self.related_object)),
)
relating_obj = None
if self.relating_object:
relating_obj = tool.Ifc.get_object(tool.Ifc.get().by_id(self.relating_object))
elif context.active_object:
relating_obj = context.active_object
if not relating_obj:
return
for obj in bpy.context.selected_objects:
if obj == relating_obj:
continue
element = tool.Ifc.get_entity(obj)
if not element:
continue
result = core.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=relating_obj,
related_obj=obj,
)
if not result:
self.report({"ERROR"}, f" Cannot aggregate {obj.name} to {relating_obj.name}")
class BIM_OT_unassign_object(bpy.types.Operator, Operator):
@@ -58,16 +73,22 @@ class BIM_OT_unassign_object(bpy.types.Operator, Operator):
bl_idname = "bim.unassign_object"
bl_label = "Unassign Object"
bl_options = {"REGISTER", "UNDO"}
relating_object: bpy.props.IntProperty()
related_object: bpy.props.IntProperty()
def _execute(self, context):
core.unassign_object(
tool.Ifc,
tool.Collector,
relating_obj=tool.Ifc.get_object(tool.Ifc.get().by_id(self.relating_object)),
related_obj=tool.Ifc.get_object(tool.Ifc.get().by_id(self.related_object)),
)
for obj in bpy.context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element:
continue
aggregate = ifcopenshell.util.element.get_aggregate(element)
if not aggregate:
continue
core.unassign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(aggregate),
related_obj=tool.Ifc.get_object(element),
)
class BIM_OT_enable_editing_aggregate(bpy.types.Operator, Operator):
@@ -92,52 +113,58 @@ class BIM_OT_disable_editing_aggregate(bpy.types.Operator, Operator):
core.disable_editing_aggregate(tool.Aggregate, obj=context.active_object)
class BIM_OT_add_aggregate(bpy.types.Operator):
class BIM_OT_add_aggregate(bpy.types.Operator, tool.Ifc.Operator):
"""Add aggregate to IFC element"""
bl_idname = "bim.add_aggregate"
bl_label = "Add Aggregate"
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty()
ifc_class: bpy.props.StringProperty(name="IFC Class", default="IfcElementAssembly")
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
row = self.layout
row.prop(self, "ifc_class")
def _execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
element = tool.Ifc.get_entity(obj)
if not element:
return {"FINISHED"}
try:
ifc_class = tool.Ifc.schema().declaration_by_name(self.ifc_class).name()
except:
return
aggregate = self.create_aggregate(context, ifc_class)
aggregate = self.create_aggregate(context)
tool.Collector.sync(obj)
current_aggregate = ifcopenshell.util.element.get_aggregate(element)
current_container = ifcopenshell.util.element.get_container(element)
if current_aggregate:
core.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(current_aggregate),
related_obj=aggregate,
)
elif current_container:
blenderbim.core.spatial.assign_container(
tool.Ifc,
tool.Collector,
tool.Spatial,
structure_obj=tool.Ifc.get_object(current_container),
element_obj=aggregate,
)
core.assign_object(tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=aggregate, related_obj=obj)
return {"FINISHED"}
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element:
continue
def create_aggregate(self, context):
aggregate_collection = bpy.data.collections.new("IfcElementAssembly/Assembly")
context.scene.collection.children.link(aggregate_collection)
tool.Collector.sync(obj)
current_aggregate = ifcopenshell.util.element.get_aggregate(element)
current_container = ifcopenshell.util.element.get_container(element)
if current_aggregate:
core.assign_object(
tool.Ifc,
tool.Aggregate,
tool.Collector,
relating_obj=tool.Ifc.get_object(current_aggregate),
related_obj=aggregate,
)
elif current_container:
blenderbim.core.spatial.assign_container(
tool.Ifc,
tool.Collector,
tool.Spatial,
structure_obj=tool.Ifc.get_object(current_container),
element_obj=aggregate,
)
core.assign_object(tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=aggregate, related_obj=obj)
def create_aggregate(self, context, ifc_class):
aggregate = bpy.data.objects.new("Assembly", None)
aggregate_collection.objects.link(aggregate)
bpy.ops.bim.assign_class(obj=aggregate.name, ifc_class="IfcElementAssembly")
bpy.ops.bim.assign_class(obj=aggregate.name, ifc_class=ifc_class)
return aggregate
@@ -56,7 +56,6 @@ class BIM_PT_aggregate(Panel):
if props.relating_object:
op = row.operator("bim.assign_object", icon="CHECKMARK", text="")
op.relating_object = props.relating_object.BIMObjectProperties.ifc_definition_id
op.related_object = context.active_object.BIMObjectProperties.ifc_definition_id
row.operator("bim.disable_editing_aggregate", icon="CANCEL", text="")
else:
row = layout.row(align=True)
@@ -67,8 +66,6 @@ class BIM_PT_aggregate(Panel):
row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="")
row.operator("bim.add_aggregate", icon="ADD", text="")
op = row.operator("bim.unassign_object", icon="X", text="")
op.relating_object = AggregateData.data["relating_object_id"]
op.related_object = context.active_object.BIMObjectProperties.ifc_definition_id
else:
row.label(text="No Aggregate", icon="TRIA_UP")
row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="")
@@ -59,9 +59,13 @@ class MaterialAttributesData:
@classmethod
def load(cls):
cls.data = {"attributes": cls.attributes()}
cls.data = {"ifc_definition_id": cls.ifc_definition_id(), "attributes": cls.attributes()}
cls.is_loaded = True
@classmethod
def ifc_definition_id(cls):
return bpy.context.active_object.active_material.BIMObjectProperties.ifc_definition_id
@classmethod
def attributes(cls):
results = []
@@ -50,7 +50,22 @@ class EnableEditingAttributes(bpy.types.Operator):
oprops = obj.BIMObjectProperties
props = obj.BIMAttributeProperties
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.add_attribute_description(new)
new.description += " The degrees, minutes and seconds should follow this format : [12,34,56]"
blenderbim.bim.helper.import_attributes2(
tool.Ifc.get().by_id(oprops.ifc_definition_id), props.attributes, callback=callback
)
props.is_editing_attributes = True
return {"FINISHED"}
@@ -87,7 +102,19 @@ class EditAttributes(bpy.types.Operator, Operator):
obj = bpy.data.materials.get(self.obj)
props = obj.BIMAttributeProperties
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)
bpy.ops.bim.disable_editing_attributes(obj=obj.name, obj_type=self.obj_type)
return {"FINISHED"}
@@ -94,4 +94,10 @@ class BIM_PT_material_attributes(Panel):
def draw(self, context):
if not MaterialAttributesData.is_loaded:
MaterialAttributesData.load()
elif (
context.active_object.active_material.BIMObjectProperties.ifc_definition_id
!= MaterialAttributesData.data["ifc_definition_id"]
):
MaterialAttributesData.load()
draw_ui(context, self.layout, "Material", MaterialAttributesData.data["attributes"])
@@ -218,7 +218,7 @@ class EditBcfTopicName(bpy.types.Operator):
props = context.scene.BCFProperties
blender_topic = props.active_topic
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = bcfxml.topics[blender_topic.name]
topic = bcfxml.topics[blender_topic.name].topic
topic.title = blender_topic.title
return {"FINISHED"}
@@ -233,7 +233,7 @@ class EditBcfTopic(bpy.types.Operator):
blender_topic = props.active_topic
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = bcfxml.topics[blender_topic.name]
topic = bcfxml.topics[blender_topic.name].topic
topic.title = blender_topic.title or None
topic.priority = blender_topic.priority or None
topic.due_date = blender_topic.due_date or None
@@ -940,7 +940,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
context.area.type = old
for global_id in exception_global_ids:
obj = IfcStore.get_element(global_id)
if obj:
if obj and bpy.context.view_layer.objects.get(obj.name):
obj.hide_set(True)
else:
objs = []
@@ -20,28 +20,37 @@ import bpy
from . import ui, operator, prop
classes = (
operator.AddBoundary,
operator.ColourByRelatedBuildingElement,
operator.DisableEditingBoundary,
operator.DisableEditingBoundaryGeometry,
operator.EditBoundaryAttributes,
operator.EditBoundaryGeometry,
operator.EnableEditingBoundary,
operator.EnableEditingBoundaryGeometry,
operator.HideBoundaries,
operator.LoadBoundary,
operator.LoadProjectSpaceBoundaries,
operator.LoadSpaceBoundaries,
operator.LoadBoundary,
operator.SelectRelatedElementBoundaries,
operator.SelectProjectBoundaries,
operator.SelectRelatedElementBoundaries,
operator.SelectRelatedElementTypeBoundaries,
operator.SelectSpaceBoundaries,
operator.ShowBoundaries,
operator.UpdateBoundaryGeometry,
ui.BIM_PT_Boundary,
ui.BIM_PT_SceneBoundaries,
ui.BIM_PT_SpaceBoundaries,
prop.BIMBoundaryProperties,
prop.BIMObjectBoundaryProperties,
)
def register():
bpy.types.Object.bim_boundary_properties = bpy.props.PointerProperty(type=prop.BIMBoundaryProperties)
bpy.types.Scene.BIMBoundaryProperties = bpy.props.PointerProperty(type=prop.BIMBoundaryProperties)
bpy.types.Object.bim_boundary_properties = bpy.props.PointerProperty(type=prop.BIMObjectBoundaryProperties)
def unregister():
del bpy.types.Scene.BIMBoundaryProperties
del bpy.types.Object.bim_boundary_properties
@@ -0,0 +1,112 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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/>.
import gpu
import bmesh
import blenderbim.tool as tool
from bpy.types import SpaceView3D
from mathutils import Vector
from gpu_extras.batch import batch_for_shader
class BoundaryDecorator:
installed = None
@classmethod
def install(cls, context):
if cls.installed:
cls.uninstall()
handler = cls()
cls.installed = SpaceView3D.draw_handler_add(handler, (context,), "WINDOW", "POST_VIEW")
@classmethod
def uninstall(cls):
try:
SpaceView3D.draw_handler_remove(cls.installed, "WINDOW")
except ValueError:
pass
cls.installed = None
def draw_batch(self, shader_type, content_pos, color, indices=None):
shader = self.line_shader if shader_type == "LINES" else self.shader
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
shader.uniform_float("color", color)
batch.draw(shader)
def __call__(self, context):
self.addon_prefs = context.preferences.addons["blenderbim"].preferences
selected_elements_color = self.addon_prefs.decorator_color_selected
unselected_elements_color = self.addon_prefs.decorator_color_unselected
special_elements_color = self.addon_prefs.decorator_color_special
def transparent_color(color, alpha=0.1):
color = [i for i in color]
color[3] = alpha
return color
gpu.state.point_size_set(6)
gpu.state.blend_set("ALPHA")
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() # required to be able to change uniforms of the shader
# POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0)
# general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR")
selected_vertices = []
selected_edges = []
selected_tris = []
unselected_vertices = []
unselected_edges = []
unselected_tris = []
for boundary in context.scene.BIMBoundaryProperties.boundaries:
obj = boundary.obj
if not obj or not obj.data: # A boundary may not have data if it has no connection geometry
continue
if obj.mode == "EDIT":
continue # A profile decorator or something else is used here.
else:
bm = bmesh.new()
bm.from_mesh(obj.data)
obj.data.calc_loop_triangles()
if obj.select_get():
offset = len(selected_vertices)
selected_vertices.extend([tuple(obj.matrix_world @ v.co) for v in bm.verts])
selected_edges.extend([tuple([v.index + offset for v in e.verts]) for e in bm.edges])
selected_tris.extend([tuple([i + offset for i in t.vertices]) for t in obj.data.loop_triangles])
else:
offset = len(unselected_vertices)
unselected_vertices.extend([tuple(obj.matrix_world @ v.co) for v in bm.verts])
unselected_edges.extend([tuple([v.index + offset for v in e.verts]) for e in bm.edges])
unselected_tris.extend([tuple([i + offset for i in t.vertices]) for t in obj.data.loop_triangles])
if obj.mode != "EDIT":
bm.free()
if unselected_edges:
self.draw_batch("LINES", unselected_vertices, special_elements_color, unselected_edges)
self.draw_batch("TRIS", unselected_vertices, transparent_color(special_elements_color), unselected_tris)
if selected_edges:
self.draw_batch("LINES", selected_vertices, selected_elements_color, selected_edges)
self.draw_batch("TRIS", selected_vertices, transparent_color(selected_elements_color), selected_tris)
@@ -18,18 +18,28 @@
import bpy
import bmesh
import mathutils
import logging
import shapely
import mathutils
import numpy as np
import ifcopenshell.api
import ifcopenshell.util.placement
import ifcopenshell.util.unit
import ifcopenshell.util.shape
import ifcopenshell.util.element
import ifcopenshell.util.placement
import ifcopenshell.util.representation
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
import blenderbim.bim.import_ifc as import_ifc
from math import pi, inf
from mathutils import Vector, Matrix
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.model.decorator import ProfileDecorator
from blenderbim.bim.module.boundary.decorator import BoundaryDecorator
import blenderbim.core
def get_boundaries_collection(blender_space):
space_collection = bpy.data.collections.get(blender_space.name, blender_space.users_collection[0])
space_collection = blender_space.BIMObjectProperties.collection
collection_name = f"Boundaries/{blender_space.BIMObjectProperties.ifc_definition_id}"
boundaries_collection = space_collection.children.get(collection_name)
if not boundaries_collection:
@@ -38,6 +48,20 @@ def get_boundaries_collection(blender_space):
return boundaries_collection
def disable_editing_boundary_geometry(context):
ProfileDecorator.uninstall()
bpy.ops.object.mode_set(mode="OBJECT")
obj = context.active_object
element = tool.Ifc.get_entity(obj)
old_mesh = obj.data
loader = Loader()
obj.data = loader.create_mesh(element)
tool.Geometry.delete_data(old_mesh)
return {"FINISHED"}
class Loader:
def __init__(self):
self.ifc_file = None
@@ -119,7 +143,7 @@ class Loader:
class LoadProjectSpaceBoundaries(bpy.types.Operator):
bl_idname = "bim.load_project_space_boundaries"
bl_label = "Load all project space boundaries"
bl_label = "Load All Project Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -131,7 +155,7 @@ class LoadProjectSpaceBoundaries(bpy.types.Operator):
class LoadBoundary(bpy.types.Operator):
bl_idname = "bim.load_boundary"
bl_label = "Load boundary"
bl_label = "Load Boundary"
bl_options = {"REGISTER", "UNDO"}
boundary_id: bpy.props.IntProperty()
@@ -147,7 +171,7 @@ class LoadBoundary(bpy.types.Operator):
class LoadSpaceBoundaries(bpy.types.Operator):
bl_idname = "bim.load_space_boundaries"
bl_label = "Load selected space boundaries"
bl_label = "Load Selected Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -168,7 +192,7 @@ def get_element_boundaries(element):
class SelectRelatedElementBoundaries(bpy.types.Operator):
bl_idname = "bim.select_related_element_boundaries"
bl_label = "Select related element space boundaries"
bl_label = "Select Related Element Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
related_element: bpy.props.IntProperty()
@@ -185,7 +209,7 @@ class SelectRelatedElementBoundaries(bpy.types.Operator):
class SelectRelatedElementTypeBoundaries(bpy.types.Operator):
bl_idname = "bim.select_related_element_type_boundaries"
bl_label = "Select related element type space boundaries"
bl_label = "Select Related Element Type Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
related_element: bpy.props.IntProperty()
@@ -208,7 +232,7 @@ class SelectRelatedElementTypeBoundaries(bpy.types.Operator):
class SelectSpaceBoundaries(bpy.types.Operator):
bl_idname = "bim.select_space_boundaries"
bl_label = "Select all space boundaries"
bl_label = "Select All Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -224,7 +248,7 @@ class SelectSpaceBoundaries(bpy.types.Operator):
class SelectProjectBoundaries(bpy.types.Operator):
bl_idname = "bim.select_project_space_boundaries"
bl_label = "Select all project space boundaries"
bl_label = "Select All Project Space Boundaries"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -260,7 +284,7 @@ def get_colour(ifc_boundary):
class ColourByRelatedBuildingElement(bpy.types.Operator):
bl_idname = "bim.colour_by_related_building_element"
bl_label = "Apply colour based on related building elements"
bl_label = "Apply Colour Based on Related Building Elements"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -308,7 +332,7 @@ EDITABLE_ATTRIBUTES = {
class EnableEditingBoundary(bpy.types.Operator):
bl_idname = "bim.enable_editing_boundary"
bl_label = "Edit boundary relations"
bl_label = "Edit Boundary Relations"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -327,7 +351,7 @@ class EnableEditingBoundary(bpy.types.Operator):
class DisableEditingBoundary(bpy.types.Operator):
bl_idname = "bim.disable_editing_boundary"
bl_label = "Disable editing boundary relations"
bl_label = "Disable Editing Boundary Relations"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -340,7 +364,7 @@ class DisableEditingBoundary(bpy.types.Operator):
class EditBoundaryAttributes(bpy.types.Operator):
bl_idname = "bim.edit_boundary_attributes"
bl_label = "Disable editing boundary relations"
bl_label = "Disable Editing Boundary Relations"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -361,7 +385,7 @@ class EditBoundaryAttributes(bpy.types.Operator):
class UpdateBoundaryGeometry(bpy.types.Operator):
bl_idname = "bim.update_boundary_geometry"
bl_label = "Update boundary geometry"
bl_label = "Update Boundary Geometry"
bl_description = """
Update boundary connection geometry from mesh.
Mesh must lie on a single plane. It should look like a face or a face with holes.
@@ -376,3 +400,357 @@ class UpdateBoundaryGeometry(bpy.types.Operator):
settings = tool.Boundary.get_assign_connection_geometry_settings(context.active_object)
ifcopenshell.api.run("boundary.assign_connection_geometry", tool.Ifc.get(), **settings)
return {"FINISHED"}
class EnableEditingBoundaryGeometry(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.enable_editing_boundary_geometry"
bl_label = "Enable Editing Boundary Geometry"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.selected_objects
def _execute(self, context):
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
obj = context.active_object
element = tool.Ifc.get_entity(obj)
if element.ConnectionGeometry.is_a("IfcConnectionSurfaceGeometry"):
surface = element.ConnectionGeometry.SurfaceOnRelatingElement
tool.Model.import_surface(surface, obj)
bpy.ops.object.mode_set(mode="EDIT")
ProfileDecorator.install(context, exit_edit_mode_callback=lambda: disable_editing_boundary_geometry(context))
if not bpy.app.background:
bpy.ops.wm.tool_set_by_id(tool.Blender.get_viewport_context(), name="bim.cad_tool")
return {"FINISHED"}
class EditBoundaryGeometry(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.edit_boundary_geometry"
bl_label = "Edit Boundary Geometry"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
ProfileDecorator.uninstall()
bpy.ops.object.mode_set(mode="OBJECT")
obj = context.active_object
element = tool.Ifc.get_entity(obj)
if element.ConnectionGeometry.is_a("IfcConnectionSurfaceGeometry"):
surface = tool.Model.export_surface(obj)
if not surface:
def msg(self, context):
self.layout.label(text="INVALID PROFILE")
bpy.context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
ProfileDecorator.install(
context, exit_edit_mode_callback=lambda: disable_editing_boundary_geometry(context)
)
bpy.ops.object.mode_set(mode="EDIT")
return
old_surface = element.ConnectionGeometry.SurfaceOnRelatingElement
for inverse in tool.Ifc.get().get_inverse(old_surface):
ifcopenshell.util.element.replace_attribute(inverse, old_surface, surface)
ifcopenshell.util.element.remove_deep2(tool.Ifc.get(), old_surface)
old_mesh = obj.data
loader = Loader()
obj.data = loader.create_mesh(element)
tool.Geometry.delete_data(old_mesh)
class DisableEditingBoundaryGeometry(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.disable_editing_boundary_geometry"
bl_label = "Disable Editing Boundary Geometry"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.selected_objects
def _execute(self, context):
return disable_editing_boundary_geometry(context)
class ShowBoundaries(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.show_boundaries"
bl_label = "Show Boundaries"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
props = bpy.context.scene.BIMBoundaryProperties
loader = Loader()
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element or not getattr(element, "BoundedBy", None):
continue
if tool.Ifc.is_moved(obj):
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
element = tool.Ifc.get_entity(obj)
for rel in element.BoundedBy or []:
boundary_obj = loader.load_boundary(rel, obj)
tool.Boundary.decorate_boundary(boundary_obj)
BoundaryDecorator.install(bpy.context)
return {"FINISHED"}
class HideBoundaries(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.hide_boundaries"
bl_label = "Hide Boundaries"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
to_delete = set()
spaces = set()
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element:
continue
if element.is_a("IfcSpace"):
spaces.add(element)
elif element.is_a("IfcRelSpaceBoundary"):
spaces.add(element.RelatingSpace)
for element in spaces:
for boundary in element.BoundedBy or []:
boundary_obj = tool.Ifc.get_object(boundary)
if boundary_obj:
to_delete.add(boundary_obj)
for boundary_obj in to_delete:
tool.Ifc.unlink(obj=boundary_obj)
bpy.data.objects.remove(boundary_obj)
context.scene.BIMBoundaryProperties.boundaries.clear()
return {"FINISHED"}
class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.add_boundary"
bl_label = "Add Boundary"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
relating_space = None
related_building_element = None
relating_space_obj = None
related_building_element_obj = None
objs = context.selected_objects
if len(objs) == 2:
# The user may select two objects, a space and its related building element
for obj in objs:
element = tool.Ifc.get_entity(obj)
if not element:
continue
if element.is_a("IfcSpace"):
relating_space = element
relating_space_obj = obj
else:
related_building_element = element
related_building_element_obj = obj
elif len(objs) == 1:
# Optionally the user may select just the space, and the building element shall be auto-detected
def msg(self, context):
self.layout.label(text="NO ACTIVE STOREY")
element = tool.Ifc.get_entity(objs[0])
if element.is_a("IfcSpace"):
relating_space = element
relating_space_obj = objs[0]
target = bpy.context.scene.cursor.location
collection = context.view_layer.active_layer_collection.collection
collection_obj = bpy.data.objects.get(collection.name)
if not collection_obj:
bpy.context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
return
spatial_element = tool.Ifc.get_entity(collection_obj)
if not spatial_element:
bpy.context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
return
for subelement in ifcopenshell.util.element.get_decomposition(spatial_element):
if not (subelement.is_a("IfcWall") or subelement.is_a("IfcSlab")):
continue
obj = tool.Ifc.get_object(subelement)
if obj:
raycast = obj.closest_point_on_mesh(obj.matrix_world.inverted() @ target, distance=0.1)
if raycast[0]:
related_building_element = subelement
related_building_element_obj = obj
break
if not relating_space or not related_building_element:
return
bm = bmesh.new()
bm.from_mesh(relating_space_obj.data)
bmesh.ops.dissolve_limit(bm, angle_limit=pi * 2 / 360, verts=bm.verts, edges=bm.edges)
target_distance = inf
target_face = None
for face in bm.faces:
centroid = relating_space_obj.matrix_world @ face.calc_center_median()
raycast = related_building_element_obj.closest_point_on_mesh(
related_building_element_obj.matrix_world.inverted() @ centroid, distance=1
)
if raycast[0]:
distance = (related_building_element_obj.matrix_world @ raycast[1] - centroid).length
if distance < target_distance:
target_face = face
target_distance = distance
if not target_face:
return
parent_boundary = tool.Ifc.run("root.create_entity", ifc_class=context.scene.BIMModelProperties.boundary_class)
# Is this right? Or should I use loop?
target_face_verts = [v.co.copy() for v in target_face.verts]
target_face_matrix = self.get_face_matrix(*[v.copy() for v in target_face_verts[0:3]])
target_face_matrix_i = target_face_matrix.inverted()
target_face_polygon = shapely.Polygon([tuple((target_face_matrix_i @ v).xy) for v in target_face_verts])
related_building_element_polygon = self.get_flattened_polygon(
related_building_element, relating_space_obj, target_face_matrix_i
)
gross_boundary_polygon = target_face_polygon.intersection(related_building_element_polygon)
if type(gross_boundary_polygon) == shapely.GeometryCollection:
for geom in gross_boundary_polygon.geoms:
if type(geom) == shapely.Polygon:
gross_boundary_polygon = geom
break
# The gross boundary polygon may not be a true gross boundary since it
# may have openings already removed, such as in IFC4 Reference View. So
# we cheat by using the exterior boundary to mean "gross". Later, we
# can use this to check whether or not the opening is relevant to our
# space.
exterior_boundary_polygon = shapely.Polygon(gross_boundary_polygon.exterior.coords)
net_boundary_polygon = shapely.Polygon(gross_boundary_polygon)
inner_boundaries = []
for rel in getattr(related_building_element, "HasOpenings", []):
opening = rel.RelatedOpeningElement
filling = None
if opening.HasFillings:
filling = opening.HasFillings[0].RelatedBuildingElement
opening_polygon = self.get_flattened_polygon(opening, relating_space_obj, target_face_matrix_i)
net_boundary_polygon = net_boundary_polygon.difference(opening_polygon)
# Only openings that are projected onto our exterior boundary are relevant.
if opening_polygon.intersection(exterior_boundary_polygon).area == 0:
continue
connection_geometry = self.create_connection_geometry_from_polygon(opening_polygon, target_face_matrix)
boundary = tool.Ifc.run("root.create_entity", ifc_class=context.scene.BIMModelProperties.boundary_class)
boundary.RelatingSpace = relating_space
boundary.RelatedBuildingElement = filling or related_building_element
boundary.ConnectionGeometry = connection_geometry
boundary.PhysicalOrVirtualBoundary = "PHYSICAL" if filling else "VIRTUAL"
boundary.InternalOrExternalBoundary = "INTERNAL"
if boundary.is_a("IfcRelSpaceBoundary2ndLevel"):
boundary.ParentBoundary = parent_boundary
connection_geometry = self.create_connection_geometry_from_polygon(net_boundary_polygon, target_face_matrix)
parent_boundary.RelatingSpace = relating_space
parent_boundary.RelatedBuildingElement = related_building_element
parent_boundary.ConnectionGeometry = connection_geometry
parent_boundary.PhysicalOrVirtualBoundary = "PHYSICAL"
parent_boundary.InternalOrExternalBoundary = "INTERNAL"
bpy.ops.bim.show_boundaries()
obj = tool.Ifc.get_object(parent_boundary)
obj.select_set(True)
def get_face_matrix(self, p1, p2, p3):
edge1 = p2 - p1
edge2 = p3 - p1
normal = edge1.cross(edge2)
z_axis = normal.normalized()
x_axis = p2 - p1
x_axis.normalize()
y_axis = z_axis.cross(x_axis)
mat = Matrix()
mat.col[0][:3] = x_axis
mat.col[1][:3] = y_axis
mat.col[2][:3] = z_axis
mat.col[3][:3] = p1
return mat
def get_flattened_polygon(self, element, relating_space_obj, target_face_matrix_i):
obj = tool.Ifc.get_object(element)
if obj and tool.Ifc.is_moved(obj):
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
space_matrix_i = relating_space_obj.matrix_world.inverted()
settings = ifcopenshell.geom.settings()
if not element.is_a("IfcOpeningElement"):
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, True)
settings.set(settings.STRICT_TOLERANCE, True)
# geometry = ifcopenshell.geom.create_shape(settings, body)
shape = ifcopenshell.geom.create_shape(settings, element)
m = shape.transformation.matrix.data
mat = Matrix(([m[0], m[3], m[6], m[9]], [m[1], m[4], m[7], m[10]], [m[2], m[5], m[8], m[11]], [0, 0, 0, 1]))
verts = [space_matrix_i @ mat @ Vector(v) for v in ifcopenshell.util.shape.get_vertices(shape.geometry)]
faces = ifcopenshell.util.shape.get_faces(shape.geometry)
polygons = []
for face in faces:
polygon = shapely.Polygon([tuple((target_face_matrix_i @ verts[vi]).xy) for vi in face])
polygons.append(polygon)
return shapely.ops.unary_union(polygons)
def create_connection_geometry_from_polygon(self, polygon, target_face_matrix):
surface = self.export_surface(polygon, target_face_matrix)
return tool.Ifc.get().createIfcConnectionSurfaceGeometry(surface)
def export_surface(self, polygon, target_face_matrix):
x_axis = target_face_matrix.col[0][:3]
z_axis = target_face_matrix.col[2][:3]
p1 = target_face_matrix.col[3][:3]
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
tool.Model.unit_scale = self.unit_scale
surface = tool.Ifc.get().createIfcCurveBoundedPlane()
surface.BasisSurface = tool.Ifc.get().createIfcPlane(tool.Ifc.get().createIfcAxis2Placement3D(
tool.Ifc.get().createIfcCartesianPoint([o / self.unit_scale for o in p1]),
tool.Ifc.get().createIfcDirection([float(o) for o in z_axis]),
tool.Ifc.get().createIfcDirection([float(o) for o in x_axis]),
))
if tool.Ifc.get().schema != "IFC2X3":
points = [tool.Model.convert_si_to_unit(list(co)) for co in polygon.exterior.coords]
point_list = tool.Ifc.get().createIfcCartesianPointList2D(points)
outer_boundary = tool.Ifc.get().createIfcIndexedPolyCurve(point_list, None, False)
inner_boundaries = []
for interior in polygon.interiors:
points = [tool.Model.convert_si_to_unit(list(co)) for co in interior.coords]
point_list = tool.Ifc.get().createIfcCartesianPointList2D(points)
inner_boundaries.append(tool.Ifc.get().createIfcIndexedPolyCurve(point_list, None, False))
else:
pass # TODO
surface.OuterBoundary = outer_boundary
surface.InnerBoundaries = inner_boundaries
return surface
@@ -18,6 +18,7 @@
import bpy
from bpy.types import PropertyGroup
from blenderbim.bim.prop import ObjProperty
from bpy.props import (
PointerProperty,
StringProperty,
@@ -52,9 +53,13 @@ def element_filter(self, object):
return False
class BIMBoundaryProperties(PropertyGroup):
class BIMObjectBoundaryProperties(PropertyGroup):
is_editing: BoolProperty(name="Is Editing")
relating_space: PointerProperty(name="RelatingSpace", type=bpy.types.Object, poll=space_filter)
related_building_element: PointerProperty(name="RelatedBuildingElement", type=bpy.types.Object, poll=element_filter)
parent_boundary: PointerProperty(name="ParentBoundary", type=bpy.types.Object, poll=boundary_filter)
corresponding_boundary: PointerProperty(name="CorrespondingBoundary", type=bpy.types.Object, poll=boundary_filter)
class BIMBoundaryProperties(PropertyGroup):
boundaries: bpy.props.CollectionProperty(type=ObjProperty)
@@ -123,6 +123,7 @@ class BIM_PT_SpaceBoundaries(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_geometry_object"
@classmethod
@@ -18,8 +18,8 @@
import bpy
from blenderbim.bim.module.model.data import AuthoringData
from blenderbim.bim.module.model.root import ConstrTypeEntityNotFound
from bpy.types import PropertyGroup
from math import pi
class BIMCadProperties(PropertyGroup):
@@ -28,3 +28,7 @@ class BIMCadProperties(PropertyGroup):
distance: bpy.props.FloatProperty(name="Distance", default=0.1)
x: bpy.props.FloatProperty(name="X", default=0.2)
y: bpy.props.FloatProperty(name="Y", default=0.1)
gable_roof_edge_angle: bpy.props.FloatProperty(
name="Gable Roof Edge Angle", default=pi / 2, soft_min=0, soft_max=pi / 2, subtype="ANGLE"
)
gable_roof_separate_verts: bpy.props.BoolProperty(name="Separate Verts", default=True)
@@ -33,8 +33,7 @@ class CadTool(WorkSpaceTool):
bl_description = "Gives you CAD authoring related superpowers"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.cad")
bl_widget = None
# https://docs.blender.org/api/current/bpy.types.KeyMapItems.html
bl_keymap = (
bl_keymap = tool.Blender.get_default_selection_keypmap() + (
("bim.cad_hotkey", {"type": "C", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_C")]}),
("bim.cad_hotkey", {"type": "E", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_E")]}),
("bim.cad_hotkey", {"type": "F", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_F")]}),
@@ -46,7 +45,7 @@ class CadTool(WorkSpaceTool):
("bim.cad_hotkey", {"type": "X", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_X")]}),
)
def draw_settings(context, layout, tool):
def draw_settings(context, layout, workspace_tool):
obj = context.active_object
if not obj or not obj.data:
return
@@ -54,14 +53,19 @@ class CadTool(WorkSpaceTool):
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_Q")
if obj.BIMObjectProperties.ifc_definition_id:
row.operator("bim.edit_extrusion_profile", text="Save Profile")
row.operator("bim.align_view_to_profile", text="", icon="AXIS_FRONT")
row.operator("bim.disable_editing_extrusion_profile", text="", icon="CANCEL")
else:
row.operator("bim.edit_arbitrary_profile", text="Save Profile")
row.operator("bim.align_view_to_profile", text="", icon="AXIS_FRONT")
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
element = tool.Ifc.get_entity(obj)
if element:
if element.is_a("IfcProfileDef"):
row.operator("bim.edit_arbitrary_profile", text="Save Profile")
row.operator("bim.align_view_to_profile", text="", icon="AXIS_FRONT")
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
elif element.is_a("IfcRelSpaceBoundary"):
row.operator("bim.edit_boundary_geometry", text="Save Profile")
row.operator("bim.disable_editing_boundary_geometry", text="", icon="CANCEL")
else:
row.operator("bim.edit_extrusion_profile", text="Save Profile")
row.operator("bim.align_view_to_profile", text="", icon="AXIS_FRONT")
row.operator("bim.disable_editing_extrusion_profile", text="", icon="CANCEL")
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
@@ -139,7 +143,7 @@ class CadTool(WorkSpaceTool):
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_Q")
row.operator("bim.hotkey", text="Apply Railing Path").hotkey = "S_Q"
row.operator("bim.cad_hotkey", text="Apply Railing Path").hotkey = "S_Q"
row.operator("bim.cancel_editing_railing_path", icon="CANCEL", text="")
elif (
@@ -150,9 +154,14 @@ class CadTool(WorkSpaceTool):
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_Q")
row.operator("bim.hotkey", text="Apply Roof Path").hotkey = "S_Q"
row.operator("bim.cad_hotkey", text="Apply Roof Path").hotkey = "S_Q"
row.operator("bim.cancel_editing_roof_path", icon="CANCEL", text="")
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_R")
row.operator("bim.cad_hotkey", text="Set Gable Roof Angle").hotkey = "S_R"
row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_E")
@@ -200,20 +209,32 @@ class CadHotkey(bpy.types.Operator):
if self.is_profile():
row = self.layout.row()
row.prop(props, "radius")
elif self.hotkey == "S_F":
if not self.is_profile():
row = self.layout.row()
row.prop(props, "resolution")
row = self.layout.row()
row.prop(props, "radius")
elif self.hotkey == "S_O":
row = self.layout.row()
row.prop(props, "distance")
elif self.hotkey == "S_R":
row = self.layout.row()
row.prop(props, "x")
row = self.layout.row()
row.prop(props, "y")
if self.is_profile():
row = self.layout.row()
row.prop(props, "x")
row = self.layout.row()
row.prop(props, "y")
elif (
(RoofData.is_loaded or not RoofData.load())
and RoofData.data["parameters"]
and bpy.context.active_object.BIMRoofProperties.is_editing_path
):
self.layout.row().prop(props, "gable_roof_edge_angle")
self.layout.row().prop(props, "gable_roof_separate_verts")
elif self.hotkey == "S_V":
if not self.is_profile():
row = self.layout.row()
@@ -238,32 +259,42 @@ class CadHotkey(bpy.types.Operator):
bpy.ops.bim.cad_offset(distance=self.props.distance)
def hotkey_S_Q(self):
if tool.Ifc.get_entity(bpy.context.active_object):
if bpy.context.active_object.data.BIMMeshProperties.subshape_type == "PROFILE":
element = tool.Ifc.get_entity(bpy.context.active_object)
if bpy.context.active_object.data.BIMMeshProperties.subshape_type == "PROFILE":
if element.is_a("IfcProfileDef"):
bpy.ops.bim.edit_arbitrary_profile()
elif element.is_a("IfcRelSpaceBoundary"):
bpy.ops.bim.edit_boundary_geometry()
else:
bpy.ops.bim.edit_extrusion_profile()
elif bpy.context.active_object.data.BIMMeshProperties.subshape_type == "AXIS":
bpy.ops.bim.edit_extrusion_axis()
elif bpy.context.active_object.data.BIMMeshProperties.subshape_type == "AXIS":
bpy.ops.bim.edit_extrusion_axis()
elif (
(RailingData.is_loaded or not RailingData.load())
and RailingData.data["parameters"]
and bpy.context.active_object.BIMRailingProperties.is_editing_path
):
bpy.ops.bim.finish_editing_railing_path()
elif (
(RailingData.is_loaded or not RailingData.load())
and RailingData.data["parameters"]
and bpy.context.active_object.BIMRailingProperties.is_editing_path
):
bpy.ops.bim.finish_editing_railing_path()
elif (
(RoofData.is_loaded or not RoofData.load())
and RoofData.data["parameters"]
and bpy.context.active_object.BIMRoofProperties.is_editing_path
):
bpy.ops.bim.finish_editing_roof_path()
else:
bpy.ops.bim.edit_arbitrary_profile()
elif (
(RoofData.is_loaded or not RoofData.load())
and RoofData.data["parameters"]
and bpy.context.active_object.BIMRoofProperties.is_editing_path
):
bpy.ops.bim.finish_editing_roof_path()
def hotkey_S_R(self):
if self.is_profile():
bpy.ops.bim.add_rectangle(x=self.props.x, y=self.props.y)
elif (
(RoofData.is_loaded or not RoofData.load())
and RoofData.data["parameters"]
and bpy.context.active_object.BIMRoofProperties.is_editing_path
):
bpy.ops.bim.set_gable_roof_edge_angle(
angle=self.props.gable_roof_edge_angle, separate_verts=self.props.gable_roof_separate_verts
)
def hotkey_S_T(self):
bpy.ops.bim.cad_mitre()
@@ -31,6 +31,7 @@ from blenderbim.bim.ifc import IfcStore
class ExportClashSets(bpy.types.Operator):
bl_idname = "bim.export_clash_sets"
bl_label = "Export Clash Sets"
bl_description = "Export clash sets to a selected file"
filename_ext = ".json"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
@@ -64,6 +65,7 @@ class ImportClashSets(bpy.types.Operator):
bl_idname = "bim.import_clash_sets"
bl_label = "Import Clash Sets"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Import clash sets from a selected file"
filename_ext = ".json"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
@@ -101,6 +103,7 @@ class AddClashSet(bpy.types.Operator):
bl_idname = "bim.add_clash_set"
bl_label = "Add Clash Set"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Add a clash set"
def execute(self, context):
new = context.scene.BIMClashProperties.clash_sets.add()
@@ -113,6 +116,7 @@ class RemoveClashSet(bpy.types.Operator):
bl_idname = "bim.remove_clash_set"
bl_label = "Remove Clash Set"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Remove the selected clash set"
index: bpy.props.IntProperty()
def execute(self, context):
@@ -124,6 +128,7 @@ class AddClashSource(bpy.types.Operator):
bl_idname = "bim.add_clash_source"
bl_label = "Add Clash Source"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Add a clash source to this group"
group: bpy.props.StringProperty()
def execute(self, context):
@@ -136,6 +141,7 @@ class RemoveClashSource(bpy.types.Operator):
bl_idname = "bim.remove_clash_source"
bl_label = "Remove Clash Source"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Remove this clash source"
index: bpy.props.IntProperty()
group: bpy.props.StringProperty()
@@ -149,6 +155,7 @@ class SelectClashSource(bpy.types.Operator):
bl_idname = "bim.select_clash_source"
bl_label = "Select Clash Source"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Select an IFC file to add as a clash source"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
filter_glob: bpy.props.StringProperty(default="*.ifc", options={"HIDDEN"})
index: bpy.props.IntProperty()
@@ -197,6 +204,7 @@ class SelectSmartGroupedClashesPath(bpy.types.Operator):
class ExecuteIfcClash(bpy.types.Operator):
bl_idname = "bim.execute_ifc_clash"
bl_label = "Execute IFC Clash"
bl_description = "Execute clash detection and save the information to a .bcf or .json file"
filter_glob: bpy.props.StringProperty(default="*.bcf;*.json", options={"HIDDEN"})
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
@@ -266,6 +274,7 @@ class SelectIfcClashResults(bpy.types.Operator):
bl_idname = "bim.select_ifc_clash_results"
bl_label = "Select IFC Clash Results"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Select the clashing IFC geometry stored in a file"
filename_ext = ".json"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
@@ -299,7 +308,8 @@ class SelectIfcClashResults(bpy.types.Operator):
for scene in obj.users_scene:
if scene.BIMProperties.ifc_file:
ifc_file = scene.BIMProperties.ifc_file
break
if scene.library:
break
if ifc_file:
if ifc_file not in IfcStore.session_files:
@@ -74,6 +74,7 @@ class BIM_PT_object_constraints(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_misc_object"
@classmethod
@@ -67,6 +67,17 @@ classes = (
operator.ExpandCostItemRate,
operator.ContractCostItemRate,
operator.CalculateCostItemResourceValue,
operator.ClearCostItemAssignments,
operator.HighlightProductCostItem,
operator.LoadProductCostItems,
operator.ReorderCostItem,
operator.SelectUnassignedProducts,
operator.LoadCostItemElementQuantities,
operator.LoadCostItemTaskQuantities,
operator.LoadCostItemResourceQuantities,
operator.ChangeParentCostItem,
operator.CopyCostItem,
operator.AddCurrency,
prop.CostItem,
prop.CostItemQuantity,
prop.CostItemType,
@@ -80,6 +91,8 @@ classes = (
ui.BIM_UL_cost_item_quantities,
ui.BIM_UL_cost_item_types,
ui.BIM_UL_cost_item_rates,
ui.BIM_UL_product_cost_items,
ui.BIM_PT_Costing_Tools,
)
@@ -46,9 +46,16 @@ class CostSchedulesData:
"cost_quantities": cls.cost_quantities(),
"cost_values": cls.cost_values(),
"quantity_types": cls.quantity_types(),
"currency": cls.currency(),
}
cls.is_loaded = True
@classmethod
def currency(cls):
unit = tool.Unit.get_project_currency_unit()
if unit:
return {"id": unit.id(), "name": unit.Currency}
@classmethod
def total_cost_schedules(cls):
return len(tool.Ifc.get().by_type("IfcCostSchedule"))
@@ -62,6 +69,7 @@ class CostSchedulesData:
{
"id": schedule.id(),
"name": schedule.Name or "Unnamed",
"predefined_type": ifcopenshell.util.element.get_predefined_type(schedule),
}
)
else:
@@ -70,6 +78,7 @@ class CostSchedulesData:
{
"id": schedule.id(),
"name": schedule.Name or "Unnamed",
"predefined_type": ifcopenshell.util.element.get_predefined_type(schedule),
}
)
return results
@@ -89,9 +98,16 @@ class CostSchedulesData:
data = {}
cls._load_cost_item_quantities(cost_item, data)
cls._load_cost_values(cost_item, data)
cls._load_nesting_index(cost_item, data)
results[cost_item.id()] = data
return results
@classmethod
def _load_nesting_index(cls, cost_item, data):
data["NestingIndex"] = None
for rel in cost_item.Nests or []:
data["NestingIndex"] = rel.RelatedObjects.index(cost_item)
@classmethod
def _load_cost_values(cls, root_element, data):
# data["CostValues"] = []
@@ -100,6 +116,7 @@ class CostSchedulesData:
data["UnitBasisUnitSymbol"] = None
data["TotalAppliedValue"] = 0.0
data["TotalCost"] = 0.0
has_unit_basis = False
if root_element.is_a("IfcCostItem"):
values = root_element.CostValues
elif root_element.is_a("IfcConstructionResource"):
@@ -112,41 +129,63 @@ class CostSchedulesData:
cost_value_data = cls._cost_values[cost_value.id()]
data["UnitBasisValueComponent"] = cost_value_data["UnitBasis"]["ValueComponent"]
data["UnitBasisUnitSymbol"] = cost_value_data["UnitBasis"]["UnitSymbol"]
if data["UnitBasisValueComponent"]:
data["TotalCost"] = data["TotalCostQuantity"] / data["UnitBasisValueComponent"] * data["TotalAppliedValue"]
has_unit_basis = True
if has_unit_basis:
data["TotalCost"] = data["TotalAppliedValue"] / data["UnitBasisValueComponent"]
else:
data["TotalCost"] = data["TotalCostQuantity"] * data["TotalAppliedValue"]
if data["TotalCostQuantity"] is not None:
data["TotalCost"] = data["TotalAppliedValue"] * data["TotalCostQuantity"]
else:
data["TotalCost"] = data["TotalAppliedValue"]
data["TotalAppliedValue"] = None
@classmethod
def _load_cost_item_quantities(cls, cost_item, data):
parametric_quantities = []
for rel in cost_item.Controls:
for related_object in rel.RelatedObjects or []:
quantities = cls._get_object_quantities(cost_item, related_object)
# data["Controls"][related_object.id()] = quantities
parametric_quantities.extend(quantities)
# data["CostQuantities"] = []
# parametric_quantities = []
# for rel in cost_item.Controls:
# for related_object in rel.RelatedObjects or []:
# quantities = cls._get_object_quantities(cost_item, related_object)
# parametric_quantities.extend(quantities)
data["TotalCostQuantity"] = ifcopenshell.util.cost.get_total_quantity(cost_item)
for quantity in cost_item.CostQuantities or []:
if quantity.id() in parametric_quantities:
continue
# quantity_data = quantity.get_info()
# del quantity_data["Unit"]
# cls.physical_quantities[quantity.id()] = quantity_data
# data["CostQuantities"].append(quantity.id())
# data["Unit"] = None
data["UnitSymbol"] = "?"
data["UnitSymbol"] = "-"
if cost_item.CostQuantities:
quantity = cost_item.CostQuantities[0]
unit = ifcopenshell.util.unit.get_property_unit(quantity, tool.Ifc.get())
if unit:
# data["Unit"] = unit.id()
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit)
else:
# data["Unit"] = None
data["UnitSymbol"] = None
# same_unit_nested_cost_item = set()
# data["DerivedTotalCostQuantity"] = None
# if cost_item.IsNestedBy:
# data["TotalCostQuantity"] = 0.0
# derived_quantity = 0
# derived_unit = None
# should_sum = False
# for rel in cost_item.IsNestedBy:
# for related_object in rel.RelatedObjects or []:
# for quantity in related_object.CostQuantities or []:
# nested_unit = ifcopenshell.util.unit.get_property_unit(quantity, tool.Ifc.get())
# if derived_unit is None:
# derived_unit = nested_unit
# elif nested_unit and nested_unit.id() == derived_unit.id():
# same_unit_nested_cost_item.add(related_object)
# else:
# derived_unit = None
# break
# for cost in same_unit_nested_cost_item:
# qto = ifcopenshell.util.cost.get_total_quantity(cost)
# derived_quantity += qto
# print(derived_quantity)
# if derived_quantity not in [0, None]:
# data["DerivedTotalCostQuantity"] = derived_quantity
# if derived_unit:
# data["DerivedUnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(derived_unit)
# else:
# data["DerivedUnitSymbol"] = "?"
# print("Total Cost", data["DerivedTotalCostQuantity"], cost_item.Name)
@classmethod
def _get_object_quantities(cls, cost_item, element):
if not element.is_a("IfcObject"):
@@ -236,6 +275,7 @@ class CostSchedulesData:
break
return results
class CostItemRatesData:
data = {}
is_loaded = False
@@ -23,7 +23,6 @@ import time
import ifcopenshell.api
import blenderbim.bim.helper
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from bpy_extras.io_utils import ImportHelper
import blenderbim.tool as tool
import blenderbim.core.cost as core
@@ -36,7 +35,7 @@ class AddCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
bl_description = "Add a new cost schedule"
def _execute(self, context):
core.add_cost_schedule(tool.Ifc, predefined_type = context.scene.BIMCostProperties.cost_schedule_predefined_types)
core.add_cost_schedule(tool.Ifc, predefined_type=context.scene.BIMCostProperties.cost_schedule_predefined_types)
class EditCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
@@ -98,10 +97,9 @@ class AddSummaryCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_label = "Add Cost Item"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Add a summary cost item"
cost_schedule: bpy.props.IntProperty()
def _execute(self, context):
core.add_summary_cost_item(tool.Ifc, tool.Cost, cost_schedule=tool.Ifc.get().by_id(self.cost_schedule))
core.add_summary_cost_item(tool.Ifc, tool.Cost, cost_schedule=tool.Cost.get_active_cost_schedule())
class AddCostItem(bpy.types.Operator, tool.Ifc.Operator):
@@ -115,6 +113,16 @@ class AddCostItem(bpy.types.Operator, tool.Ifc.Operator):
core.add_cost_item(tool.Ifc, tool.Cost, cost_item=tool.Ifc.get().by_id(self.cost_item))
class CopyCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.copy_cost_item"
bl_label = "Copy Cost Item"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Copy a cost item"
def _execute(self, context):
core.copy_cost_item(tool.Ifc, tool.Cost)
class ExpandCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.expand_cost_item"
bl_label = "Expand Cost Item"
@@ -150,7 +158,7 @@ class ContractCostItem(bpy.types.Operator, tool.Ifc.Operator):
class RemoveCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.remove_cost_item"
bl_label = "Remove Cost item"
bl_label = "Remove Cost Item"
bl_options = {"REGISTER", "UNDO"}
cost_item: bpy.props.IntProperty()
@@ -215,8 +223,9 @@ class UnassignCostItemType(bpy.types.Operator, tool.Ifc.Operator):
core.unassign_cost_item_type(
tool.Ifc,
tool.Cost,
self.cost_item,
products=[tool.Ifc.get().by_id(self.related_object)] if self.related_object else [],
tool.Spatial,
cost_item=tool.Ifc.get().by_id(self.cost_item),
product_types=[tool.Ifc.get().by_id(self.related_object)] if self.related_object else [],
)
return {"FINISHED"}
@@ -456,9 +465,7 @@ class SelectCostItemProducts(bpy.types.Operator, tool.Ifc.Operator):
cost_item: bpy.props.IntProperty()
def _execute(self, context):
core.select_cost_item_products(
tool.Cost, tool.Spatial, cost_item=tool.Ifc.get().by_id(self.cost_item), include_nested=False
)
core.select_cost_item_products(tool.Cost, tool.Spatial, cost_item=tool.Ifc.get().by_id(self.cost_item))
return {"FINISHED"}
@@ -494,7 +501,7 @@ class AddCostColumn(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
name: bpy.props.StringProperty()
def _execute(self, context):
def execute(self, context):
core.add_cost_column(tool.Cost, self.name)
return {"FINISHED"}
@@ -520,6 +527,36 @@ class LoadCostItemQuantities(bpy.types.Operator):
return {"FINISHED"}
class LoadCostItemElementQuantities(bpy.types.Operator):
bl_idname = "bim.load_cost_item_element_quantities"
bl_label = "Load Cost Item Element Quantities"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
core.load_cost_item_element_quantities(tool.Cost)
return {"FINISHED"}
class LoadCostItemTaskQuantities(bpy.types.Operator):
bl_idname = "bim.load_cost_item_task_quantities"
bl_label = "Load Cost Item Task Quantities"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
core.load_cost_item_task_quantities(tool.Cost)
return {"FINISHED"}
class LoadCostItemResourceQuantities(bpy.types.Operator):
bl_idname = "bim.load_cost_item_resource_quantities"
bl_label = "Load Cost Item Resource Quantities"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
core.load_cost_item_resource_quantities(tool.Cost)
return {"FINISHED"}
class LoadCostItemTypes(bpy.types.Operator):
bl_idname = "bim.load_cost_item_types"
bl_label = "Load Cost Item Types"
@@ -592,16 +629,125 @@ class ExportCostSchedules(bpy.types.Operator):
bl_label = "Export Cost Schedule"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Export a cost schedule to a CSV, XSLX OR ODS file"
cost_schedule: bpy.props.IntProperty()
format: bpy.props.EnumProperty("Format", items=(("CSV", "CSV", ""), ("XLSX", "XLSX", ""), ("ODS", "ODS", "")))
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
core.export_cost_schedules(tool.Cost, format=self.format)
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
r = core.export_cost_schedules(tool.Cost, filepath=self.filepath, format=self.format, cost_schedule=cost_schedule)
if isinstance(r, str):
self.report({"ERROR"}, r)
return {"FINISHED"}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
wm.fileselect_add(self)
return {"RUNNING_MODAL"}
def draw(self, context):
self.layout.label(text="Choose a format")
self.layout.prop(self, "format")
class ClearCostItemAssignments(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.clear_cost_item_assignments"
bl_label = "Clear Cost Item Product Assignments"
bl_options = {"REGISTER", "UNDO"}
cost_item: bpy.props.IntProperty()
related_object_type: bpy.props.StringProperty()
def _execute(self, context):
core.clear_cost_item_assignments(
tool.Ifc,
tool.Cost,
cost_item=tool.Ifc.get().by_id(self.cost_item),
related_object_type=self.related_object_type,
)
return {"FINISHED"}
class LoadProductCostItems(bpy.types.Operator):
bl_idname = "bim.load_product_cost_items"
bl_label = "Get Product Cost Assignments"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if not tool.Ifc.get():
return False
if not context.active_object:
return False
if not context.active_object.BIMObjectProperties.ifc_definition_id:
return False
return True
def execute(self, context):
core.load_product_cost_items(
tool.Cost, product=tool.Ifc.get().by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
)
return {"FINISHED"}
class HighlightProductCostItem(bpy.types.Operator):
bl_idname = "bim.highlight_product_cost_item"
bl_label = "Highlight Product Cost Items"
bl_options = {"REGISTER", "UNDO"}
cost_item: bpy.props.IntProperty()
def execute(self, context):
r = core.highlight_product_cost_item(tool.Spatial, tool.Cost, cost_item=tool.Ifc.get().by_id(self.cost_item))
if isinstance(r, str):
self.report({"WARNING"}, r)
return {"FINISHED"}
class ReorderCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.reorder_cost_item_nesting"
bl_label = "Reorder Nesting"
bl_options = {"REGISTER", "UNDO"}
new_index: bpy.props.IntProperty()
cost_item: bpy.props.IntProperty()
def _execute(self, context):
ifcopenshell.api.run(
"nest.reorder_nesting",
tool.Ifc.get(),
**{
"item": tool.Ifc.get().by_id(self.cost_item),
"new_index": self.new_index,
},
)
tool.Cost.load_cost_schedule_tree()
class SelectUnassignedProducts(bpy.types.Operator):
bl_idname = "bim.select_unassigned_products"
bl_label = "Select Unassigned Products"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
core.select_unassigned_products(tool.Ifc, tool.Cost, tool.Spatial)
return {"FINISHED"}
class ChangeParentCostItem(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.change_parent_cost_item"
bl_label = "Change Parent Cost Item"
bl_options = {"REGISTER", "UNDO"}
new_parent: bpy.props.IntProperty()
def _execute(self, context):
r = core.change_parent_cost_item(tool.Ifc, tool.Cost, new_parent=tool.Ifc.get().by_id(self.new_parent))
if isinstance(r, str):
self.report({"WARNING"}, r)
return {"FINISHED"}
class AddCurrency(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.add_currency"
bl_label = "Add Currency"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
core.add_currency(tool.Ifc, tool.Cost)
@@ -75,7 +75,7 @@ def update_active_cost_item_index(self, context):
if schedule.PredefinedType == "SCHEDULEOFRATES":
tool.Cost.load_cost_item_types()
else:
tool.Cost.load_cost_item_quantities(cost_item=tool.Cost.get_highlighted_cost_item())
tool.Cost.load_cost_item_quantities()
CostClassificationsData.load()
@@ -115,6 +115,27 @@ def get_schedule_predefined_types(self, context):
return CostSchedulesData.data["predefined_types"]
def get_currencies(self, context):
return [
("USD", "USD", "Dollar"),
("EUR", "EUR", "Euro"),
("GBP", "GBP", "Pound"),
("AUD", "AUD", "Australian Dollar"),
("CAD", "CAD", "Canadian Dollar"),
("CHF", "CHF", "Swiss Franc"),
("CNY", "CNY", "Chinese Yuan"),
("HKD", "HKD", "Hong Kong Dollar"),
("JPY", "JPY", "Japanese Yen"),
("NZD", "NZD", "New Zealand Dollar"),
("SEK", "SEK", "Swedish Krona"),
("KRW", "KRW", "South Korean Won"),
("SGD", "SGD", "Singapore Dollar"),
("NOK", "NOK", "Norwegian Krone"),
("MAD", "MAD", "Moroccan Dirham"),
("CUSTOM", "Custom currency", "Custom"),
]
class CostItem(PropertyGroup):
name: StringProperty(name="Name", update=update_cost_item_name)
identification: StringProperty(name="Identification", update=update_cost_item_identification)
@@ -128,6 +149,8 @@ class CostItemQuantity(PropertyGroup):
name: StringProperty(name="Name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
total_quantity: FloatProperty(name="Total Quantity")
unit_symbol: StringProperty(name="Unit Symbol")
total_cost_quantity: FloatProperty(name="Total Quantity")
class CostItemType(PropertyGroup):
@@ -135,6 +158,23 @@ class CostItemType(PropertyGroup):
ifc_definition_id: IntProperty(name="IFC Definition ID")
def update_cost_item_parent(self, context):
cost_item = tool.Cost.get_highlighted_cost_item()
tool.Cost.toggle_cost_item_parent_change(cost_item=cost_item)
def update_active_cost_item_elements(self, context):
bpy.ops.bim.load_cost_item_element_quantities()
def update_active_cost_item_tasks(self, context):
bpy.ops.bim.load_cost_item_task_quantities()
def update_active_cost_item_resources(self, context):
bpy.ops.bim.load_cost_item_resource_quantities()
class BIMCostProperties(PropertyGroup):
cost_schedule_predefined_types: EnumProperty(
items=get_schedule_predefined_types, name="Predefined Type", default=None
@@ -164,12 +204,14 @@ class BIMCostProperties(PropertyGroup):
name="Cost Types",
)
cost_category: StringProperty(name="Cost Category")
fixed_cost_value: FloatProperty(name="Fixed Cost Value")
active_cost_value_id: IntProperty(name="Active Cost Item Value Id")
cost_value_editing_type: StringProperty(name="Cost Value Editing Type")
cost_value_attributes: CollectionProperty(name="Cost Value Attributes", type=Attribute)
cost_value_formula: StringProperty(name="Cost Value Formula")
cost_column: StringProperty(name="Cost Column")
should_show_column_ui: BoolProperty(name="Should Show Column UI", default=False)
should_show_currency_ui: BoolProperty(name="Should Show Currency UI", default=False)
columns: CollectionProperty(name="Columns", type=StrProperty)
active_column_index: IntProperty(name="Active Column Index")
cost_item_products: CollectionProperty(name="Cost Item Products", type=CostItemQuantity)
@@ -186,3 +228,17 @@ class BIMCostProperties(PropertyGroup):
cost_item_rates: CollectionProperty(name="Cost Item Rates", type=CostItem)
active_cost_item_rate_index: IntProperty(name="Active Cost Rate Index")
contracted_cost_item_rates: StringProperty(name="Contracted Cost Item Rates", default="[]")
product_cost_items: CollectionProperty(name="Product Cost Items", type=CostItemQuantity)
active_product_cost_item_index: IntProperty(name="Active Product Cost Item Index")
enable_reorder: BoolProperty(name="Enable Reorder", default=False)
show_nested_elements: BoolProperty(name="Show Nested Tasks", default=False, update=update_active_cost_item_elements)
show_nested_tasks: BoolProperty(name="Show Nested Tasks", default=False, update=update_active_cost_item_tasks)
show_nested_resources: BoolProperty(
name="Show Nested Tasks", default=False, update=update_active_cost_item_resources
)
change_cost_item_parent: BoolProperty(name="Change Cost Item Parent", default=False, update=update_cost_item_parent)
show_cost_item_operators: BoolProperty(name="Show Cost Item Operators", default=False)
currency: EnumProperty(items=get_currencies, name="Currencies")
custom_currency: StringProperty(
name="Custom Currency", default="USD", description="Custom Currency in ISO 4217 format"
)
+205 -50
View File
@@ -43,47 +43,68 @@ class BIM_PT_cost_schedules(Panel):
self.props = context.scene.BIMCostProperties
row = self.layout.row()
if CostSchedulesData.data["total_cost_schedules"]:
row.label(text=f"{CostSchedulesData.data['total_cost_schedules']} Cost Schedules Found", icon="TEXT")
row.operator("bim.export_cost_schedules", text="Export as spreadsheet", icon="EXPORT")
else:
row.label(text="No Cost Schedules Found found.", icon="COMMUNITY")
row = self.layout.row()
row.prop(self.props, "cost_schedule_predefined_types")
row.operator("bim.add_cost_schedule", icon="ADD", text="Add new")
if not self.props.active_cost_schedule_id:
if CostSchedulesData.data["total_cost_schedules"]:
row.label(text=f"{CostSchedulesData.data['total_cost_schedules']} Cost Schedules Found", icon="TEXT")
row.operator("bim.export_cost_schedules", text="Export as spreadsheet", icon="EXPORT")
else:
row.label(text="No Cost Schedules Found found.", icon="COMMUNITY")
row = self.layout.row()
row.prop(self.props, "cost_schedule_predefined_types")
row.operator("bim.add_cost_schedule", icon="ADD", text="Add")
for schedule in CostSchedulesData.data["schedules"]:
self.draw_cost_schedule_ui(schedule)
def draw_cost_schedule_ui(self, cost_schedule):
row = self.layout.row(align=True)
row.label(text=cost_schedule["name"], icon="LINENUMBERS_ON")
if self.props.active_cost_schedule_id and self.props.active_cost_schedule_id == cost_schedule["id"]:
op = row.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="")
row.label(
text="Currently editing: {}[{}]".format(cost_schedule["name"], cost_schedule["predefined_type"]),
icon="LINENUMBERS_ON",
)
grid = self.layout.grid_flow(columns=2, even_columns=True)
col = grid.column()
row1 = col.row(align=True)
row1.alignment = "LEFT"
row1.label(text="Schedule tools")
row1 = col.row(align=True)
row1.alignment = "RIGHT"
row1.operator("bim.export_cost_schedules", text="Export", icon="EXPORT").cost_schedule = cost_schedule["id"]
row2 = col.row(align=True)
row2.alignment = "RIGHT"
op = row2.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="Assigned")
op.cost_schedule = cost_schedule["id"]
row.prop(self.props, "should_show_column_ui", text="", icon="SHORTDISPLAY")
row2.operator("bim.select_unassigned_products", icon="RESTRICT_SELECT_OFF", text="Unassigned")
col = grid.column()
row1 = col.row(align=True)
row1.alignment = "LEFT"
row1.label(text="Settings")
row1 = col.row(align=True)
row1.alignment = "RIGHT"
row1.prop(self.props, "should_show_currency_ui", text="Project Currency", icon="COPY_ID")
row1.prop(self.props, "should_show_column_ui", text="Schedule Columns", icon="SHORTDISPLAY")
if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES":
row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK")
elif self.props.is_editing == "COST_ITEMS":
row.operator("bim.add_summary_cost_item", text="", icon="ADD").cost_schedule = cost_schedule["id"]
row.operator("bim.disable_editing_cost_schedule", text="", icon="CANCEL")
elif self.props.active_cost_schedule_id:
row.operator("bim.remove_cost_schedule", text="", icon="X").cost_schedule = cost_schedule["id"]
row.operator("bim.disable_editing_cost_schedule", text="Disable Editing", icon="CANCEL")
else:
row.label(
text="{}[{}]".format(cost_schedule["name"], cost_schedule["predefined_type"]), icon="LINENUMBERS_ON"
)
row.operator("bim.enable_editing_cost_items", text="", icon="OUTLINER").cost_schedule = cost_schedule["id"]
row.operator(
"bim.enable_editing_cost_schedule_attributes", text="", icon="GREASEPENCIL"
).cost_schedule = cost_schedule["id"]
row.operator("bim.remove_cost_schedule", text="", icon="X").cost_schedule = cost_schedule["id"]
if self.props.active_cost_schedule_id == cost_schedule["id"]:
if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES":
self.draw_editable_cost_schedule_ui()
elif self.props.is_editing == "COST_ITEMS":
if self.props.should_show_column_ui:
self.draw_column_ui()
if self.props.should_show_currency_ui:
self.draw_currency_ui()
self.draw_editable_cost_item_ui()
def draw_column_ui(self):
@@ -92,6 +113,20 @@ class BIM_PT_cost_schedules(Panel):
row.operator("bim.add_cost_column", text="", icon="ADD").name = self.props.cost_column
self.layout.template_list("BIM_UL_cost_columns", "", self.props, "columns", self.props, "active_column_index")
def draw_currency_ui(self):
row = self.layout.row(align=True)
if CostSchedulesData.data["currency"]:
text = "Currency used: {}".format(CostSchedulesData.data["currency"]["name"])
row.label(text=text)
row.operator("bim.remove_unit", text="", icon="X").unit = CostSchedulesData.data["currency"]["id"]
else:
row.label(text="No currency set")
row.prop(self.props, "currency", text="")
if self.props.currency == "CUSTOM":
row.alignment = "RIGHT"
row.prop(self.props, "custom_currency", text="")
row.operator("bim.add_currency", text="", icon="ADD")
def draw_editable_cost_schedule_ui(self):
blenderbim.bim.helper.draw_attributes(self.props.cost_schedule_attributes, self.layout)
@@ -99,29 +134,39 @@ class BIM_PT_cost_schedules(Panel):
row = self.layout.row(align=True)
row.alignment = "RIGHT"
ifc_definition_id = None
row = self.layout.row(align=True)
row.label(text="Cost Item Tools")
row = self.layout.row(align=True)
row.alignment = "RIGHT"
row.operator("bim.add_summary_cost_item", text="Add Summary Cost", icon="ADD")
row.operator("bim.expand_all_tasks", text="Expand All")
row.operator("bim.contract_all_tasks", text="Contract All")
row = self.layout.row(align=True)
row.alignment = "RIGHT"
if self.props.cost_items and self.props.active_cost_item_index < len(self.props.cost_items):
ifc_definition_id = self.props.cost_items[self.props.active_cost_item_index].ifc_definition_id
if ifc_definition_id:
if not CostSchedulesData.data["is_editing_rates"]:
op = row.operator("bim.enable_editing_cost_item_quantities", text="", icon="PROPERTIES")
row.prop(self.props, "show_cost_item_operators", text="Edit", icon="DOWNARROW_HLT")
row.operator("bim.add_cost_item", text="Add", icon="ADD").cost_item = ifc_definition_id
row.operator("bim.copy_cost_item", text="Copy", icon="ADD")
row.operator("bim.remove_cost_item", text="Delete", icon="X").cost_item = ifc_definition_id
if self.props.show_cost_item_operators:
row = self.layout.row(align=True)
row.alignment = "RIGHT"
row.prop(self.props, "change_cost_item_parent", text="", icon="LINKED")
row.prop(self.props, "enable_reorder", text="", icon="SORTALPHA")
if not CostSchedulesData.data["is_editing_rates"]:
op = row.operator("bim.enable_editing_cost_item_quantities", text="", icon="PROPERTIES")
op.cost_item = ifc_definition_id
op = row.operator("bim.enable_editing_cost_item_values", text="", icon="DISC")
op.cost_item = ifc_definition_id
op = row.operator("bim.enable_editing_cost_item_values", text="", icon="DISC")
op.cost_item = ifc_definition_id
row.operator("bim.add_cost_item", text="", icon="ADD").cost_item = ifc_definition_id
if self.props.active_cost_item_id == ifc_definition_id:
if self.props.cost_item_editing_type == "ATTRIBUTES":
row.operator("bim.edit_cost_item", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_cost_item", text="", icon="CANCEL")
else:
op = row.operator("bim.enable_editing_cost_item_attributes", text="", icon="GREASEPENCIL")
op.cost_item = ifc_definition_id
row.operator("bim.remove_cost_item", text="", icon="X").cost_item = ifc_definition_id
if self.props.active_cost_item_id == ifc_definition_id:
if self.props.cost_item_editing_type == "ATTRIBUTES":
row.operator("bim.edit_cost_item", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_cost_item", text="", icon="CANCEL")
else:
op = row.operator("bim.enable_editing_cost_item_attributes", text="", icon="GREASEPENCIL")
op.cost_item = ifc_definition_id
self.layout.template_list(
"BIM_UL_cost_items",
"",
@@ -173,6 +218,8 @@ class BIM_PT_cost_schedules(Panel):
def draw_editable_cost_item_values_ui(self):
row = self.layout.row(align=True)
row.prop(self.props, "cost_types", text="")
if self.props.cost_types == "FIXED":
row.prop(self.props, "fixed_cost_value", text="")
if self.props.cost_types == "CATEGORY":
row.prop(self.props, "cost_category", text="")
op = row.operator("bim.add_cost_value", text="Add Value", icon="ADD")
@@ -341,7 +388,8 @@ class BIM_PT_cost_item_quantities(Panel):
has_quantity_names = CostProp.get_product_quantity_names(self, context)
row2 = col.row(align=True)
row2.label(text="Elements")
total_cost_item_products = len(self.props.cost_item_products)
row2.label(text="Elements ({})".format(total_cost_item_products))
op = row2.operator("bim.select_cost_item_products", icon="RESTRICT_SELECT_OFF", text="")
op.cost_item = cost_item.ifc_definition_id
@@ -361,6 +409,8 @@ class BIM_PT_cost_item_quantities(Panel):
op.cost_item = cost_item.ifc_definition_id
op.related_object = 0
row2 = col.row()
row2.prop(self.props, "show_nested_elements", text="Show nested")
row2 = col.row()
row2.template_list(
"BIM_UL_cost_item_quantities",
@@ -371,6 +421,11 @@ class BIM_PT_cost_item_quantities(Panel):
"active_cost_item_product_index",
)
row2 = col.row()
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
op.cost_item = cost_item.ifc_definition_id
op.related_object_type = "PRODUCT"
if has_quantity_names:
row2 = col.row()
row2.prop(self.props, "product_quantity_names", text="")
@@ -381,7 +436,8 @@ class BIM_PT_cost_item_quantities(Panel):
has_quantity_names = CostProp.get_process_quantity_names(self, context)
row2 = col.row(align=True)
row2.label(text="Tasks")
total_cost_item_processes = len(self.props.cost_item_processes)
row2.label(text="Tasks ({})".format(total_cost_item_processes))
tprops = context.scene.BIMTaskTreeProperties
wprops = context.scene.BIMWorkScheduleProperties
@@ -397,6 +453,9 @@ class BIM_PT_cost_item_quantities(Panel):
op.cost_item = cost_item.ifc_definition_id
op.prop_name = ""
row2 = col.row()
row2.prop(self.props, "show_nested_tasks", text="Show nested")
row2 = col.row()
row2.template_list(
"BIM_UL_cost_item_quantities",
@@ -407,6 +466,11 @@ class BIM_PT_cost_item_quantities(Panel):
"active_cost_item_process_index",
)
row2 = col.row()
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
op.cost_item = cost_item.ifc_definition_id
op.related_object_type = "PROCESS"
if has_quantity_names:
row2 = col.row()
row2.prop(self.props, "process_quantity_names", text="")
@@ -417,7 +481,8 @@ class BIM_PT_cost_item_quantities(Panel):
has_quantity_names = CostProp.get_resource_quantity_names(self, context)
row2 = col.row(align=True)
row2.label(text="Resources")
total_cost_item_resources = len(self.props.cost_item_resources)
row2.label(text="Resources ({})".format(total_cost_item_resources))
op = row2.operator("bim.calculate_cost_item_resource_value", text="", icon="DISC")
op.cost_item = cost_item.ifc_definition_id
@@ -436,6 +501,9 @@ class BIM_PT_cost_item_quantities(Panel):
op.cost_item = cost_item.ifc_definition_id
op.prop_name = ""
row2 = col.row()
row2.prop(self.props, "show_nested_resources", text="Show nested")
row2 = col.row()
row2.template_list(
"BIM_UL_cost_item_quantities",
@@ -446,6 +514,11 @@ class BIM_PT_cost_item_quantities(Panel):
"active_cost_item_resource_index",
)
row2 = col.row()
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
op.cost_item = cost_item.ifc_definition_id
op.related_object_type = "RESOURCE"
if has_quantity_names:
row2 = col.row()
row2.prop(self.props, "resource_quantity_names", text="")
@@ -518,8 +591,23 @@ class BIM_UL_cost_items_trait:
split2.label(text=str(cost_item["CategoryValues"].get(column.name, "-")))
self.draw_total_cost_column(split2, cost_item)
if self.props.enable_reorder:
self.draw_order_operator(row, item.ifc_definition_id, cost_item)
if self.props.change_cost_item_parent:
self.draw_parent_operator(row, item.ifc_definition_id)
# TODO: reimplement "bim.copy_cost_item_values" somewhere with better UX
def draw_parent_operator(self, row, cost_item_id):
if self.props.active_cost_item_id:
if self.props.active_cost_item_id != cost_item_id:
op = row.operator(
"bim.change_parent_cost_item", text="", icon="LINKED", emboss=False
).new_parent = cost_item_id
else:
row.label(text="", icon="BLANK1")
def draw_hierarchy(self, row, item):
for i in range(0, item.level_index):
row.label(text="", icon="BLANK1")
@@ -533,7 +621,10 @@ class BIM_UL_cost_items_trait:
row.label(text="", icon="DOT")
def draw_total_cost_column(self, layout, cost_item):
layout.label(text="{0:.2f}".format(cost_item["TotalCost"]))
format_numbers = "{0:,.2f}".format(cost_item["TotalCost"]).replace(",", " ")
currency = CostSchedulesData.data["currency"]
text = "{} {}".format(format_numbers, currency["name"]) if currency else format_numbers
layout.label(text=text)
def draw_quantity_column(self, layout, cost_item):
if CostSchedulesData.data["is_editing_rates"]:
@@ -542,16 +633,43 @@ class BIM_UL_cost_items_trait:
self.draw_total_quantity_column(layout, cost_item)
def draw_value_column(self, layout, cost_item):
text = "{0:.2f}".format(cost_item["TotalAppliedValue"])
if cost_item["UnitBasisValueComponent"] not in [None, 1]:
text += " / {}".format(round(cost_item["UnitBasisValueComponent"], 2))
layout.label(text=text)
if cost_item["TotalAppliedValue"]:
text = "{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ")
if cost_item["UnitBasisValueComponent"] not in [None, 1]:
text = "{} / {}".format(text, round(cost_item["UnitBasisValueComponent"], 2))
currency = CostSchedulesData.data["currency"]
text = "{} {}".format(text, currency["name"]) if currency else text
layout.label(text=text)
else:
layout.label(text="-")
def draw_uom_column(self, layout, cost_item):
layout.label(text=cost_item["UnitBasisUnitSymbol"] or "?" if cost_item["UnitBasisValueComponent"] else "-")
layout.label(text=cost_item["UnitBasisUnitSymbol"] or "-" if cost_item["UnitBasisValueComponent"] else "-")
def draw_order_operator(self, row, ifc_definition_id, cost_item):
if cost_item["NestingIndex"] is not None:
if cost_item["NestingIndex"] == 0:
op = row.operator("bim.reorder_cost_item_nesting", icon="TRIA_DOWN", text="")
op.cost_item = ifc_definition_id
op.new_index = cost_item["NestingIndex"] + 1
elif cost_item["NestingIndex"] > 0:
op = row.operator("bim.reorder_cost_item_nesting", icon="TRIA_UP", text="")
op.cost_item = ifc_definition_id
op.new_index = cost_item["NestingIndex"] - 1
def draw_total_quantity_column(self, layout, cost_item):
layout.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '?'}")
if cost_item["TotalCostQuantity"]:
label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}"
layout.label(text=label)
else:
layout.label(text="-")
# if cost_item["DerivedTotalCostQuantity"] not in [None, 0]:
# layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}")
# else:
# if cost_item["TotalCostQuantity"] == 0:
# layout.label(text="-")
# else:
# layout.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}")
class BIM_UL_cost_items(BIM_UL_cost_items_trait, UIList):
@@ -601,12 +719,49 @@ class BIM_UL_cost_item_quantities(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.BIMCostProperties
cost_item = props.cost_items[props.active_cost_item_index]
if item:
row = layout.row(align=True)
op = row.operator("bim.select_product", text="", icon="RESTRICT_SELECT_OFF")
op.product = item.ifc_definition_id
row.split(factor=0.8)
row.label(text=item.name)
row.label(text="{0:.2f}".format(item.total_quantity))
formatted_quantity = "{0:.2f}".format(item.total_quantity)
row.label(text="{}{}".format(formatted_quantity, item.unit_symbol))
op = row.operator("bim.unassign_cost_item_quantity", text="", icon="X")
op.cost_item = cost_item.ifc_definition_id
op.related_object = item.ifc_definition_id
class BIM_UL_product_cost_items(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
op = row.operator("bim.highlight_product_cost_item", text="", icon="STYLUS_PRESSURE")
op.cost_item = item.ifc_definition_id
row.split(factor=0.5)
row.label(text=item.name)
qty = "{0:.2f}".format(item.total_quantity)
formatted_total_quantity = "{0:.2f}".format(item.total_cost_quantity)
row.label(text="{}/{} {}".format(qty, formatted_total_quantity, item.unit_symbol))
class BIM_PT_Costing_Tools(Panel):
bl_label = "5D Tools"
bl_idname = "BIM_PT_Costing_Tools"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "4D/5D Toolkit"
def draw(self, context):
self.props = context.scene.BIMCostProperties
row = self.layout.row()
row.operator("bim.load_product_cost_items", icon="FILE_REFRESH")
row = self.layout.row()
row.template_list(
"BIM_UL_product_cost_items",
"",
self.props,
"product_cost_items",
self.props,
"active_product_cost_item_index",
)
@@ -31,6 +31,7 @@ from blenderbim.bim.handler import purge_module_data
class AddCsvAttribute(bpy.types.Operator):
bl_idname = "bim.add_csv_attribute"
bl_label = "Add CSV Attribute"
bl_description = "Add a new IFC Attribute to the CSV export"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -52,6 +53,7 @@ class RemoveCsvAttribute(bpy.types.Operator):
class RemoveAllCsvAttributes(bpy.types.Operator):
bl_idname = "bim.remove_all_csv_attributes"
bl_label = "Remove all CSV Attributes"
bl_description = "Remove all IFC Attributes from the CSV export"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
@@ -61,20 +63,25 @@ class RemoveAllCsvAttributes(bpy.types.Operator):
class ImportCsvAttributes(bpy.types.Operator):
bl_idname = "bim.import_csv_attributes"
bl_label = "Import CSV Attributes"
bl_label = "Import CSV Template"
bl_description = "Import a json template for CSV export"
bl_options = {"REGISTER", "UNDO"}
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
csv_attributes = context.scene.CsvProperties.csv_attributes
csv_attributes.clear()
csv_props = context.scene.CsvProperties
csv_json = json.load(open(self.filepath))
i = 0
for attribute in csv_json:
csv_attributes.add()
csv_attributes[i].name = attribute
i += 1
expression = csv_json.get("expression", "")
if expression:
csv_props.ifc_selector = expression
attributes = csv_json.get("attributes", [])
if attributes:
csv_props.csv_attributes.clear()
for attribute in attributes:
csv_props.csv_attributes.add().name = attribute
return {"FINISHED"}
@@ -85,19 +92,30 @@ class ImportCsvAttributes(bpy.types.Operator):
class ExportCsvAttributes(bpy.types.Operator):
bl_idname = "bim.export_csv_attributes"
bl_label = "Export CSV Attributes"
bl_label = "Export CSV Template"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Save a json template for CSV export"
filename_ext = ".json"
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
csv_attributes = []
with open(self.filepath, "w") as outfile:
for attribute in context.scene.CsvProperties.csv_attributes:
csv_attributes.append(attribute.name)
csv_props = context.scene.CsvProperties
json.dump(csv_attributes, outfile)
csv_template = {}
expression = csv_props.ifc_selector
if expression:
csv_template["expression"] = expression
csv_attributes = []
for attribute in csv_props.csv_attributes:
attribute_name = attribute.name
csv_attributes.append(attribute_name)
if csv_attributes:
csv_template["attributes"] = csv_attributes
with open(self.filepath, "w") as outfile:
json.dump(csv_template, outfile)
return {"FINISHED"}
@@ -132,14 +150,9 @@ class ExportIfcCsv(bpy.types.Operator):
selector = ifcopenshell.util.selector.Selector()
results = selector.parse(ifc_file, props.ifc_selector)
ifc_csv = ifccsv.IfcCsv()
ifc_csv.output = self.filepath
ifc_csv.attributes = [a.name for a in props.csv_attributes]
ifc_csv.selector = selector
if props.csv_delimiter == "CUSTOM":
ifc_csv.delimiter = props.csv_custom_delimiter
else:
ifc_csv.delimiter = props.csv_delimiter
ifc_csv.export(ifc_file, results)
attributes = [a.name for a in props.csv_attributes]
sep = props.csv_custom_delimiter if props.csv_delimiter == "CUSTOM" else props.csv_delimiter
ifc_csv.export(ifc_file, results, attributes, output=self.filepath, format=args.format, delimiter=sep)
return {"FINISHED"}
@@ -164,12 +177,8 @@ class ImportIfcCsv(bpy.types.Operator):
else:
ifc_file = ifcopenshell.open(props.csv_ifc_file)
ifc_csv = ifccsv.IfcCsv()
ifc_csv.output = self.filepath
if props.csv_delimiter == "CUSTOM":
ifc_csv.delimiter = props.csv_custom_delimiter
else:
ifc_csv.delimiter = props.csv_delimiter
ifc_csv.Import(ifc_file)
sep = props.csv_custom_delimiter if props.csv_delimiter == "CUSTOM" else props.csv_delimiter
ifc_csv.Import(ifc_file, self.filepath, delimiter=sep)
if not props.should_load_from_memory:
ifc_file.write(props.csv_ifc_file)
purge_module_data()
+7 -16
View File
@@ -49,27 +49,18 @@ class BIM_PT_ifccsv(Panel):
row.operator("bim.eyedrop_ifccsv", icon="EYEDROPPER", text="")
layout.separator()
row = layout.row()
split = row.split(factor=0.7)
c = split.column()
c.operator("bim.add_csv_attribute")
c = split.column()
c.operator("bim.import_csv_attributes", icon="IMPORT", text="Load Template")
row = layout.row(align=True)
row.operator("bim.add_csv_attribute", icon="ADD")
row.operator("bim.remove_all_csv_attributes", icon="CANCEL")
row = layout.row(align=True)
row.operator("bim.import_csv_attributes", icon="IMPORT")
row.operator("bim.export_csv_attributes", icon="EXPORT")
for index, attribute in enumerate(props.csv_attributes):
row = layout.row(align=True)
row.prop(attribute, "name", text="")
row.operator("bim.remove_csv_attribute", icon="X", text="").index = index
if props.csv_attributes:
row = layout.row()
row.label()
row.operator("bim.remove_all_csv_attributes", icon="CANCEL", text="")
row = layout.row()
row.operator("bim.export_csv_attributes", icon="EXPORT", text="Create Template")
layout.separator()
row = layout.row(align=True)
row.prop(props, "csv_delimiter")
@@ -78,7 +69,7 @@ class BIM_PT_ifccsv(Panel):
row.prop(props, "csv_custom_delimiter")
row = layout.row()
split = row.split(factor=0.7)
split = row.split(factor=0.5)
c = split.column()
c.operator("bim.export_ifccsv", icon="EXPORT")
c = split.column()
@@ -82,6 +82,7 @@ class BIM_PT_object_documents(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_misc_object"
@classmethod
@@ -17,11 +17,12 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
from . import ui, prop, operator, handler, gizmos
from . import ui, prop, operator, handler, gizmos, workspace
classes = (
operator.ActivateDrawing,
operator.ActivateDrawingStyle,
operator.ActivateView,
operator.ActivateModel,
operator.AddAnnotation,
operator.AddDrawing,
operator.AddDrawingStyle,
@@ -29,12 +30,12 @@ classes = (
operator.AddDrawingToSheet,
operator.AddSchedule,
operator.AddScheduleToSheet,
operator.AddSectionsAnnotations,
operator.AddReferenceToSheet,
operator.AddSheet,
operator.AddTextLiteral,
operator.BuildSchedule,
operator.CleanWireframes,
operator.ContractSheet,
operator.CopyGrid,
operator.CreateDrawing,
operator.CreateSheets,
operator.DisableEditingAssignedProduct,
@@ -44,42 +45,55 @@ classes = (
operator.DisableEditingText,
operator.DuplicateDrawing,
operator.EditAssignedProduct,
operator.EditSheet,
operator.EditText,
operator.EditVectorStyle,
operator.EditTextPopup,
operator.EnableEditingAssignedProduct,
operator.EnableEditingText,
operator.ExpandSheet,
operator.LoadDrawings,
operator.LoadSchedules,
operator.LoadSheets,
operator.OpenDrawing,
operator.OpenSchedule,
operator.OpenSheet,
operator.OpenView,
operator.RemoveDrawing,
operator.RemoveDrawingFromSheet,
operator.RemoveDrawingStyle,
operator.RemoveDrawingStyleAttribute,
operator.RemoveSchedule,
operator.ReloadDrawingStyles,
operator.RemoveSheet,
operator.RemoveTextLiteral,
operator.SelectAllDrawings,
operator.ResizeText,
operator.SaveDrawingStyle,
operator.SelectDocIfcFile,
operator.SaveDrawingStylesData,
operator.SelectAssignedProduct,
operator.SelectDocIfcFile,
operator.LoadReferences,
operator.DisableEditingReferences,
operator.AddReference,
operator.RemoveReference,
operator.OpenReference,
prop.Variable,
prop.Drawing,
prop.Schedule,
prop.Document,
prop.DrawingStyle,
prop.Sheet,
prop.DocProperties,
prop.BIMCameraProperties,
prop.Literal,
prop.BIMTextProperties,
prop.BIMAssignedProductProperties,
prop.BIMAnnotationProperties,
ui.BIM_PT_camera,
ui.BIM_PT_drawing_underlay,
ui.BIM_PT_annotation_utilities,
ui.BIM_PT_sheets,
ui.BIM_PT_drawings,
ui.BIM_PT_schedules,
ui.BIM_PT_references,
ui.BIM_PT_product_assignments,
ui.BIM_PT_text,
ui.BIM_UL_drawinglist,
@@ -89,11 +103,15 @@ classes = (
gizmos.DimensionLabelGizmo,
gizmos.ExtrusionGuidesGizmo,
gizmos.ExtrusionWidget,
workspace.Hotkey,
)
def register():
if not bpy.app.background:
bpy.utils.register_tool(workspace.AnnotationTool, after={"bim.bim_tool"}, separator=False, group=True)
bpy.types.Scene.DocProperties = bpy.props.PointerProperty(type=prop.DocProperties)
bpy.types.Scene.BIMAnnotationProperties = bpy.props.PointerProperty(type=prop.BIMAnnotationProperties)
bpy.types.Camera.BIMCameraProperties = bpy.props.PointerProperty(type=prop.BIMCameraProperties)
bpy.types.Object.BIMAssignedProductProperties = bpy.props.PointerProperty(type=prop.BIMAssignedProductProperties)
bpy.types.Object.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties)
@@ -103,7 +121,10 @@ def register():
def unregister():
if not bpy.app.background:
bpy.utils.unregister_tool(workspace.AnnotationTool)
del bpy.types.Scene.DocProperties
del bpy.types.Scene.BIMAnnotationProperties
del bpy.types.Camera.BIMCameraProperties
del bpy.types.Object.BIMAssignedProductProperties
del bpy.types.Object.BIMTextProperties
@@ -20,6 +20,7 @@ import bpy
import os
import blenderbim.tool as tool
from mathutils import Vector
import bmesh
class Annotator:
@@ -32,7 +33,7 @@ class Annotator:
if related_element is None:
location, _, _, _ = Annotator.get_placeholder_coords(bpy.context)
else:
obj.data.BIMTextProperties.related_element = related_element
obj.data.BIMAssignedProductProperties.related_element = related_element
location = related_element.location
obj.location = location
obj.hide_render = True
@@ -44,7 +45,7 @@ class Annotator:
font.name = "OpenGost Type B TT"
obj.data.font = font
obj.data.BIMTextProperties.font_size = "2.5"
collection = bpy.context.scene.camera.users_collection[0]
collection = bpy.context.scene.camera.BIMObjectProperties.collection
collection.objects.link(obj)
Annotator.resize_text(obj)
return obj
@@ -52,9 +53,10 @@ class Annotator:
@staticmethod
def resize_text(text_obj):
camera = None
for obj in text_obj.users_collection[0].objects:
if isinstance(obj.data, bpy.types.Camera):
camera = obj
group = tool.Drawing.get_drawing_group(tool.Ifc.get_entity(text_obj))
for element in tool.Drawing.get_drawing_elements(group):
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
camera = tool.Ifc.get_object(element)
break
if not camera:
return
@@ -62,12 +64,7 @@ class Annotator:
font_size = 1.6 / 1000
font_size *= float(text_obj.data.BIMTextProperties.font_size)
if camera.data.BIMCameraProperties.diagram_scale == "CUSTOM":
human_scale, fraction = camera.data.BIMCameraProperties.custom_diagram_scale.split("|")
else:
human_scale, fraction = camera.data.BIMCameraProperties.diagram_scale.split("|")
numerator, denominator = fraction.split("/")
font_size /= float(numerator) / float(denominator)
font_size /= tool.Drawing.get_scale_ratio(tool.Drawing.get_diagram_scale(camera)["Scale"])
text_obj.data.size = font_size
@@ -77,66 +74,37 @@ class Annotator:
co1, co2, _, _ = Annotator.get_placeholder_coords()
co1 = obj.matrix_world.inverted() @ co1
co2 = obj.matrix_world.inverted() @ co2
if isinstance(obj.data, bpy.types.Mesh):
obj.data.vertices.add(2)
obj.data.vertices[-2].co = co1
obj.data.vertices[-1].co = co2
obj.data.edges.add(1)
obj.data.edges[-1].vertices = (obj.data.vertices[-2].index, obj.data.vertices[-1].index)
if isinstance(obj.data, bpy.types.Curve):
polyline = obj.data.splines.new("POLY")
polyline.points.add(1)
polyline.points[-2].co = list(co1) + [1]
polyline.points[-1].co = list(co2) + [1]
return obj
@staticmethod
def add_plane_to_annotation(obj):
co1, co2, co3, co4 = Annotator.get_placeholder_coords()
co1 = obj.matrix_world.inverted() @ co1 # bot left
co2 = obj.matrix_world.inverted() @ co2 # top left
co3 = obj.matrix_world.inverted() @ co3 # bot right
co4 = obj.matrix_world.inverted() @ co4 # top right
def add_plane_to_annotation(obj, remove_face=False):
# default order = bot left, top left, bot right, top right
# therefore we redefine the order
face_verts = [0, 2, 3, 1]
obj.data.vertices.add(4)
v1 = obj.data.vertices[-4]
v2 = obj.data.vertices[-3]
v3 = obj.data.vertices[-2]
v4 = obj.data.vertices[-1]
v1.co = co4
v2.co = co2
v3.co = co1
v4.co = co3
verts_world_space = Annotator.get_placeholder_coords()
verts_local = [obj.matrix_world.inverted() @ v for v in verts_world_space]
bm = tool.Blender.get_bmesh_for_mesh(obj.data, clean=True)
new_verts = [bm.verts.new(v) for v in verts_local]
obj.data.edges.add(4)
e1 = obj.data.edges[-4]
e2 = obj.data.edges[-3]
e3 = obj.data.edges[-2]
e4 = obj.data.edges[-1]
e1.vertices = (v1.index, v2.index)
e2.vertices = (v2.index, v3.index)
e3.vertices = (v3.index, v4.index)
e4.vertices = (v4.index, v1.index)
obj.data.loops.add(4)
l1 = obj.data.loops[-4]
l2 = obj.data.loops[-3]
l3 = obj.data.loops[-2]
l4 = obj.data.loops[-1]
l1.vertex_index = v1.index
l1.edge_index = e1.index
l2.vertex_index = v2.index
l2.edge_index = e2.index
l3.vertex_index = v3.index
l3.edge_index = e3.index
l4.vertex_index = v4.index
l4.edge_index = e4.index
obj.data.polygons.add(1)
p1 = obj.data.polygons[-1]
p1.vertices = (v1.index, v2.index, v3.index, v4.index)
p1.loop_start = l1.index
p1.loop_total = 4
face = bm.faces.new([new_verts[i] for i in face_verts])
if remove_face:
bmesh.ops.delete(bm, geom=[face], context="FACES_ONLY")
tool.Blender.apply_bmesh(obj.data, bm, obj)
return obj
@staticmethod
@@ -144,15 +112,15 @@ class Annotator:
camera = tool.Ifc.get_object(drawing)
co1, _, _, _ = Annotator.get_placeholder_coords(camera)
matrix_world = camera.matrix_world.copy()
matrix_world[0][3] = co1.x
matrix_world[1][3] = co1.y
matrix_world[2][3] = co1.z
collection = camera.users_collection[0]
matrix_world.translation = co1
collection = camera.BIMObjectProperties.collection
if object_type == "TEXT":
obj = bpy.data.objects.new(object_type, None)
obj.matrix_world = matrix_world
collection.objects.link(obj)
return obj
elif object_type in ("TEXT_LEADER", "SECTION_LEVEL"):
data = bpy.data.curves.new(object_type, type="CURVE")
data.dimensions = "3D"
@@ -161,17 +129,20 @@ class Annotator:
obj.matrix_world = matrix_world
collection.objects.link(obj)
return obj
if object_type != "ANGLE":
for obj in collection.objects:
element = tool.Ifc.get_entity(obj)
if element and element.ObjectType == object_type and obj.type == object_type.upper():
return obj
if data_type == "mesh":
data = bpy.data.meshes.new(object_type)
elif data_type == "curve":
data = bpy.data.curves.new(object_type, type="CURVE")
data.dimensions = "3D"
data.resolution_u = 2
obj = bpy.data.objects.new(object_type, data)
obj.matrix_world = matrix_world
collection.objects.link(obj)
@@ -182,14 +153,13 @@ class Annotator:
if not camera:
camera = bpy.context.scene.camera
z_offset = camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
if bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y:
y = (
camera.data.ortho_scale
* (bpy.context.scene.render.resolution_y / bpy.context.scene.render.resolution_x)
/ 4
)
else:
y = camera.data.ortho_scale / 4
y = camera.data.ortho_scale / 4
res_x = bpy.context.scene.render.resolution_x
res_y = bpy.context.scene.render.resolution_y
if res_x > res_y:
y *= res_y / res_x
y_offset = camera.matrix_world.to_quaternion() @ Vector((0, y, 0))
x_offset = camera.matrix_world.to_quaternion() @ Vector((y / 2, 0, 0))
return (
@@ -16,19 +16,23 @@
# 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/>.
import os
import bpy
import ifcopenshell.util.element
import ifcopenshell.util.representation
import blenderbim.tool as tool
from pathlib import Path
def refresh():
ProductAssignmentsData.is_loaded = False
TextData.is_loaded = False
SheetsData.is_loaded = False
SchedulesData.is_loaded = False
DocumentsData.is_loaded = False
DrawingsData.is_loaded = False
AnnotationData.is_loaded = False
DecoratorData.data = {}
DecoratorData.cut_cache = {}
DecoratorData.layerset_cache = {}
class ProductAssignmentsData:
@@ -51,40 +55,42 @@ class ProductAssignmentsData:
return f"{rel.RelatingProduct.is_a()}/{name}"
class TextData:
data = {}
is_loaded = False
@classmethod
def load(cls):
cls.data = {"attributes": cls.attributes()}
cls.is_loaded = True
@classmethod
def attributes(cls):
element = tool.Ifc.get_entity(bpy.context.active_object)
if not element or not element.is_a("IfcAnnotation") or element.ObjectType not in ["TEXT", "TEXT_LEADER"]:
return []
rep = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
text_literal = [i for i in rep.Items if i.is_a("IfcTextLiteral")][0]
return [
{"name": "Literal", "value": text_literal.Literal},
{"name": "BoxAlignment", "value": text_literal.BoxAlignment},
]
class SheetsData:
data = {}
is_loaded = False
@classmethod
def load(cls):
cls.data = {"total_sheets": cls.total_sheets()}
cls.data = {
"has_saved_ifc": cls.has_saved_ifc(),
"total_sheets": cls.total_sheets(),
"titleblocks": cls.titleblocks(),
}
cls.is_loaded = True
@classmethod
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def total_sheets(cls):
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION"])
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"])
@classmethod
def titleblocks(cls):
files = Path(os.path.join(bpy.context.scene.BIMProperties.data_dir, "templates", "titleblocks")).glob("*.svg")
files = [str(f.stem) for f in files]
if tool.Ifc.get():
project = tool.Ifc.get().by_type("IfcProject")[0]
titleblocks_dir = ifcopenshell.util.element.get_pset(project, "BBIM_Documentation", "TitleblocksDir")
if not titleblocks_dir:
titleblocks_dir = bpy.context.scene.DocProperties.titleblocks_dir
titleblocks_dir = tool.Ifc.resolve_uri(titleblocks_dir)
if os.path.exists(titleblocks_dir):
files.extend([str(f.stem) for f in Path(titleblocks_dir).glob("*.svg")])
return [(f, f, "") for f in sorted(list(set(files)))]
class DrawingsData:
@@ -93,9 +99,18 @@ class DrawingsData:
@classmethod
def load(cls):
cls.data = {"total_drawings": cls.total_drawings(), "location_hint": cls.location_hint()}
cls.data = {
"has_saved_ifc": cls.has_saved_ifc(),
"total_drawings": cls.total_drawings(),
"location_hint": cls.location_hint(),
"active_drawing_pset_data": cls.active_drawing_pset_data(),
}
cls.is_loaded = True
@classmethod
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def total_drawings(cls):
return len([e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"])
@@ -110,24 +125,63 @@ class DrawingsData:
return results
return [(h.upper(), h, "") for h in ["North", "South", "East", "West"]]
@classmethod
def active_drawing_pset_data(cls):
ifc_file = tool.Ifc.get()
drawing_id = bpy.context.scene.DocProperties.active_drawing_id
if drawing_id == 0:
return {}
drawing = ifc_file.by_id(bpy.context.scene.DocProperties.active_drawing_id)
return ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing")
class SchedulesData:
class DocumentsData:
data = {}
is_loaded = False
@classmethod
def load(cls):
cls.data = {"total_schedules": cls.total_schedules()}
documents = cls.count_documents()
cls.data = {
"has_saved_ifc": cls.has_saved_ifc(),
"total_schedules": documents["SCHEDULE"],
"total_references": documents["REFERENCE"],
}
cls.is_loaded = True
@classmethod
def total_schedules(cls):
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SCHEDULE"])
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def count_documents(cls):
documents = {
"SCHEDULE": 0,
"REFERENCE": 0,
}
for d in tool.Ifc.get().by_type("IfcDocumentInformation"):
scope = d.Scope
documents[scope] = documents.get(scope, 0) + 1
return documents
FONT_SIZES = {
"small": 1.8,
"regular": 2.5,
"large": 3.5,
"header": 5.0,
"title": 7.0,
}
class DecoratorData:
# stores 1 type of data per object
data = {}
cut_cache = {}
layerset_cache = {}
# used by Ifc Annotations with ObjectType = "BATTING"
@classmethod
def get_batting_thickness(cls, obj):
result = cls.data.get(obj.name, None)
@@ -136,8 +190,157 @@ class DecoratorData:
element = tool.Ifc.get_entity(obj)
if element:
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
thickness = ifcopenshell.util.element.get_pset(element, "BBIM_Batting", "Thickness")
thickness = ifcopenshell.util.element.get_pset(element, "BBIM_Batting", "Thickness")
thickness = thickness * unit_scale if thickness else 1.5
cls.data[obj.name] = thickness
return thickness
return 1.5
# used by Ifc Annotations with ObjectType = "SECTION"
@classmethod
def get_section_markers_display_data(cls, obj):
result = cls.data.get(obj.name, None)
if result is not None:
return result
element = tool.Ifc.get_entity(obj)
if not element:
return
# default values
pset_data = {
"HasConnectedSectionLine": True,
"ShowStartArrow": True,
"StartArrowSymbol": "",
"ShowEndArrow": True,
"EndArrowSymbol": "",
}
obj_pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Section") or {}
pset_data.update(obj_pset_data)
# create more usable display data
start_symbol = pset_data["StartArrowSymbol"]
end_symbol = pset_data["EndArrowSymbol"]
display_data = {
"start": {
"add_circle": pset_data["ShowStartArrow"] and not start_symbol,
"add_symbol": pset_data["ShowStartArrow"] or bool(start_symbol),
"symbol": start_symbol or "section-arrow",
},
"end": {
"add_circle": pset_data["ShowEndArrow"] and not end_symbol,
"add_symbol": pset_data["ShowEndArrow"] or bool(end_symbol),
"symbol": end_symbol or "section-arrow",
},
"connect_markers": pset_data["HasConnectedSectionLine"],
}
cls.data[obj.name] = display_data
return display_data
# used by Ifc Annotations with ObjectType = "TEXT" / "TEXT_LEADER"
@classmethod
def get_ifc_text_data(cls, obj):
"""returns font size in mm for current ifc text object"""
result = cls.data.get(obj.name, None)
if result is not None:
return result
element = tool.Ifc.get_entity(obj)
if not element or not tool.Drawing.is_annotation_object_type(element, ["TEXT", "TEXT_LEADER"]):
return None
props = obj.BIMTextProperties
# getting font size
pset_data = ifcopenshell.util.element.get_pset(element, "EPset_Annotation") or {}
# use `regular` as default
# get font size
classes = pset_data.get("Classes", None) or "regular"
classes_split = classes.split()
# prioritize smaller font sizes just like in svg
font_size_type = next(
(font_size_type for font_size_type in FONT_SIZES if font_size_type in classes_split), "regular"
)
font_size = FONT_SIZES[font_size_type]
# get symbol
symbol = pset_data.get("Symbol", None)
# other attributes
props_literals = props.literals
props_literals_n = len(props.literals)
literals = tool.Drawing.get_text_literal(obj, return_list=True)
literals_data = []
for i, literal in enumerate(literals):
literal_data = {
"Literal": literal.Literal,
"BoxAlignment": literal.BoxAlignment,
}
if i < props_literals_n:
literal_data["CurrentValue"] = props_literals[i].value
else:
literal_data["CurrentValue"] = literal.Literal
literals_data.append(literal_data)
text_data = {"Literals": literals_data, "FontSize": font_size, "Symbol": symbol}
cls.data[obj.name] = text_data
return text_data
# used by Ifc Annotations with ObjectType = "DIMENSION" / "DIAMETER"
@classmethod
def get_dimension_data(cls, obj):
result = cls.data.get(obj.name, None)
if result is not None:
return result
element = tool.Ifc.get_entity(obj)
supported_object_types = ("DIMENSION", "DIAMETER")
if not element or not element.is_a("IfcAnnotation") or element.ObjectType not in supported_object_types:
return None
dimension_style = "arrow"
classes = ifcopenshell.util.element.get_pset(element, "EPset_Annotation", "Classes")
if classes and "oblique" in classes.lower().split():
dimension_style = "oblique"
pset_data = ifcopenshell.util.element.get_pset(element, "BBIM_Dimension") or {}
show_description_only = pset_data.get("ShowDescriptionOnly", False)
suppress_zero_inches = pset_data.get("SuppressZeroInches", False)
text_prefix = pset_data.get("TextPrefix", "")
text_suffix = pset_data.get("TextSuffix", "")
dimension_data = {
"dimension_style": dimension_style,
"show_description_only": show_description_only,
"suppress_zero_inches": suppress_zero_inches,
"text_prefix": text_prefix,
"text_suffix": text_suffix,
}
cls.data[obj.name] = dimension_data
return dimension_data
class AnnotationData:
data = {}
is_loaded = False
@classmethod
def load(cls):
cls.is_loaded = True
cls.props = bpy.context.scene.BIMAnnotationProperties
cls.data["relating_types"] = cls.get_relating_types()
@classmethod
def get_relating_types(cls):
object_type = cls.props.object_type
relating_types = []
for relating_type in tool.Ifc.get().by_type("IfcTypeProduct"):
if tool.Drawing.is_annotation_object_type(relating_type, object_type):
relating_types.append(relating_type)
enum_items = [(str(e.id()), e.Name or "Unnamed", e.Description or "") for e in relating_types]
# item to create anootations without relating types
enum_items.insert(0, ("0", "-", ""))
return enum_items
File diff suppressed because it is too large Load Diff
@@ -18,13 +18,12 @@
import bpy
import blf
import math
import gpu, bgl
import gpu
from bpy import types
from mathutils import Vector, Matrix
from mathutils import Vector
from mathutils import geometry
from bpy_extras import view3d_utils
from blenderbim.bim.module.drawing.shaders import DotsGizmoShader, ExtrusionGuidesShader, BaseLinesShader
from blenderbim.bim.module.drawing.shaders import DotsGizmoShader, ExtrusionGuidesShader
from ifcopenshell.util.unit import si_conversions
@@ -252,11 +251,12 @@ X3DISC = (
class CustomGizmo:
# FIXME: highliting/selection doesnt work
def draw_very_custom_shape(self, ctx, custom_shape, select_id=None):
# similar to draw_custom_shape
shape, batch, shader = custom_shape
# create shader and batch
shader_wrapper, batch = custom_shape
shader = shader_wrapper.get_shader()
# setup params
shader.bind()
if select_id is not None:
gpu.select.load_id(select_id)
else:
@@ -265,15 +265,19 @@ class CustomGizmo:
else:
color = (*self.color, self.alpha)
shader.uniform_float("color", color)
shape.glenable()
shader_wrapper.glenable()
shader_wrapper.uniform_region(ctx)
shape.uniform_region(ctx)
# shader.uniform_float('modelMatrix', self.matrix_world)
# using `with` block to make sure matrix multiplication
# won't affect other shaders
with gpu.matrix.push_pop():
gpu.matrix.multiply_matrix(self.matrix_world)
batch.draw()
# using matrix_world seems to be unaffected by matrix_offset
# therefore we use basis @ offset
matrix = self.matrix_basis @ self.matrix_offset
gpu.matrix.multiply_matrix(matrix)
batch.draw(shader)
bgl.glDisable(bgl.GL_BLEND)
gpu.state.blend_set("NONE")
class OffsetHandle:
@@ -361,6 +365,7 @@ class UglyDotGizmo(OffsetHandle, types.Gizmo):
self.draw_custom_shape(self.custom_shape, select_id=select_id)
# TODO: dead code?
class DotGizmo(CustomGizmo, OffsetHandle, types.Gizmo):
"""Single dot viewport-aligned"""
@@ -390,10 +395,6 @@ class DotGizmo(CustomGizmo, OffsetHandle, types.Gizmo):
self.refresh()
self.draw_very_custom_shape(ctx, self.custom_shape, select_id=select_id)
# doesn't get called
# def test_select(self, ctx, location):
# pass
class ExtrusionGuidesGizmo(CustomGizmo, types.Gizmo):
"""Extrusion guides
@@ -408,19 +409,25 @@ class ExtrusionGuidesGizmo(CustomGizmo, types.Gizmo):
__slots__ = ("scale_value", "custom_shape")
def setup(self):
shader = ExtrusionGuidesShader()
self.custom_shape = shader, shader.batch(pos=((0, 0, 0), (0, 0, 1))), shader.prog
self.use_draw_scale = False
def refresh(self):
depth = self.target_get_value("depth") / self.scale_value
self.matrix_offset.col[2][2] = depth # z-scaled
"""setup `custom_shape`"""
shader_wrapper = ExtrusionGuidesShader()
verts = [Vector((0, 0, 0)), Vector((0, 0, 1))]
verts, edges = shader_wrapper.process_geometry(verts)
self.custom_shape = shader_wrapper, shader_wrapper.batch(
pos=verts,
indices=edges,
)
def draw(self, ctx):
self.refresh()
self.draw_very_custom_shape(ctx, self.custom_shape)
def refresh(self):
depth = self.target_get_value("depth") / self.scale_value
self.matrix_offset.col[2][2] = depth # z-scaled
# TODO: dead code?
class DimensionLabelGizmo(types.Gizmo):
"""Text label for a dimension"""
@@ -487,6 +494,7 @@ class ExtrusionWidget(types.GizmoGroup):
theme = ctx.preferences.themes[0].user_interface
scale_value = self.get_scale_value(ctx.scene.unit_settings.system, ctx.scene.unit_settings.length_unit)
# setup handle
gz = self.handle = self.gizmos.new("BIM_GT_uglydot_3d")
gz.matrix_basis = basis
gz.scale_basis = 0.1
@@ -497,10 +505,11 @@ class ExtrusionWidget(types.GizmoGroup):
gz.target_set_prop("offset", prop, "value")
gz.scale_value = scale_value
# setup guides
gz = self.guides = self.gizmos.new("BIM_GT_extrusion_guides")
gz.matrix_basis = basis
gz.color = gz.color_highlight = tuple(theme.gizmo_secondary)
gz.alpha = gz.alpha_highlight = 0.5
gz.alpha = gz.alpha_highlight = 0.75
gz.use_draw_modal = True
gz.target_set_prop("depth", prop, "value")
gz.scale_value = scale_value
@@ -23,8 +23,7 @@ from bpy.app.handlers import persistent
@persistent
def toggleDecorationsOnLoad(*args):
toggle = bpy.context.scene.DocProperties.should_draw_decorations
if toggle:
if bpy.context.scene.DocProperties.should_draw_decorations:
decoration.DecorationsHandler.install(bpy.context)
else:
decoration.DecorationsHandler.uninstall()
@@ -120,9 +120,9 @@ class BoundingBox:
# This function stolen from https://github.com/kevancress/MeasureIt_ARCH/blob/dcf607ce0896aa2284463c6b4ae9cd023fc54cbe/measureit_arch_baseclass.py
# MeasureIt-ARCH is GPL-v3
# In the future I will need to rewrite this to allow the user to have custom
# settings for each annotation object, not read from Blender.
def format_distance(value, isArea=False, hide_units=True):
def format_distance(
value, isArea=False, hide_units=True, precision=None, decimal_places=None, suppress_zero_inches=False
):
s_code = "\u00b2" # Superscript two THIS IS LEGACY (but being kept for when Area Measurements are re-implimented)
# Get Scene Unit Settings
@@ -131,7 +131,7 @@ def format_distance(value, isArea=False, hide_units=True):
unit_length = bpy.context.scene.unit_settings.length_unit
toInches = 39.3700787401574887
inPerFoot = 11.999
inPerFoot = 11.9999
if isArea:
toInches = 1550
@@ -141,8 +141,7 @@ def format_distance(value, isArea=False, hide_units=True):
# Imperial Formatting
if unit_system == "IMPERIAL":
precision = bpy.context.scene.BIMProperties.imperial_precision
if precision == "NONE":
if not precision:
precision = 256
elif precision == "1":
precision = 1
@@ -155,13 +154,14 @@ def format_distance(value, isArea=False, hide_units=True):
# Separate ft and inches
# Unless Inches are the specified Length Unit
if unit_length != "INCHES":
feet = math.floor(decInches / inPerFoot)
feet = int(decInches / inPerFoot) # remove decimal
decInches -= feet * inPerFoot
else:
feet = 0
# Separate Fractional Inches
inches = math.floor(decInches)
decInches = abs(decInches) # ignore the sign for inches
inches = math.floor(decInches) # remove decimal
if inches != 0:
frac = round(base * (decInches - inches))
else:
@@ -186,44 +186,50 @@ def format_distance(value, isArea=False, hide_units=True):
inches = 0
if not isArea:
add_inches = bool(inches) or not suppress_zero_inches
tx_dist = ""
if feet:
tx_dist += str(feet) + "'"
if feet and inches:
if feet and add_inches:
tx_dist += " - "
if inches:
if add_inches:
tx_dist += str(inches)
if inches and frac:
if add_inches and frac:
tx_dist += " "
if frac:
tx_dist += str(frac) + "/" + str(base)
if inches or frac:
if add_inches or frac:
tx_dist += '"'
else:
tx_dist = str("%1.3f" % (value * toInches / inPerFoot)) + " sq. ft."
# METRIC FORMATTING
elif unit_system == "METRIC":
precision = bpy.context.scene.BIMProperties.metric_precision
if precision != 0:
if precision:
value = precision * round(float(value) / precision)
if decimal_places:
fmt = "%1." + str(decimal_places) + "f"
# Meters
if unit_length == "METERS":
fmt = "%1.3f"
if not decimal_places:
fmt = "%1.3f"
if hide_units is False:
fmt += " m"
tx_dist = fmt % value
# Centimeters
elif unit_length == "CENTIMETERS":
fmt = "%1.1f"
if not decimal_places:
fmt = "%1.1f"
if hide_units is False:
fmt += " cm"
d_cm = value * (100)
tx_dist = fmt % d_cm
# Millimeters
elif unit_length == "MILLIMETERS":
fmt = "%1.0f"
if not decimal_places:
fmt = "%1.0f"
if hide_units is False:
fmt += " mm"
d_mm = value * (1000)
@@ -231,20 +237,21 @@ def format_distance(value, isArea=False, hide_units=True):
# Otherwise Use Adaptive Units
else:
if round(value, 2) >= 1.0:
if round(value, 2) >= 1.0 and not decimal_places:
fmt = "%1.3f"
if hide_units is False:
fmt += " m"
tx_dist = fmt % value
else:
if round(value, 2) >= 0.01:
if round(value, 2) >= 0.01 and not decimal_places:
fmt = "%1.1f"
if hide_units is False:
fmt += " cm"
d_cm = value * (100)
tx_dist = fmt % d_cm
else:
fmt = "%1.0f"
if not decimal_places:
fmt = "%1.0f"
if hide_units is False:
fmt += " mm"
d_mm = value * (1000)
@@ -262,7 +269,7 @@ def get_active_drawing(scene):
props = scene.DocProperties
try:
camera = tool.Ifc.get_object(tool.Ifc.get().by_id(props.active_drawing_id))
return camera.users_collection[0], camera
return camera.BIMObjectProperties.collection, camera
except:
return None, None
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,8 @@ import blenderbim.tool as tool
import blenderbim.core.drawing as core
import blenderbim.bim.module.drawing.annotation as annotation
import blenderbim.bim.module.drawing.decoration as decoration
from blenderbim.bim.module.drawing.data import DrawingsData
from blenderbim.bim.module.drawing.data import DrawingsData, DecoratorData, SheetsData, AnnotationData
from blenderbim.bim.module.drawing.data import refresh as refresh_drawing_data
from pathlib import Path
from blenderbim.bim.prop import Attribute, StrProperty
from bpy.types import PropertyGroup
@@ -38,24 +39,19 @@ from bpy.props import (
FloatProperty,
FloatVectorProperty,
CollectionProperty,
BoolVectorProperty,
)
diagram_scales_enum = []
titleblocks_enum = []
sheets_enum = []
vector_styles_enum = []
def purge():
global diagram_scales_enum
global titleblocks_enum
global sheets_enum
global vector_styles_enum
diagram_scales_enum = []
titleblocks_enum = []
sheets_enum = []
vector_styles_enum = []
def update_target_view(self, context):
@@ -69,12 +65,6 @@ def get_location_hint(self, context):
def update_diagram_scale(self, context):
scale = self.diagram_scale
if scale == "CUSTOM":
scale = self.custom_diagram_scale
if "|" not in scale:
return
human_scale, scale = scale.split("|")
try:
element = (
tool.Ifc.get()
@@ -84,14 +74,33 @@ def update_diagram_scale(self, context):
)
except:
return
pset = ifcopenshell.util.element.get_psets(element).get("EPset_Drawing")
diagram_scale = tool.Drawing.get_diagram_scale(tool.Ifc.get_object(element))
if not diagram_scale:
return
pset = ifcopenshell.util.element.get_pset(element, "EPset_Drawing")
if pset:
pset = tool.Ifc.get().by_id(pset["id"])
else:
pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Drawing")
ifcopenshell.api.run(
"pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Scale": scale, "HumanScale": human_scale}
)
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties=diagram_scale)
def update_is_nts(self, context):
try:
element = (
tool.Ifc.get()
.by_id(self.id_data.BIMMeshProperties.ifc_definition_id)
.OfProductRepresentation[0]
.ShapeOfProduct[0]
)
except:
return
pset = ifcopenshell.util.element.get_pset(element, "EPset_Drawing")
if pset:
pset = tool.Ifc.get().by_id(pset["id"])
else:
pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Drawing")
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"IsNTS": self.is_nts})
def get_diagram_scales(self, context):
@@ -160,13 +169,32 @@ def update_drawing_name(self, context):
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
def update_schedule_name(self, context):
schedule = tool.Ifc.get().by_id(self.ifc_definition_id)
core.update_schedule_name(tool.Ifc, tool.Drawing, schedule=schedule, name=self.name)
def get_drawing_style_name(self):
"""needed to make `set_drawing_style_name` work"""
return self.get("name", "")
def set_drawing_style_name(self, new_value):
"""ensure the name is unique"""
scene = bpy.context.scene
drawing_styles = [s.name for s in scene.DocProperties.drawing_styles if s.name != self.name]
new_value = tool.Blender.ensure_unique_name(new_value, drawing_styles)
old_value = self.name
self["name"] = new_value
bpy.ops.bim.save_drawing_styles_data(rename_style=True, rename_style_from=old_value, rename_style_to=new_value)
def update_document_name(self, context):
document = tool.Ifc.get().by_id(self.ifc_definition_id)
core.update_document_name(tool.Ifc, tool.Drawing, document=document, name=self.name)
def update_has_underlay(self, context):
update_layer(self, context, "HasUnderlay", self.has_underlay)
# making sure that camera is active
if self.has_underlay and (context.active_object and context.active_object.data == self.id_data):
bpy.ops.bim.reload_drawing_styles()
bpy.ops.bim.activate_drawing_style()
def update_has_linework(self, context):
@@ -189,48 +217,32 @@ def update_layer(self, context, name, value):
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={name: value})
def getTitleblocks(self, context):
global titleblocks_enum
if len(titleblocks_enum) < 1:
titleblocks_enum.clear()
files = Path(os.path.join(context.scene.BIMProperties.data_dir, "templates", "titleblocks")).glob("*.svg")
files = sorted([str(f.stem) for f in files])
titleblocks_enum.extend([(f, f, "") for f in files])
return titleblocks_enum
def get_titleblocks(self, context):
if not SheetsData.is_loaded:
SheetsData.load()
return SheetsData.data["titleblocks"]
def refreshTitleblocks(self, context):
global titleblocks_enum
titleblocks_enum.clear()
getTitleblocks(self, context)
def update_titleblocks(self, context):
SheetsData.data["titleblocks"] = SheetsData.titleblocks()
def toggleDecorations(self, context):
toggle = self.should_draw_decorations
if toggle:
# TODO: design a proper text variable templating renderer
collection = context.scene.camera.users_collection[0]
collection = context.scene.camera.BIMObjectProperties.collection
for obj in collection.objects:
element = tool.Ifc.get_entity(obj)
if not element or not tool.Drawing.is_annotation_object_type(element, ["TEXT", "TEXT_LEADER"]):
continue
tool.Drawing.update_text_value(obj)
refresh_drawing_data()
decoration.DecorationsHandler.install(context)
else:
decoration.DecorationsHandler.uninstall()
def getVectorStyles(self, context):
global vector_styles_enum
if len(vector_styles_enum) < 1:
sheets_enum.clear()
for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, "styles")).glob("*.css"):
f = str(filename.stem)
vector_styles_enum.append((f, f, ""))
return vector_styles_enum
def refreshFontSize(self, context):
annotation.Annotator.resize_text(context.active_object)
class Variable(PropertyGroup):
name: StringProperty(name="Name")
prop_key: StringProperty(name="Property Key")
@@ -240,36 +252,27 @@ class Drawing(PropertyGroup):
ifc_definition_id: IntProperty(name="IFC Definition ID")
name: StringProperty(name="Name", update=update_drawing_name)
target_view: StringProperty(name="Target View")
is_selected: BoolProperty(name="Is Selected", default=True)
class Schedule(PropertyGroup):
class Document(PropertyGroup):
ifc_definition_id: IntProperty(name="IFC Definition ID")
name: StringProperty(name="Name", update=update_schedule_name)
name: StringProperty(name="Name", update=update_document_name)
identification: StringProperty(name="Identification")
class Sheet(PropertyGroup):
def set_name(self, new):
old = self.get("name")
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "sheets")
if old and os.path.isfile(os.path.join(path, old + ".svg")):
os.rename(os.path.join(path, old + ".svg"), os.path.join(path, new + ".svg"))
self["name"] = new
def get_name(self):
return self.get("name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
identification: StringProperty(name="Identification")
name: StringProperty(name="Name", get=get_name, set=set_name)
name: StringProperty(name="Name")
is_sheet: BoolProperty(name="Is Sheet", default=False)
reference_type: StringProperty(name="Reference Type")
is_expanded: BoolProperty(name="Is Expanded", default=False)
class DrawingStyle(PropertyGroup):
name: StringProperty(name="Name")
raster_style: StringProperty(name="Raster Style")
name: StringProperty(name="Name", get=get_drawing_style_name, set=set_drawing_style_name)
raster_style: StringProperty(name="Raster Style", default="{}")
render_type: EnumProperty(
items=[
("NONE", "None", ""),
@@ -279,37 +282,26 @@ class DrawingStyle(PropertyGroup):
name="Render Type",
default="VIEWPORT",
)
vector_style: EnumProperty(items=getVectorStyles, name="Vector Style")
include_query: StringProperty(name="Include Query")
exclude_query: StringProperty(name="Exclude Query")
attributes: CollectionProperty(name="Attributes", type=StrProperty)
class RasterStyleProperty(enum.Enum):
WORLD_COLOR = "bpy.data.worlds[0].color"
RENDER_ENGINE = "scene.render.engine"
RENDER_TRANSPARENT = "scene.render.film_transparent"
VIEW_TRANSFORM = "scene.view_settings.view_transform"
SHADING_SHOW_OBJECT_OUTLINE = "scene.display.shading.show_object_outline"
SHADING_SHOW_CAVITY = "scene.display.shading.show_cavity"
SHADING_CAVITY_TYPE = "scene.display.shading.cavity_type"
SHADING_CURVATURE_RIDGE_FACTOR = "scene.display.shading.curvature_ridge_factor"
SHADING_CURVATURE_VALLEY_FACTOR = "scene.display.shading.curvature_valley_factor"
SHADING_LIGHT = "scene.display.shading.light"
SHADING_COLOR_TYPE = "scene.display.shading.color_type"
SHADING_SINGLE_COLOR = "scene.display.shading.single_color"
SHADING_SHOW_SHADOWS = "scene.display.shading.show_shadows"
SHADING_SHADOW_INTENSITY = "scene.display.shading.shadow_intensity"
DISPLAY_LIGHT_DIRECTION = "scene.display.light_direction"
VIEW_USE_CURVE_MAPPING = "scene.view_settings.use_curve_mapping"
OVERLAY_SHOW_WIREFRAMES = "space.overlay.show_wireframes"
OVERLAY_WIREFRAME_THRESHOLD = "space.overlay.wireframe_threshold"
OVERLAY_SHOW_FLOOR = "space.overlay.show_floor"
OVERLAY_SHOW_AXIS_X = "space.overlay.show_axis_x"
OVERLAY_SHOW_AXIS_Y = "space.overlay.show_axis_y"
OVERLAY_SHOW_AXIS_Z = "space.overlay.show_axis_z"
OVERLAY_SHOW_OBJECT_ORIGINS = "space.overlay.show_object_origins"
OVERLAY_SHOW_RELATIONSHIP_LINES = "space.overlay.show_relationship_lines"
# EVAL_PROP_ props will be evaluated explicitly
EVAL_PROP_WORLD_COLOR = "bpy.data.worlds[0].color"
# those props attributes used as a source for shading style properties
RENDER = "scene.render"
VIEW_SETTINGS = "scene.view_settings"
SHADING = "scene.display.shading"
DISPLAY = "scene.display"
OVERLAY = "space.overlay"
RASTER_STYLE_PROPERTIES_EXCLUDE = (
"scene.render.filepath",
)
class DocProperties(PropertyGroup):
@@ -319,6 +311,7 @@ class DocProperties(PropertyGroup):
should_extract: BoolProperty(name="Should Extract", default=True)
is_editing_drawings: BoolProperty(name="Is Editing Drawings", default=False)
is_editing_schedules: BoolProperty(name="Is Editing Schedules", default=False)
is_editing_references: BoolProperty(name="Is Editing References", default=False)
target_view: EnumProperty(
items=[
("PLAN_VIEW", "Plan", ""),
@@ -336,31 +329,49 @@ class DocProperties(PropertyGroup):
active_drawing_id: IntProperty(name="Active Drawing Id")
active_drawing_index: IntProperty(name="Active Drawing Index")
current_drawing_index: IntProperty(name="Current Drawing Index")
schedules: CollectionProperty(name="Schedules", type=Schedule)
schedules: CollectionProperty(name="Schedules", type=Document)
active_schedule_index: IntProperty(name="Active Schedule Index")
titleblock: EnumProperty(items=getTitleblocks, name="Titleblock", update=refreshTitleblocks)
references: CollectionProperty(name="References", type=Document)
active_reference_index: IntProperty(name="Active Reference Index")
titleblock: EnumProperty(items=get_titleblocks, name="Titleblock", update=update_titleblocks)
is_editing_sheets: BoolProperty(name="Is Editing Sheets", default=False)
sheets: CollectionProperty(name="Sheets", type=Sheet)
active_sheet_index: IntProperty(name="Active Sheet Index")
ifc_files: CollectionProperty(name="IFCs", type=StrProperty)
drawing_styles: CollectionProperty(name="Drawing Styles", type=DrawingStyle)
should_draw_decorations: BoolProperty(name="Should Draw Decorations", update=toggleDecorations)
decorations_colour: FloatVectorProperty(
name="Decorations Colour", subtype="COLOR", default=(1, 1, 1, 1), min=0.0, max=1.0, size=4
sheets_dir: StringProperty(default=os.path.join("sheets") + os.path.sep, name="Default Sheets Directory")
layouts_dir: StringProperty(default=os.path.join("layouts") + os.path.sep, name="Default Layouts Directory")
titleblocks_dir: StringProperty(
default=os.path.join("layouts", "titleblocks") + os.path.sep, name="Default Titleblocks Directory"
)
drawings_dir: StringProperty(default=os.path.join("drawings") + os.path.sep, name="Default Drawings Directory")
stylesheet_path: StringProperty(
default=os.path.join("drawings", "assets", "default.css"), name="Default Stylesheet"
)
markers_path: StringProperty(default=os.path.join("drawings", "assets", "markers.svg"), name="Default Markers")
symbols_path: StringProperty(default=os.path.join("drawings", "assets", "symbols.svg"), name="Default Symbols")
patterns_path: StringProperty(default=os.path.join("drawings", "assets", "patterns.svg"), name="Default Patterns")
shadingstyles_path: StringProperty(
default=os.path.join("drawings", "assets", "shading_styles.json"), name="Default Shading Styles"
)
shadingstyle_default: StringProperty(default="Blender Default", name="Default Shading Style")
class BIMCameraProperties(PropertyGroup):
calculate_shapely_surfaces: BoolProperty(name="Calculate Shapely Surfaces", default=False)
calculate_svgfill_surfaces: BoolProperty(name="Calculate SVGFill Surfaces", default=False)
has_underlay: BoolProperty(name="Underlay", default=False, update=update_has_underlay)
has_linework: BoolProperty(name="Linework", default=True, update=update_has_linework)
has_annotation: BoolProperty(name="Annotation", default=True, update=update_has_annotation)
representation: StringProperty(name="Representation")
view_name: StringProperty(name="View Name")
diagram_scale: EnumProperty(items=get_diagram_scales, name="Drawing Scale", update=update_diagram_scale)
custom_diagram_scale: StringProperty(name="Custom Scale", update=update_diagram_scale)
custom_scale_numerator: bpy.props.StringProperty(default="1", update=update_diagram_scale)
custom_scale_denominator: bpy.props.StringProperty(default="100", update=update_diagram_scale)
raster_x: IntProperty(name="Raster X", default=1000)
raster_y: IntProperty(name="Raster Y", default=1000)
is_nts: BoolProperty(name="Is NTS")
is_nts: BoolProperty(name="Is NTS", update=update_is_nts)
active_drawing_style_index: IntProperty(name="Active Drawing Style Index")
# For now, this JSON dump are all the parameters that determine a camera's "Block representation"
@@ -381,10 +392,66 @@ class BIMCameraProperties(PropertyGroup):
return False
DEFAULT_BOX_ALIGNMENT = [False] * 6 + [True] + [False] * 2
BOX_ALIGNMENT_POSITIONS = [
"top-left",
"top-middle",
"top-right",
"middle-left",
"center",
"middle-right",
"bottom-left",
"bottom-middle",
"bottom-right",
]
class Literal(PropertyGroup):
def set_box_alignment(self, new_value):
markers = new_value.count(True)
if not markers:
return
if markers > 1:
prev_value = self.get("box_alignment", DEFAULT_BOX_ALIGNMENT)
# looking for the first value changed to positive
first_changed_value = next((i for i in range(9) if new_value[i] and new_value[i] != prev_value[i]), None)
# if nothing have changed we just keep the previous value
if first_changed_value is None:
return
new_value = [False] * 9
new_value[first_changed_value] = True
self["box_alignment"] = new_value
position_string = BOX_ALIGNMENT_POSITIONS[next(i for i in range(9) if new_value[i])]
self.attributes["BoxAlignment"].set_value(position_string)
def get_box_alignment(self):
return self.get("box_alignment", DEFAULT_BOX_ALIGNMENT)
attributes: CollectionProperty(name="Attributes", type=Attribute)
# Current text value with evaluated experessions stored in `value`.
# The original (Literal) value stored in `attributes['Literal']`
# and can be accessed with `get_text()`
value: StringProperty(name="Value", default="TEXT")
box_alignment: BoolVectorProperty(
name="Box alignment", size=9, set=set_box_alignment, get=get_box_alignment, default=DEFAULT_BOX_ALIGNMENT
)
ifc_definition_id: IntProperty(name="IFC definition ID", default=0)
def get_literal_edited_data(self):
text_data = {
"CurrentValue": self.attributes["Literal"].string_value,
"Literal": self.attributes["Literal"].string_value,
"BoxAlignment": self.attributes["BoxAlignment"].string_value,
}
return text_data
class BIMTextProperties(PropertyGroup):
is_editing: BoolProperty(name="Is Editing", default=False)
attributes: CollectionProperty(name="Attributes", type=Attribute)
value: StringProperty(name="Value", default="TEXT")
literals: CollectionProperty(name="Literals", type=Literal)
font_size: EnumProperty(
items=[
("1.8", "1.8 - Small", ""),
@@ -394,11 +461,84 @@ class BIMTextProperties(PropertyGroup):
("7.0", "7.0 - Title", ""),
],
default="2.5",
update=refreshFontSize,
name="Font Size",
)
def get_text_edited_data(self):
"""should be called only if `is_editing`
otherwise should use `DecoratorData.get_ifc_text_data(obj)` instead
because this data could be out of date
"""
literals_data = []
for literal in self.literals:
literal_data = literal.get_literal_edited_data()
literals_data.append(literal_data)
text_data = {
"Literals": literals_data,
"FontSize": float(self.font_size),
}
return text_data
class BIMAssignedProductProperties(PropertyGroup):
is_editing_product: BoolProperty(name="Is Editing Product", default=False)
relating_product: PointerProperty(name="Relating Product", type=bpy.types.Object)
# ObjectType: annotation_name, description, icon, data_type
# fmt: off
ANNOTATION_TYPES_DATA = {
"DIMENSION": ("Dimension", "Add dimensions annotation.\nMeasurement values can be hidden through ShowDescriptionOnly property\nof BBIM_Dimension property set", "FIXED_SIZE", "curve"),
"ANGLE": ("Angle", "", "DRIVER_ROTATIONAL_DIFFERENCE", "curve"),
"RADIUS": ("Radius", "", "FORWARD", "curve"),
"DIAMETER": ("Diameter", "Add diameter annotation.\nMeasurement values can be hidden through ShowDescriptionOnly property\nof BBIM_Dimension property set", "ARROW_LEFTRIGHT", "curve"),
"TEXT": ("Text", "", "SMALL_CAPS", "empty"),
"TEXT_LEADER": ("Leader", "", "TRACKING_BACKWARDS", "curve"),
"STAIR_ARROW": ("Stair Arrow", "Add stair arrow annotation.\nIf you have IfcStairFlight object selected, it will be used as a reference for the annotation", "SCREEN_BACK", "curve"),
"HIDDEN_LINE": ("Hidden", "", "CON_TRACKTO", "mesh"),
"PLAN_LEVEL": ("Level (Plan)", "", "SORTBYEXT", "curve"),
"SECTION_LEVEL": ("Level (Section)", "", "TRIA_DOWN", "curve"),
"BREAKLINE": ("Breakline", "", "FCURVE", "mesh"),
"LINEWORK": ("Line", "", "MESH_MONKEY", "mesh"),
"BATTING": ("Batting", "Add batting annotation.\nThickness could be changed through Thickness property of BBIM_Batting property set", "FORCE_FORCE", "mesh"),
"REVISION_CLOUD":("Revision Cloud", "Add revision cloud", "VOLUME_DATA", "mesh"),
"FILL_AREA": ("Fill Area", "", "NODE_TEXTURE", "mesh"),
"FALL": ("Fall", "", "SORT_ASC", "curve"),
}
# fmt: on
annotation_classes = [(x, *ANNOTATION_TYPES_DATA[x][:3], i) for i, x in enumerate(ANNOTATION_TYPES_DATA)]
def get_annotation_data_prop(prop_name):
def function(self, context):
if not AnnotationData.is_loaded:
AnnotationData.load()
return AnnotationData.data[prop_name]
return function
def update_annotation_object_type(self, context):
self.relating_type_id = "0"
# changing enum doesn't trigger refresh by itself
AnnotationData.is_loaded = False
def update_sheet_data(self, context):
SheetsData.is_loaded = False
class BIMAnnotationProperties(PropertyGroup):
object_type: bpy.props.EnumProperty(
name="Annotation Object Type", items=annotation_classes, default="TEXT", update=update_annotation_object_type
)
relating_type_id: bpy.props.EnumProperty(
name="Relating Annotation Type", items=get_annotation_data_prop("relating_types")
)
create_representation_for_type: bpy.props.BoolProperty(
name="Create Representation For Type",
default=False,
description='Whether "Add type" should define a representation for the type \n'
"or allow occurences to have their own",
)
@@ -16,12 +16,41 @@
# 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/>.
from blenderbim.bim.module.drawing.svgwriter import SvgWriter
import svgwrite
from odf.opendocument import load
from odf.opendocument import load as load_ods
from odf.table import Table, TableRow, TableColumn, TableCell
from odf.text import P
from odf.style import Style
from textwrap import wrap
from pathlib import Path
import string
FONT_SIZE = 4.13
FONT_WIDTH = lambda size: size * 0.45
FONT_SIZE_PT = 12
FONT_FAMILY = "OpenGost Type B TT"
DEBUG = False
def col2num(col):
"""convert letter column index to number:
`"A" -> 1`, `"AA" -> 27``
"""
num = 0
for c in col:
if c in string.ascii_letters:
num = num * 26 + (ord(c.upper()) - ord("A")) + 1
return num
def a1_to_rc(cell):
"""convert cell index from A1 format to RC: `"A1" -> (0,0)`"""
column_letter = cell.strip(string.digits)
col_number = col2num(column_letter) - 1
row_number = int(cell[len(column_letter) :]) - 1
return row_number, col_number
class Scheduler:
@@ -33,69 +62,334 @@ class Scheduler:
)
self.padding = 1
self.margin = 1
doc = load(infile)
doc = load_ods(infile)
# useful for debugging ods
if DEBUG:
import xml.dom.minidom
path = Path(infile)
dom = xml.dom.minidom.parseString(doc.xml())
pretty_xml = dom.toprettyxml()
with open(path.with_suffix(".xml"), "w") as fo:
fo.write(pretty_xml)
styles = {}
for style in doc.getElementsByType(Style):
name = style.getAttribute("name")
if not style.firstChild:
for cell_style in doc.getElementsByType(Style):
name = cell_style.getAttribute("name")
styles[name] = {}
# NOTE: there are also styles that inherit from parent styles that we do not process atm
if not cell_style.firstChild:
continue
styles[name] = {key[1]: value for key, value in style.firstChild.attributes.items()}
if cell_style.firstChild.tagName in ["style:table-column-properties", "style:table-row-properties"]:
style_children = [cell_style.firstChild]
else:
# for style:table-cell-properties we need to collect also text and paragraph properties
style_children = cell_style.childNodes
for child in style_children:
child_params = {key[1]: value for key, value in child.attributes.items()}
styles[name].update(child_params)
table = doc.getElementsByType(Table)[0]
# related styles stored as a list of tuples:
# [(child, parent), ...]
related_styles = []
# collect columns width
column_widths = []
column_styles = []
for col in table.getElementsByType(TableColumn):
style_name = col.getAttribute("stylename")
repeat = col.getAttribute("numbercolumnsrepeated")
repeat = int(repeat) if repeat else 1
for i in range(0, repeat):
col_repeat = col.getAttribute("numbercolumnsrepeated")
col_repeat = int(col_repeat) if col_repeat else 1
for i in range(col_repeat):
if not style_name or "column-width" not in styles[style_name]:
column_widths.append(50)
column_width = 50
else:
column_widths.append(self.convert_to_mm(styles[style_name]["column-width"]))
column_width = self.convert_to_mm(styles[style_name]["column-width"])
column_styles.append(style_name)
column_widths.append(column_width)
cell_style = col.getAttribute("defaultcellstylename")
if cell_style:
related_styles.append((style_name, cell_style))
# collect rows height
row_heights = []
# TODO: never used yet because unsure about priority for row styles
# over column styles or vice versa
row_styles = []
for col in table.getElementsByType(TableRow):
style_name = col.getAttribute("stylename")
row_repeat = col.getAttribute("numberrowsrepeated")
row_repeat = int(row_repeat) if row_repeat else 1
for i in range(row_repeat):
if not style_name or "row-height" not in styles[style_name]:
row_height = 6
else:
row_height = self.convert_to_mm(styles[style_name]["row-height"])
row_styles.append(style_name)
row_heights.append(row_height)
cell_style = col.getAttribute("defaultcellstylename")
if cell_style:
related_styles.append((style_name, cell_style))
while len(related_styles) > 0:
# unzip related styles to children and parents
children, parents = zip(*related_styles)
independent_styles = set(parents) - set(children)
for relation in related_styles[:]:
child, parent = relation
if parent in independent_styles:
child_style = styles[child]
styles[child] = styles[parent] | child_style
related_styles.remove(relation)
# TODO: multiple print ranges? 😔
print_range = table.getAttribute("printranges")
if print_range:
min_rc, max_rc = [a1_to_rc(cell.rsplit(".", 1)[1]) for cell in print_range.split(":")]
else:
# fallback if print range is not defined
n_rows = len(row_heights)
n_cols = len(column_widths)
n_cells = len(row_heights) * len(column_widths)
cells_limit = 10000
if n_cells >= cells_limit:
raise Exception(
f"You were about to build a very big table with number of cells more than {cells_limit}.\n"
f"In fact it is {n_rows} rows x {n_cols} cols = {n_cells} cells \n"
"and the operation was stopped to prevent system freeze.\n"
"Please define print range in .ods file to proceede\n"
"(needed to make sure printed table will have reasonable size)."
)
min_rc, max_rc = (0, 0), (1048576, 16384)
min_row, min_col = min_rc
max_row, max_col = max_rc
# draw table
y = self.margin
for tri, tr in enumerate(table.getElementsByType(TableRow)):
x = self.margin
height = 6
tdi = 0
for td in tr.getElementsByType(TableCell):
repeat = td.getAttribute("numbercolumnsrepeated")
repeat = int(repeat) if repeat else 1
for i in range(0, repeat):
width = column_widths[tdi]
self.svg.add(
self.svg.rect(
insert=(x, y),
size=(width, height),
style="fill: #ffffff; stroke-width:.125; stroke: #000000;",
tri = 0
stop_iterating_over_rows = False
# TODO: row spans support?
for tr in table.getElementsByType(TableRow):
if stop_iterating_over_rows:
break
row_repeat = tr.getAttribute("numberrowsrepeated")
row_repeat = int(row_repeat) if row_repeat else 1
for i_row_repeat in range(row_repeat):
if tri < min_row:
tri += 1
continue
elif tri > max_row:
stop_iterating_over_rows = True
break
x = self.margin
height = row_heights[tri]
tdi = 0
stop_iterating_over_columns = False
for td in tr.getElementsByType(TableCell):
if stop_iterating_over_columns:
break
column_span = td.getAttribute("numbercolumnsspanned")
column_span = int(column_span) if column_span else 1
col_repeat = td.getAttribute("numbercolumnsrepeated")
col_repeat = int(col_repeat) if col_repeat else 1
# figuring text alignment
cell_style = self.get_style(td.getAttribute("stylename"), styles)
# drawing cells and text
for i_col_repeat in range(col_repeat):
start_tdi = tdi
end_tdi = tdi + int(column_span) - 1
# if the entire span is beyond print range => continue
# if only part then keeping that part
if start_tdi < min_col:
if end_tdi < min_col:
tdi += column_span
continue
else:
start_tdi = min_col
# stop if start column is beyond print range
if start_tdi > max_col:
stop_iterating_over_columns = True
break
# making sure last column won't go beyond the print range
if end_tdi > max_col:
end_tdi = max_col
width = sum(column_widths[start_tdi : end_tdi + 1])
col_style = self.get_style(column_styles[tdi], styles)
final_cell_style = cell_style or col_style
background_color = final_cell_style.get("background-color", "#ffffff")
self.svg.add(
self.svg.rect(
insert=(x, y),
size=(width, height),
style=f"fill: {background_color}; stroke-width:.125; stroke: #000000;",
)
)
)
value = td.getElementsByType(P)
if value:
self.add_text(value[0], x + self.padding, y + self.padding)
x += width
tdi += 1
y += height
total_width = sum(column_widths) + (self.margin * 2)
p_tags = td.getElementsByType(P)
text_color = final_cell_style.get("color", None)
box_alignment = self.get_box_alignment(final_cell_style)
wrap_text = final_cell_style.get("wrap-option", None) == "wrap"
bold_text = final_cell_style.get("font-weight", None) == "bold"
italic_text = final_cell_style.get("font-style", None) == "italic"
# NOTE: very naive since we're scaling text proportionally
font_size = (
float(final_cell_style.get("font-size", f"{FONT_SIZE_PT}pt")[:-2])
/ FONT_SIZE_PT
* FONT_SIZE
)
if p_tags:
# figuring text position based on alignment
text_position = [0.0, 0.0]
if box_alignment.endswith("left"):
text_position[0] = x + self.padding
elif box_alignment.endswith("middle") or box_alignment == "center":
text_position[0] = x + width / 2
elif box_alignment.endswith("right"):
text_position[0] = x + width - self.padding
if box_alignment.startswith("top"):
text_position[1] = y + self.padding
elif box_alignment.startswith("middle") or box_alignment == "center":
text_position[1] = y + height / 2
elif box_alignment.startswith("bottom"):
text_position[1] = y + height - self.padding
self.add_text(
p_tags,
*text_position,
font_size=font_size,
box_alignment=box_alignment,
wrap_text=wrap_text,
cell_width=width,
bold=bold_text,
italic=italic_text,
text_color=text_color,
)
x += width
tdi += column_span
tri += 1
y += height
total_width = x + self.margin
total_height = y + self.margin
self.svg["width"] = "{}mm".format(total_width)
self.svg["height"] = "{}mm".format(y)
self.svg["viewBox"] = "0 0 {} {}".format(total_width, y)
self.svg["height"] = "{}mm".format(total_height)
self.svg["viewBox"] = "0 0 {} {}".format(total_width, total_height)
self.svg.save(pretty=True)
def add_text(self, text, x, y):
self.svg.add(
self.svg.text(
str(text).upper(),
insert=tuple((x, y)),
**{
"font-size": 4.13,
"font-family": "OpenGost Type B TT",
"text-anchor": "start",
"alignment-baseline": "baseline",
"dominant-baseline": "hanging",
}
)
)
def get_style(self, style_name, styles):
style = styles[style_name] if style_name else {}
return style
def get_box_alignment(self, style):
if style and "vertical-align" in style and style["vertical-align"] != "automatic":
vertical_align = style["vertical-align"]
else:
vertical_align = "bottom"
alignment_translation = {
"center": "middle",
"end": "right",
"start": "left",
}
if style and "text-align" in style and style["text-align"] != "automatic":
horizontal_align = style["text-align"]
horizontal_align = alignment_translation.get(horizontal_align, horizontal_align)
else:
horizontal_align = "left"
if vertical_align == "middle" and horizontal_align == "middle":
box_alignment = "center"
else:
box_alignment = f"{vertical_align}-{horizontal_align}"
return box_alignment
def add_text(
self,
p_tags,
x,
y,
font_size,
box_alignment="bottom-left",
wrap_text=False,
cell_width=100,
bold=False,
italic=False,
text_color=None,
):
"""
Adds text to svg.
Args:
p_tags: list of cell's P tags from odt file
box_alignment: alignment of text in box
wrap_text: if True, text will be wrapped to fit in cell
cell_width: width of cell, used for wrapping text
"""
text_lines = [str(p).upper() for p in p_tags]
box_alignment_params = SvgWriter.get_box_alignment_parameters(box_alignment)
text_params = {
"font-size": font_size,
"font-family": FONT_FAMILY,
}
if bold:
text_params["font-weight"] = "bold"
if italic:
text_params["font-style"] = "italic"
if text_color:
text_params["fill"] = text_color
if len(text_lines) == 1 and not wrap_text:
text_params.update(box_alignment_params)
text_tag = self.svg.text(text_lines[0], insert=(x, y), **(text_params))
self.svg.add(text_tag)
return
text_tag = self.svg.text("", **(text_params | {"font-size": "0"} | box_alignment_params))
# TODO: should be done in less naive way
# without using magic number for FONT_WIDTH
# currently it might not work for all fonts and font sizes
if wrap_text:
wrapped_lines = []
for line in text_lines:
wrapped_line = wrap(line, width=int(cell_width // FONT_WIDTH(font_size)), break_long_words=False)
wrapped_lines.extend(wrapped_line)
else:
wrapped_lines = text_lines
for line_number, text_line in enumerate(wrapped_lines[::-1]):
# position has to be inserted at tspan to avoid x offset between tspans
tspan = self.svg.tspan(text_line, insert=(x, y), **text_params)
# doing it here and not in tspan constructor because constructor adds unnecessary spaces
tspan.update({"dy": f"-{line_number}em"})
text_tag.add(tspan)
self.svg.add(text_tag)
def convert_to_mm(self, value):
# XSL is what defines the units of measurements in ODF
@@ -16,10 +16,200 @@
# 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/>.
import bgl
from mathutils import Matrix
from gpu.types import GPUShader
from gpu_extras.batch import batch_for_shader
import gpu
from mathutils import Vector
# NOTES:
# Since Metal doesn't support geometry shaders we stick to builtin shaders
# and generate all geometry data in python before passing it to the shader.
# This way was considered to be the most reliable atm.
# More: https://blender.stackexchange.com/questions/291674/migrating-geometry-shaders-to-metal
#
# BGL deprecation:
# since `bgl` is deprecated, creating smoothing lines became tricky
# Notes for creating shaders with smoothed lines:
# in geom shader - use triangle_strip, DEFAULT_SETUP, do_edge_verts or do_vertex to emit vertices
# in frag shader - use lineWidth uniform, smoothline flaot in, smoothing shader code from base shader
# mind the vertex limit since emitting vertices for smoothed lines produces twice as much vertices
BASE_DEF_GLSL = """
#define PI 3.141592653589793
#define MAX_POINTS 64
#define CIRCLE_SEGS 12
#define SMOOTH_WIDTH 1.0
#define lineSmooth true
"""
BASE_LIB_GLSL = """
// TODO: redefine as macor instead
uniform vec2 winsize;
uniform float lineWidth;
#define half_winsize (winsize / 2)
// convert camera to window
#define C2W(v) vec4(v.x * half_winsize.x / v.w, v.y * half_winsize.y / v.w, v.z / v.w, 1)
// convert window to camera
#define W2C(v) vec4(v.x * v.w / half_winsize.x, v.y * v.w / half_winsize.y, v.z * v.w, 1)
void emitSegment(vec4 p0, vec4 p1) {
gl_Position = p0;
EmitVertex();
gl_Position = p1;
EmitVertex();
EndPrimitive();
}
void emitTriangle(vec4 p1, vec4 p2, vec4 p3) {
gl_Position = p1;
EmitVertex();
gl_Position = p2;
EmitVertex();
gl_Position = p3;
EmitVertex();
EndPrimitive();
}
#define matCLIP2WIN() vec4(winsize.x/2, winsize.y/2, 1, 1)
#define CLIP2WIN(v) (clip2win * (v) / (v).w)
#define matWIN2CLIP() vec4(2/winsize.x, 2/winsize.y, 1, 1)
#define WIN2CLIP(v) (win2clip * (v) * (v).w)
#define DEFAULT_SETUP() vec4 clip2win = matCLIP2WIN(), win2clip = matWIN2CLIP(); vec2 EDGE_DIR
out float smoothline;
void arrow_head(in vec4 dir, in float size, in float angle, out vec4 head[3]) {
vec4 nose = dir * size;
float c = cos(angle), s = sin(angle);
head[0] = nose;
head[1] = vec4(mat2(c, -s, +s, c) * nose.xy, 0, 0);
head[2] = vec4(mat2(c, +s, -s, c) * nose.xy, 0, 0);
}
void circle_head(in float size, out vec4 head[CIRCLE_SEGS]) {
float angle_d = PI * 2 / CIRCLE_SEGS;
for(int i = 0; i<CIRCLE_SEGS; i++) {
float angle = angle_d * i;
head[i] = vec4(cos(angle), sin(angle), 0, 0) * size;
}
}
bool check_counterclockwise(in vec4 A, in vec4 B, in vec4 C) {
return (C.y-A.y) * (B.x-A.x) > (B.y-A.y) * (C.x-A.x);
}
void angle_circle_head(
in vec4 circle_start, in float circle_angle,
in bool counterclockwise,
out vec4 head[CIRCLE_SEGS+1], out float angle_segs) {
// 1 added to CIRCLE_SEGS because we're number of vertices
// for n segments is n+1
float angle_d;
angle_d = PI * 2 / CIRCLE_SEGS; // 30d
// need to bottom clamp it to 1, otherwise it causes Blender crash at extruding the curve
angle_segs = max(1, ceil(circle_angle / angle_d));
angle_d = circle_angle / angle_segs;
for(int i = 0; i < (angle_segs + 1); i++) {
float angle = angle_d * i;
if (counterclockwise) {
head[i] = vec4(
circle_start.x * cos(-angle) + circle_start.y * sin(-angle),
circle_start.x * -sin(-angle) + circle_start.y * cos(-angle),
0, 0
);
} else {
head[i] = vec4(
circle_start.x * cos(angle) + circle_start.y * sin(angle),
circle_start.x * -sin(angle) + circle_start.y * cos(angle),
0, 0
);
}
}
}
void cross_head(in vec4 dir, in float size, out vec4 head[3]) {
vec4 nose = dir * size;
float c = cos(PI/2), s = sin(PI/2);
head[0] = nose;
head[1] = vec4(mat2(c, -s, +s, c) * nose.xy, 0, 0);
head[2] = vec4(mat2(c, +s, -s, c) * nose.xy, 0, 0);
}
// do_vertex_util is custom EmitVertex method to support line smoothing
// `e` - edge xy direction in win/clip space (directions are invariant in both spaces)
#define do_vertex(pos, e) (do_vertex_util(pos, vec2(-(e).y, (e).x) / winsize.xy))
#define do_vertex_win(pos, e) ( do_vertex( WIN2CLIP( pos ), e ) )
// if vertex is shared by two segments of the line still need to emit it twice
// to avoid smoothing artifacts
// don't forget to initialize `vec2 EDGE_DIR` for macro to work
// `pos0` / `pos1` - vertex position in clip space
#define do_edge_verts(pos0, pos1) ( EDGE_DIR = normalize( ( (pos1) - (pos0) ).xy ), do_vertex( pos0, EDGE_DIR ), do_vertex( pos1, EDGE_DIR) )
#define do_edge_verts_win(pos0, pos1) ( do_edge_verts( WIN2CLIP(pos0), WIN2CLIP(pos1) ) )
void do_vertex_util(vec4 pos, vec2 ofs)
{
float final_line_width = lineWidth + SMOOTH_WIDTH * float(lineSmooth);
ofs *= final_line_width;
smoothline = final_line_width * 0.5;
gl_Position = pos;
gl_Position.xy += ofs * pos.w;
EmitVertex();
smoothline = -final_line_width * 0.5;
gl_Position = pos;
gl_Position.xy -= ofs * pos.w;
EmitVertex();
}
// geometry utils
void triangle_head(in vec4 side, in vec4 dir, in float length, in float width, in float radius, out vec4 head[5]) {
// TODO: radius is unnecessary?
head[0] = side * -radius;
head[1] = side * length * -.5;
head[2] = dir * width;
head[3] = side * length * .5;
head[4] = side * radius;
}
void do_triangle_head(vec4 pos_w, vec4 head[5]) {
DEFAULT_SETUP();
do_edge_verts_win(pos_w + head[0], pos_w + head[1]);
do_edge_verts_win(pos_w + head[1], pos_w + head[2]);
do_edge_verts_win(pos_w + head[2], pos_w + head[3]);
do_edge_verts_win(pos_w + head[3], pos_w + head[4]);
}
void do_circle_head(vec4 pos_w, vec4 head[CIRCLE_SEGS]) {
DEFAULT_SETUP();
for(int i=0; i<CIRCLE_SEGS-1; i++) {
do_edge_verts_win(pos_w + head[i], pos_w + head[i+1]);
EmitVertex();
}
do_edge_verts_win( pos_w + head[CIRCLE_SEGS-1], pos_w + head[0] );
}
"""
def add_verts_sequence(verts, start_i, output_verts, output_edges, closed=False):
"""Add sequence of verts to output lists, returns next vertex index"""
for i, v in enumerate(verts[:-1], start_i):
output_verts.append(v)
output_edges.append((i, i + 1))
output_verts.append(verts[-1])
if closed:
output_edges.append((i + 1, start_i))
return i + 2
def add_offsets(v, offsets):
"""returns list of verts with offsets added"""
return [v + offset for offset in offsets]
class BaseShader:
@@ -28,7 +218,7 @@ class BaseShader:
The Geometry shader works in clipping coords (aftre projecting before division and window scaling).
To make window-scale geometry, vectors should be calculated in window space and than back-projected to clipping spae.
Provide `winSize` uniform vector with halfsize of window, and use W2C and C2W macros.
Provide `half_winsize` uniform vector with halfsize of window, and use W2C and C2W macros.
Replace glsl code in derived classes.
Beware of unused attributes and uniforms: glsl compiler will optimize them out and blender fail with an exception.
@@ -43,9 +233,7 @@ class BaseShader:
TYPE = None # should be LINES|POINTS|etc
DEF_GLSL = """
#define PI 3.141592653589793
"""
DEF_GLSL = BASE_DEF_GLSL
VERT_GLSL = """
uniform mat4 viewMatrix;
@@ -63,84 +251,86 @@ class BaseShader:
"""
# prepended to geom_glsl
LIB_GLSL = """
uniform vec2 winSize;
// convert camera to window
#define C2W(v) vec4(v.x * winSize.x / v.w, v.y * winSize.y / v.w, v.z / v.w, 1)
// convert window to camera
#define W2C(v) vec4(v.x * v.w / winSize.x, v.y * v.w / winSize.y, v.z * v.w, 1)
void emitSegment(vec4 p0, vec4 p1) {
gl_Position = p0;
EmitVertex();
gl_Position = p1;
EmitVertex();
EndPrimitive();
}
void emitTriangle(vec4 p1, vec4 p2, vec4 p3) {
gl_Position = p1;
EmitVertex();
gl_Position = p2;
EmitVertex();
gl_Position = p3;
EmitVertex();
EndPrimitive();
}
"""
LIB_GLSL = BASE_LIB_GLSL
GEOM_GLSL = """
uniform float viewportDrawingScale;
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
void main() {
// default setup for macro to work
vec4 clip2win = matCLIP2WIN();
vec4 win2clip = matWIN2CLIP();
vec2 EDGE_DIR;
vec4 p0 = gl_in[0].gl_Position, p1 = gl_in[1].gl_Position;
do_edge_verts(p0, p1);
EndPrimitive();
}
"""
FRAG_GLSL = """
uniform vec4 color;
uniform float lineWidth;
in float smoothline;
out vec4 fragColor;
void main() {
vec2 co = gl_FragCoord.xy;
fragColor = color;
if (lineSmooth) {
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(smoothline), 0.0, 1.0);
}
}
"""
def __init__(self):
# NB: libcode arg doesn't work
self.prog = GPUShader(
vertexcode=self.VERT_GLSL,
fragcode=self.FRAG_GLSL,
geocode=self.LIB_GLSL + self.GEOM_GLSL,
defines=self.DEF_GLSL,
)
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR")
self.base_shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR")
def get_shader(self):
"""Returns shader for this type"""
return self.line_shader if self.TYPE == "LINES" else self.base_shader
def batch(self, indices=None, **data):
"""Returns automatic GPUBatch filled with provided parameters"""
batch = batch_for_shader(self.prog, self.TYPE, data, indices=indices)
batch.program_set(self.prog)
shader = self.get_shader()
batch = batch_for_shader(shader, self.TYPE, data, indices=indices)
return batch
def bind(self):
self.prog.bind()
"""need to bind shader before changing it's uniforms"""
shader = self.get_shader()
shader.bind()
return shader
def glenable(self):
bgl.glEnable(bgl.GL_BLEND)
bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
bgl.glBlendEquation(bgl.GL_FUNC_ADD)
# bgl.glEnable(bgl.GL_DEPTH_TEST)
# bgl.glDepthFunc(bgl.GL_LEQUAL)
# bgl.glDepthMask(True)
gpu.state.blend_set("ALPHA")
gpu.state.depth_test_set("LESS_EQUAL")
def uniform_region(self, ctx):
shader = self.bind()
region = ctx.region
region3d = ctx.region_data
try:
self.prog.uniform_float("viewMatrix", region3d.perspective_matrix)
except ValueError: # unused uniform
pass
try:
self.prog.uniform_float("winSize", (region.width / 2, region.height / 2))
except ValueError: # unused uniform
pass
uniform_floats = {
"ModelViewProjectionMatrix": region3d.perspective_matrix,
# POLYLINE_UNIFORM_COLOR specific uniforms
"viewportSize": (region.width, region.height),
"lineWidth": 2.5,
}
for name, value in uniform_floats.items():
shader.uniform_float(name, value)
# TODO: add smoothing if this shader is going to be used
# TODO: dead code?
class BaseLinesShader(BaseShader):
"""Draws line segments with gaps around vertices at endpoints"""
@@ -185,7 +375,6 @@ class BaseLinesShader(BaseShader):
def glenable(self):
super().glenable()
bgl.glEnable(bgl.GL_LINE_SMOOTH)
class GizmoShader(BaseShader):
@@ -207,6 +396,7 @@ class GizmoShader(BaseShader):
"""
# TODO: add smoothing if this shader is going to be used
class DotsGizmoShader(GizmoShader):
"""Draws circles of radius 1 around points"""
@@ -263,35 +453,24 @@ class ExtrusionGuidesShader(GizmoShader):
TYPE = "LINES"
DEF_GLSL = (
BaseShader.DEF_GLSL
+ """
#define CROSS_SIZE .5
"""
)
def process_geometry(self, verts):
CROSS_SIZE = 0.5
GEOM_GLSL = """
uniform mat4 ModelViewProjectionMatrix;
p0, p1 = verts
bx = Vector((1, 0, 0)) * CROSS_SIZE
by = Vector((0, 1, 0)) * CROSS_SIZE
layout(lines) in;
layout(line_strip, max_vertices=10) out;
output_verts = []
output_edges = []
out_kwargs = {
"output_verts": output_verts,
"output_edges": output_edges,
}
void main() {
vec4 p0 = gl_in[0].gl_Position, p1 = gl_in[1].gl_Position;
vec4 p0w = C2W(p0), p1w = C2W(p1);
start_i = 0
start_i = add_verts_sequence(add_offsets(p0, [-bx, bx]), start_i, **out_kwargs)
start_i = add_verts_sequence(add_offsets(p0, [-by, by]), start_i, **out_kwargs)
start_i = add_verts_sequence(add_offsets(p1, [-bx, bx]), start_i, **out_kwargs)
start_i = add_verts_sequence(add_offsets(p1, [-by, by]), start_i, **out_kwargs)
emitSegment(p0, p1);
vec4 bx = ModelViewProjectionMatrix[0] * CROSS_SIZE;
vec4 by = ModelViewProjectionMatrix[1] * CROSS_SIZE;
emitSegment(p0 - bx, p0 + bx);
emitSegment(p0 - by, p0 + by);
emitSegment(p1 - bx, p1 + bx);
emitSegment(p1 - by, p1 + by);
}
"""
def glenable(self):
super().glenable()
bgl.glEnable(bgl.GL_LINE_SMOOTH)
return output_verts, output_edges
@@ -17,15 +17,23 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import os
import bpy
import uuid
import shutil
import ntpath
import pystache
import urllib.parse
import xml.etree.ElementTree as ET
import blenderbim.tool as tool
import ifcopenshell.util.geolocation
from shutil import copy
from xml.dom import minidom
from mathutils import Vector
import re
VIEW_TITLE_OFFSET_Y = 5
DEFAULT_POSITION = Vector((30, 30))
SVG = "{http://www.w3.org/2000/svg}"
XLINK = "{http://www.w3.org/1999/xlink}"
class SheetBuilder:
@@ -33,22 +41,29 @@ class SheetBuilder:
self.data_dir = None
self.scale = "NTS"
def create(self, sheet_path, titleblock_name):
def create(self, layout_path, titleblock_name):
root = ET.Element("svg")
root.attrib["xmlns"] = "http://www.w3.org/2000/svg"
root.attrib["xmlns:xlink"] = "http://www.w3.org/1999/xlink"
root.attrib["id"] = "root"
root.attrib["version"] = "1.1"
view_root = ET.parse(
os.path.join(self.data_dir, "templates", "titleblocks", titleblock_name + ".svg")
).getroot()
sheet_dir = os.path.dirname(layout_path)
ootb_titleblock_path = os.path.join(self.data_dir, "templates", "titleblocks", titleblock_name + ".svg")
titleblock_path = tool.Ifc.resolve_uri(tool.Drawing.get_default_titleblock_path(titleblock_name))
os.makedirs(sheet_dir, exist_ok=True)
os.makedirs(os.path.dirname(titleblock_path), exist_ok=True)
if not os.path.exists(titleblock_path):
shutil.copy(ootb_titleblock_path, titleblock_path)
view_root = ET.parse(titleblock_path).getroot()
view_width = self.convert_to_mm(view_root.attrib.get("width"))
view_height = self.convert_to_mm(view_root.attrib.get("height"))
view = ET.SubElement(root, "g")
view.attrib["data-type"] = "titleblock"
titleblock = ET.SubElement(view, "image")
titleblock.attrib["xlink:href"] = "../templates/titleblocks/" + titleblock_name + ".svg"
titleblock.attrib["xlink:href"] = os.path.relpath(titleblock_path, sheet_dir)
titleblock.attrib["x"] = "0"
titleblock.attrib["y"] = "0"
titleblock.attrib["width"] = str(view_width)
@@ -58,26 +73,25 @@ class SheetBuilder:
root.attrib["height"] = "{}mm".format(view_height)
root.attrib["viewBox"] = "0 0 {} {}".format(view_width, view_height)
with open(sheet_path, "w") as f:
with open(layout_path, "w") as f:
f.write(minidom.parseString(ET.tostring(root)).toprettyxml(indent=" "))
def add_drawing(self, reference, drawing, sheet):
filename = drawing.Name
sheet_name = os.path.splitext(os.path.basename(tool.Drawing.get_document_uri(sheet)))[0]
sheet_dir = os.path.join(self.data_dir, "sheets")
drawing_dir = os.path.join(self.data_dir, "diagrams")
sheet_path = os.path.join(sheet_dir, sheet_name + ".svg")
drawing_path = os.path.join(drawing_dir, filename + ".svg")
underlay_path = os.path.join(drawing_dir, filename + "-underlay.png")
layout_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
layout_dir = os.path.dirname(layout_path)
if not os.path.isfile(sheet_path):
drawing_path = tool.Drawing.get_document_uri(tool.Drawing.get_drawing_reference(drawing))
underlay_path = os.path.splitext(drawing_path)[0] + "-underlay.png"
if not os.path.exists(layout_path) or not os.path.exists(drawing_path):
raise FileNotFoundError
ET.register_namespace("", "http://www.w3.org/2000/svg")
ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")
sheet_tree = ET.parse(sheet_path)
sheet_root = sheet_tree.getroot()
layout_tree = ET.parse(layout_path)
layout_root = layout_tree.getroot()
view_tree = ET.parse(drawing_path)
view_root = view_tree.getroot()
@@ -85,103 +99,160 @@ class SheetBuilder:
# The view is placed into a group with a background image element.
# Although the foreground SVG already has a background, it is duplicated
# here to accommodate browsers which do not nest images.
view = ET.SubElement(sheet_root, "g")
view = ET.SubElement(layout_root, "g")
view.attrib["data-type"] = "drawing"
view.attrib["data-id"] = str(reference.id())
view.attrib["data-drawing"] = drawing.GlobalId
view_width = self.convert_to_mm(view_root.attrib.get("width"))
view_height = self.convert_to_mm(view_root.attrib.get("height"))
# add background
if os.path.isfile(underlay_path):
background = ET.SubElement(view, "image")
background.attrib["data-type"] = "background"
background.attrib["xlink:href"] = os.path.relpath(underlay_path, sheet_dir)
background.attrib["x"] = "30"
background.attrib["y"] = "30"
background.attrib["xlink:href"] = os.path.relpath(underlay_path, layout_dir)
background.attrib["x"] = str(DEFAULT_POSITION.x)
background.attrib["y"] = str(DEFAULT_POSITION.y)
background.attrib["width"] = str(view_width)
background.attrib["height"] = str(view_height)
# add foreground
if os.path.isfile(drawing_path):
foreground = ET.SubElement(view, "image")
foreground.attrib["data-type"] = "foreground"
foreground.attrib["xlink:href"] = os.path.relpath(drawing_path, sheet_dir)
foreground.attrib["x"] = "30"
foreground.attrib["y"] = "30"
foreground.attrib["xlink:href"] = os.path.relpath(drawing_path, layout_dir)
foreground.attrib["x"] = str(DEFAULT_POSITION.x)
foreground.attrib["y"] = str(DEFAULT_POSITION.y)
foreground.attrib["width"] = str(view_width)
foreground.attrib["height"] = str(view_height)
self.add_view_title(30, view_height + 35, view)
sheet_tree.write(sheet_path)
self.add_view_title(
DEFAULT_POSITION.x, view_height + DEFAULT_POSITION.y + VIEW_TITLE_OFFSET_Y, view, layout_dir
)
layout_tree.write(layout_path)
def update_sheet_drawing_sizes(self, sheet):
ET.register_namespace("", "http://www.w3.org/2000/svg")
layout_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
layout_tree = ET.parse(layout_path)
layout_root = layout_tree.getroot()
ifc_file = tool.Ifc.get()
# iterate over all drawings in the sheet
drawings_views = layout_root.findall(f'{SVG}g[@data-type="drawing"]')
for drawing_view in drawings_views:
# find drawing in ifc file to get the drawing dimensions
drawing = ifc_file.by_guid(drawing_view.attrib.get("data-drawing"))
drawing_path = tool.Drawing.get_document_uri(tool.Drawing.get_drawing_reference(drawing))
drawing_tree = ET.parse(drawing_path)
drawing_root = drawing_tree.getroot()
view_width = self.convert_to_mm(drawing_root.attrib.get("width"))
view_height = self.convert_to_mm(drawing_root.attrib.get("height"))
foreground = drawing_view.find(f'.//{SVG}image[@data-type="foreground"]')
height = float(foreground.attrib["height"])
width = float(foreground.attrib["width"])
readjust = Vector((width - view_width, height - view_height)) / 2
for image in drawing_view.findall(f"{SVG}image"):
x = float(image.attrib["x"])
y = float(image.attrib["y"])
if image.attrib["data-type"] == "view-title":
image.attrib["x"] = str(x - readjust.x)
image.attrib["y"] = str(y - readjust.y)
else:
image.attrib["x"] = str(x + readjust.x)
image.attrib["y"] = str(y + readjust.y)
image.attrib["width"] = str(view_width)
image.attrib["height"] = str(view_height)
layout_tree.write(layout_path)
def remove_drawing(self, reference, sheet):
ET.register_namespace("", "http://www.w3.org/2000/svg")
sheet_path = tool.Drawing.get_document_uri(sheet)
sheet_tree = ET.parse(sheet_path)
sheet_root = sheet_tree.getroot()
layout_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
layout_tree = ET.parse(layout_path)
layout_root = layout_tree.getroot()
for g in sheet_root.findall("{http://www.w3.org/2000/svg}g"):
for g in layout_root.findall("{http://www.w3.org/2000/svg}g"):
if g.attrib.get("data-id") == str(reference.id()):
sheet_root.remove(g)
layout_root.remove(g)
break
sheet_tree.write(sheet_path)
layout_tree.write(layout_path)
def add_schedule(self, reference, schedule, sheet):
view_path = tool.Drawing.get_document_uri(schedule)
def add_document(self, reference, schedule, sheet):
view_path = tool.Drawing.get_path_with_ext(tool.Drawing.get_document_uri(schedule), "svg")
if not os.path.exists(view_path):
tool.Drawing.create_svg_schedule(schedule)
schedule_name = os.path.splitext(os.path.basename(view_path))[0]
sheet_path = tool.Drawing.get_document_uri(sheet)
layout_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
layout_dir = os.path.dirname(layout_path)
ET.register_namespace("", "http://www.w3.org/2000/svg")
ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")
sheet_tree = ET.parse(sheet_path)
sheet_root = sheet_tree.getroot()
layout_tree = ET.parse(layout_path)
layout_root = layout_tree.getroot()
view_tree = ET.parse(view_path)
view_root = view_tree.getroot()
view_width = self.convert_to_mm(view_root.attrib.get("width"))
view_height = self.convert_to_mm(view_root.attrib.get("height"))
view = ET.SubElement(sheet_root, "g")
view = ET.SubElement(layout_root, "g")
view.attrib["data-type"] = "schedule"
view.attrib["data-id"] = str(reference.id())
view.attrib["data-schedule"] = str(schedule.id())
foreground = ET.SubElement(view, "image")
foreground.attrib["data-type"] = "table"
foreground.attrib["xlink:href"] = "../schedules/{}.svg".format(schedule_name)
foreground.attrib["x"] = "30"
foreground.attrib["y"] = "30"
foreground.attrib["xlink:href"] = os.path.relpath(view_path, layout_dir)
foreground.attrib["x"] = str(DEFAULT_POSITION.x)
foreground.attrib["y"] = str(DEFAULT_POSITION.y)
foreground.attrib["width"] = str(view_width)
foreground.attrib["height"] = str(view_height)
self.add_view_title(30, view_height + 35, view)
sheet_tree.write(sheet_path)
self.add_view_title(
DEFAULT_POSITION.x, view_height + DEFAULT_POSITION.y + VIEW_TITLE_OFFSET_Y, view, layout_dir
)
layout_tree.write(layout_path)
def add_view_title(self, x, y, parent):
title_tree = ET.parse(os.path.join(self.data_dir, "templates", "view-title.svg"))
def add_view_title(self, x, y, parent, layout_dir):
title_path = os.path.join(layout_dir, "assets", "view-title.svg")
os.makedirs(os.path.dirname(title_path), exist_ok=True)
if not os.path.exists(title_path):
ootb_title = os.path.join(bpy.context.scene.BIMProperties.data_dir, "assets", "view-title.svg")
shutil.copy(ootb_title, title_path)
title_tree = ET.parse(title_path)
title_root = title_tree.getroot()
title = ET.SubElement(parent, "image")
title.attrib["data-type"] = "view-title"
title.attrib["xlink:href"] = "../templates/view-title.svg"
title.attrib["xlink:href"] = os.path.relpath(title_path, layout_dir)
title.attrib["x"] = str(x)
title.attrib["y"] = str(y)
title.attrib["width"] = str(self.convert_to_mm(title_root.attrib.get("width")))
title.attrib["height"] = str(self.convert_to_mm(title_root.attrib.get("height")))
def build(self, sheet):
sheet_name = os.path.splitext(os.path.basename(tool.Drawing.get_document_uri(sheet)))[0]
os.makedirs(os.path.join(self.data_dir, "build", sheet_name), exist_ok=True)
self.references = {"SHEET": None, "RASTER": []}
sheet_path = os.path.join(self.data_dir, "sheets", f"{sheet_name}.svg")
layout_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
self.layout_dir = os.path.dirname(layout_path)
sheet_path = tool.Ifc.resolve_uri(tool.Drawing.get_default_sheet_path(sheet[0], sheet.Name))
self.sheets_dir = os.path.dirname(sheet_path)
os.makedirs(self.sheets_dir, exist_ok=True)
ET.register_namespace("", "http://www.w3.org/2000/svg")
ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")
tree = ET.parse(sheet_path)
tree = ET.parse(layout_path)
root = tree.getroot()
self.defs = ET.Element("defs")
@@ -189,11 +260,15 @@ class SheetBuilder:
self.build_titleblock(root, sheet)
self.build_drawings(root, sheet)
self.build_schedules(root)
self.build_schedules(root, sheet)
with open(os.path.join(self.data_dir, "build", sheet_name, f"{sheet_name}.svg"), "wb") as output:
with open(sheet_path, "wb") as output:
tree.write(output)
self.references["SHEET"] = sheet_path
return self.references
def build_titleblock(self, root, sheet):
titleblock = root.findall('{http://www.w3.org/2000/svg}g[@data-type="titleblock"]')[0]
image = titleblock.findall("{http://www.w3.org/2000/svg}image")[0]
@@ -207,10 +282,61 @@ class SheetBuilder:
titleblock.append(g)
titleblock.remove(image)
def build_drawings(self, root, sheet):
sheet_name = os.path.splitext(os.path.basename(tool.Drawing.get_document_uri(sheet)))[0]
def ensure_drawing_unique_styles(self, svg, drawing_id):
"""ensures all drawing's classes and ids will be unique for the whole sheet
by adding `drawing_id` based prefix
"""
prefix = f"d{drawing_id}" # just number doesn't work
# add .prefix class to all css selectors
style = svg.find(f"{SVG}defs/{SVG}style")
style_data = style.text
text = ""
brackets_level = 0
for l in style_data:
if l == "{":
if brackets_level == 0:
cur_line = text.splitlines()[-1]
text = text[: -len(cur_line)]
css_selectors = []
# making sure cases like "text, tspan" will be
# converted to "text.prefix, tspan.prefix"
for css_selector in cur_line.split(","):
css_selector = f"{css_selector.strip()}.{prefix}"
css_selectors.append(css_selector)
text += ", ".join(css_selectors) + " "
brackets_level += 1
elif l == "}":
brackets_level -= 1
text += l
# replace urls url(#marker) with url(#prefix-marker)
# since url(#marker.prefix) doesn't seem to work
text = re.sub(r"url\(#([^\)]+)\)", rf"url(#{prefix}-\1)", text)
style.text = text
for svg_element in svg.findall(f".//*"):
if svg_element.tag in (f"{SVG}style", f"{SVG}svg"):
continue
attrib = svg_element.attrib
# add "prefix-" to all ids
if "id" in attrib:
attrib["id"] = f"{prefix}-{attrib['id']}"
# add class "prefix" to all classes
if "class" in attrib:
attrib["class"] += f" {prefix}"
if svg_element.tag == f"{SVG}use":
href_attrib = f"{XLINK}href"
if href_attrib in attrib:
href = attrib[href_attrib]
if href.startswith("#"):
attrib[href_attrib] = f"#{prefix}-{href[1:]}"
return svg
def build_drawings(self, root, sheet):
for view in root.findall('{http://www.w3.org/2000/svg}g[@data-type="drawing"]'):
drawing_id = int(view.attrib["data-id"])
reference = tool.Ifc.get().by_id(int(view.attrib["data-id"]))
drawing = tool.Ifc.get().by_id(view.attrib["data-drawing"])
@@ -229,15 +355,20 @@ class SheetBuilder:
view_title = image
if foreground is not None:
view.append(self.parse_embedded_svg(foreground, {}))
svg = self.parse_embedded_svg(foreground, {})
svg = self.ensure_drawing_unique_styles(svg, drawing_id)
view.append(svg)
if background is not None:
background_path = os.path.join(self.data_dir, "sheets", self.get_href(background))
copy(background_path, os.path.join(self.data_dir, "build", sheet_name))
background_path = os.path.join(self.layout_dir, self.get_href(background))
raster_path = os.path.join(self.sheets_dir, os.path.basename(background_path))
shutil.copy(background_path, raster_path)
self.references["RASTER"].append(raster_path)
if view_title is not None:
foreground_path = self.get_href(foreground)
data = reference.get_info()
data.update({"Sheet" + k: v for k, v in sheet.get_info().items()})
if not data["Name"]:
data["Name"] = ntpath.basename(foreground_path)[0:-4]
data["Scale"] = tool.Drawing.get_drawing_human_scale(drawing)
@@ -246,7 +377,7 @@ class SheetBuilder:
for image in images:
view.remove(image)
def build_schedules(self, root):
def build_schedules(self, root, sheet):
for view in root.findall('{http://www.w3.org/2000/svg}g[@data-type="schedule"]'):
reference = tool.Ifc.get().by_id(int(view.attrib["data-id"]))
schedule = tool.Ifc.get().by_id(int(view.attrib["data-schedule"]))
@@ -268,6 +399,7 @@ class SheetBuilder:
if view_title is not None:
path = self.get_href(table)
data = reference.get_info()
data.update({"Sheet" + k: v for k, v in sheet.get_info().items()})
if not data["Name"]:
data["Name"] = schedule.Name or "Unnamed"
view.append(self.parse_embedded_svg(view_title, data))
@@ -298,7 +430,7 @@ class SheetBuilder:
self.defs.append(clip_path)
svg_path = self.get_href(image)
with open(os.path.join(self.data_dir, "sheets", svg_path), "r") as template:
with open(os.path.join(self.layout_dir, svg_path), "r") as template:
embedded = ET.fromstring(pystache.render(template.read(), data))
# viewBox should not be nested
embedded.attrib["viewBox"] = ""
@@ -314,6 +446,39 @@ class SheetBuilder:
group.append(child)
return group
def change_titleblock(self, sheet, titleblock_name):
ootb_titleblock_path = os.path.join(self.data_dir, "templates", "titleblocks", titleblock_name + ".svg")
titleblock_path = tool.Drawing.get_default_titleblock_path(titleblock_name)
sheet_path = tool.Drawing.get_document_uri(sheet, "LAYOUT")
sheet_dir = os.path.dirname(sheet_path)
os.makedirs(sheet_dir, exist_ok=True)
os.makedirs(os.path.dirname(titleblock_path), exist_ok=True)
if not os.path.exists(titleblock_path):
shutil.copy(ootb_titleblock_path, titleblock_path)
ET.register_namespace("", "http://www.w3.org/2000/svg")
ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")
view_root = ET.parse(ootb_titleblock_path).getroot()
view_width = self.convert_to_mm(view_root.attrib.get("width"))
view_height = self.convert_to_mm(view_root.attrib.get("height"))
sheet_tree = ET.parse(sheet_path)
root = sheet_tree.getroot()
titleblock = sheet_tree.findall('{http://www.w3.org/2000/svg}g[@data-type="titleblock"]')[0]
image = titleblock.findall("{http://www.w3.org/2000/svg}image[@{http://www.w3.org/1999/xlink}href]")[0]
image.attrib["{http://www.w3.org/1999/xlink}href"] = os.path.relpath(titleblock_path, sheet_dir)
image.attrib["width"] = str(view_width)
image.attrib["height"] = str(view_height)
root.attrib["width"] = "{}mm".format(view_width)
root.attrib["height"] = "{}mm".format(view_height)
root.attrib["viewBox"] = "0 0 {} {}".format(view_width, view_height)
sheet_tree.write(sheet_path)
def convert_to_mm(self, value):
# CSS is what defines these possibilities
# https://www.w3.org/TR/SVG/refs.html#ref-css-values-3
File diff suppressed because it is too large Load Diff
@@ -20,7 +20,14 @@ import bpy
import blenderbim.bim.helper
import blenderbim.tool as tool
from bpy.types import Panel
from blenderbim.bim.module.drawing.data import ProductAssignmentsData, TextData, SheetsData, SchedulesData, DrawingsData
from blenderbim.bim.module.drawing.data import (
ProductAssignmentsData,
SheetsData,
DocumentsData,
DrawingsData,
DecoratorData,
)
from blenderbim.bim.module.drawing.prop import ANNOTATION_TYPES_DATA
class BIM_PT_camera(Panel):
@@ -56,29 +63,31 @@ class BIM_PT_camera(Panel):
row.prop(props, "has_annotation", icon="MOD_EDGESPLIT")
row.prop(dprops, "should_use_annotation_cache", text="", icon="FILE_REFRESH")
row = layout.row()
row.prop(props, "calculate_shapely_surfaces")
row = layout.row()
row.prop(props, "calculate_svgfill_surfaces")
row = layout.row()
row.prop(dprops, "should_extract")
row = layout.row()
row.prop(props, "is_nts")
row = layout.row()
row.operator("bim.resize_text")
row = layout.row()
row.prop(props, "raster_x")
row = layout.row()
row.prop(props, "raster_y")
row = layout.row()
row = layout.row(align=True)
row.prop(props, "diagram_scale")
row.prop(props, "is_nts", text="", icon="MOD_EDGESPLIT")
if props.diagram_scale == "CUSTOM":
row = layout.row()
row.prop(props, "custom_diagram_scale")
row = layout.row(align=True)
row.prop(props, "custom_scale_numerator", text="Custom Scale")
row.prop(props, "custom_scale_denominator", text="")
row = layout.row(align=True)
row.operator("bim.create_drawing", text="Create Drawing", icon="OUTPUT")
op = row.operator("bim.open_view", icon="URL", text="")
op = row.operator("bim.open_drawing", icon="URL", text="")
op.view = context.active_object.name.split("/")[1]
@@ -100,41 +109,53 @@ class BIM_PT_drawing_underlay(Panel):
layout.use_property_split = True
dprops = context.scene.DocProperties
props = context.active_object.data.BIMCameraProperties
drawing_index_is_valid = props.active_drawing_style_index < len(dprops.drawing_styles)
if not DrawingsData.is_loaded:
DrawingsData.load()
drawing_pset_data = DrawingsData.data["active_drawing_pset_data"]
row = layout.row(align=True)
row.operator("bim.add_drawing_style")
current_shading_style = drawing_pset_data.get("CurrentShadingStyle", None)
if current_shading_style is None:
row.label(text="Current style is not set.")
else:
row.label(text="Current Shading Style:")
row.label(text=current_shading_style)
row.operator("bim.add_drawing_style", icon="ADD", text="")
if drawing_index_is_valid:
row.operator("bim.remove_drawing_style", icon="X", text="").index = props.active_drawing_style_index
row.operator("bim.reload_drawing_styles", icon="FILE_REFRESH", text="")
if dprops.drawing_styles:
layout.template_list("BIM_UL_generic", "", dprops, "drawing_styles", props, "active_drawing_style_index")
if not dprops.drawing_styles:
return
layout.template_list("BIM_UL_generic", "", dprops, "drawing_styles", props, "active_drawing_style_index")
if props.active_drawing_style_index < len(dprops.drawing_styles):
drawing_style = dprops.drawing_styles[props.active_drawing_style_index]
if not drawing_index_is_valid:
return
drawing_style = dprops.drawing_styles[props.active_drawing_style_index]
row = layout.row(align=True)
row.prop(drawing_style, "name")
row.operator("bim.remove_drawing_style", icon="X", text="").index = props.active_drawing_style_index
row = layout.row(align=True)
row.prop(drawing_style, "name")
row = layout.row()
row.prop(drawing_style, "render_type")
row = layout.row(align=True)
row.prop(drawing_style, "vector_style")
row.operator("bim.edit_vector_style", text="", icon="GREASEPENCIL")
row = layout.row(align=True)
row.prop(drawing_style, "include_query")
row = layout.row(align=True)
row.prop(drawing_style, "exclude_query")
row = layout.row()
row.prop(drawing_style, "render_type")
row = layout.row(align=True)
row.prop(drawing_style, "include_query")
row = layout.row(align=True)
row.prop(drawing_style, "exclude_query")
row = layout.row()
row.operator("bim.add_drawing_style_attribute")
row = layout.row()
row.operator("bim.add_drawing_style_attribute")
for index, attribute in enumerate(drawing_style.attributes):
row = layout.row(align=True)
row.prop(attribute, "name", text="")
row.operator("bim.remove_drawing_style_attribute", icon="X", text="").index = index
for index, attribute in enumerate(drawing_style.attributes):
row = layout.row(align=True)
row.prop(attribute, "name", text="")
row.operator("bim.remove_drawing_style_attribute", icon="X", text="").index = index
row = layout.row(align=True)
row.operator("bim.save_drawing_style")
row.operator("bim.activate_drawing_style")
row = layout.row(align=True)
row.operator("bim.save_drawing_style")
row.operator("bim.activate_drawing_style")
class BIM_PT_drawings(Panel):
@@ -152,6 +173,10 @@ class BIM_PT_drawings(Panel):
if not DrawingsData.is_loaded:
DrawingsData.load()
if not DrawingsData.data["has_saved_ifc"]:
draw_project_not_saved_ui(self)
return
self.props = context.scene.DocProperties
if not self.props.is_editing_drawings:
@@ -179,9 +204,11 @@ class BIM_PT_drawings(Panel):
).drawing = active_drawing.ifc_definition_id
col = row.column()
col.alignment = "RIGHT"
op = row.operator("bim.open_view", icon="URL", text="")
op = row.operator("bim.select_all_drawings", icon="SELECT_SUBTRACT", text="")
op = row.operator("bim.open_drawing", icon="URL", text="")
op.view = active_drawing.name
op = row.operator("bim.activate_view", icon="OUTLINER_OB_CAMERA", text="")
row.operator("bim.activate_model", icon="VIEW3D", text="")
op = row.operator("bim.activate_drawing", icon="OUTLINER_OB_CAMERA", text="")
op.drawing = active_drawing.ifc_definition_id
row.operator("bim.create_drawing", text="", icon="OUTPUT")
self.layout.template_list(
@@ -211,14 +238,18 @@ class BIM_PT_schedules(Panel):
return tool.Ifc.get()
def draw(self, context):
if not SchedulesData.is_loaded:
SchedulesData.load()
if not DocumentsData.is_loaded:
DocumentsData.load()
if not DocumentsData.data["has_saved_ifc"]:
draw_project_not_saved_ui(self)
return
self.props = context.scene.DocProperties
if not self.props.is_editing_schedules:
row = self.layout.row(align=True)
row.label(text=f"{SchedulesData.data['total_schedules']} Schedules Found", icon="LONGDISPLAY")
row.label(text=f"{DocumentsData.data['total_schedules']} Schedules Found", icon="LONGDISPLAY")
row.operator("bim.load_schedules", text="", icon="IMPORT")
return
@@ -242,6 +273,58 @@ class BIM_PT_schedules(Panel):
)
def draw_project_not_saved_ui(self):
row = self.layout.row()
row.label(text="Project Not Yet Saved", icon="ERROR")
row = self.layout.row()
op = row.operator("export_ifc.bim", icon="EXPORT", text="Save Project")
op.should_save_as = False
class BIM_PT_references(Panel):
bl_label = "References"
bl_idname = "BIM_PT_references"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "BIM Documentation"
@classmethod
def poll(cls, context):
return tool.Ifc.get()
def draw(self, context):
if not DocumentsData.is_loaded:
DocumentsData.load()
if not DocumentsData.data["has_saved_ifc"]:
draw_project_not_saved_ui(self)
return
self.props = context.scene.DocProperties
if not self.props.is_editing_references:
row = self.layout.row(align=True)
row.label(text=f"{DocumentsData.data['total_references']} References Found", icon="LONGDISPLAY")
row.operator("bim.load_references", text="", icon="IMPORT")
return
row = self.layout.row(align=True)
row.operator("bim.add_reference", icon="ADD")
row.operator("bim.disable_editing_references", text="", icon="CANCEL")
if self.props.references:
if self.props.active_reference_index < len(self.props.references):
active_reference = self.props.references[self.props.active_reference_index]
row = self.layout.row(align=True)
row.alignment = "RIGHT"
row.operator("bim.open_reference", icon="URL", text="").reference = active_reference.ifc_definition_id
row.operator("bim.remove_reference", icon="X", text="").reference = active_reference.ifc_definition_id
self.layout.template_list(
"BIM_UL_generic", "", self.props, "references", self.props, "active_reference_index"
)
class BIM_PT_sheets(Panel):
bl_label = "Sheets"
bl_idname = "BIM_PT_sheets"
@@ -257,6 +340,10 @@ class BIM_PT_sheets(Panel):
if not SheetsData.is_loaded:
SheetsData.load()
if not SheetsData.data["has_saved_ifc"]:
draw_project_not_saved_ui(self)
return
self.props = context.scene.DocProperties
if not self.props.is_editing_sheets:
@@ -274,9 +361,11 @@ class BIM_PT_sheets(Panel):
active_sheet = self.props.sheets[self.props.active_sheet_index]
row = self.layout.row(align=True)
row.alignment = "RIGHT"
row.operator("bim.edit_sheet", icon="GREASEPENCIL", text="")
row.operator("bim.open_sheet", icon="URL", text="")
row.operator("bim.add_drawing_to_sheet", icon="IMAGE_PLANE", text="")
row.operator("bim.add_schedule_to_sheet", icon="PRESET_NEW", text="")
row.operator("bim.add_reference_to_sheet", icon="IMAGE_REFERENCE", text="")
row.operator("bim.create_sheets", icon="FILE_REFRESH", text="")
if active_sheet.is_sheet:
row.operator("bim.remove_sheet", icon="X", text="").sheet = active_sheet.ifc_definition_id
@@ -293,6 +382,7 @@ class BIM_PT_product_assignments(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
@classmethod
def poll(cls, context):
@@ -327,6 +417,7 @@ class BIM_PT_text(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 0
@classmethod
def poll(cls, context):
@@ -335,27 +426,67 @@ class BIM_PT_text(Panel):
element = tool.Ifc.get_entity(context.active_object)
if not element:
return
return element.is_a("IfcAnnotation") and element.ObjectType in ["TEXT", "TEXT_LEADER"]
return tool.Drawing.is_annotation_object_type(element, ["TEXT", "TEXT_LEADER"])
def draw(self, context):
if not TextData.is_loaded:
TextData.load()
props = context.active_object.BIMTextProperties
obj = context.active_object
props = obj.BIMTextProperties
if props.is_editing:
# shares most of the code with EditTextPopup.draw()
# need to keep them in sync or move to some common function
row = self.layout.row(align=True)
row.operator("bim.edit_text", icon="CHECKMARK")
row.operator("bim.add_text_literal", icon="ADD", text="")
row.operator("bim.disable_editing_text", icon="CANCEL", text="")
blenderbim.bim.helper.draw_attributes(props.attributes, self.layout)
row = self.layout.row(align=True)
row.prop(props, "font_size")
for i, literal_props in enumerate(props.literals):
box = self.layout.box()
row = self.layout.row(align=True)
row = box.row(align=True)
row.label(text=f"Literal[{i}]:")
row.operator("bim.remove_text_literal", icon="X", text="").literal_prop_id = i
# skip BoxAlignment since we're going to format it ourselves
attributes = [a for a in literal_props.attributes if a.name != "BoxAlignment"]
blenderbim.bim.helper.draw_attributes(attributes, box)
row = box.row(align=True)
cols = [row.column(align=True) for i in range(3)]
for i in range(9):
cols[i % 3].prop(
literal_props,
"box_alignment",
text="",
index=i,
icon="RADIOBUT_ON" if literal_props.box_alignment[i] else "RADIOBUT_OFF",
)
col = row.column(align=True)
col.label(text=" Text box alignment:")
col.label(text=f' {literal_props.attributes["BoxAlignment"].string_value}')
else:
text_data = DecoratorData.get_ifc_text_data(obj)
row = self.layout.row()
row.operator("bim.enable_editing_text", icon="GREASEPENCIL")
for attribute in TextData.data["attributes"]:
row = self.layout.row(align=True)
row.label(text=attribute["name"])
row.label(text=attribute["value"])
row = self.layout.row(align=True)
row.label(text="FontSize")
row.label(text=str(text_data["FontSize"]))
for literal_data in text_data["Literals"]:
box = self.layout.box()
for attribute in literal_data:
row = box.row(align=True)
row.label(text=attribute)
row.label(text=literal_data[attribute])
class BIM_PT_annotation_utilities(Panel):
@@ -373,58 +504,67 @@ class BIM_PT_annotation_utilities(Panel):
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Dimension", icon="FIXED_SIZE")
op.object_type = "DIMENSION"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Angle", icon="DRIVER_ROTATIONAL_DIFFERENCE")
op.object_type = "ANGLE"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Radius", icon="FORWARD")
op.object_type = "RADIUS"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Diameter", icon="ARROW_LEFTRIGHT")
op.object_type = "DIAMETER"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Text", icon="SMALL_CAPS")
op.object_type = "TEXT"
op.data_type = "empty"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Leader", icon="TRACKING_BACKWARDS")
op.object_type = "TEXT_LEADER"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Stair Arrow", icon="SCREEN_BACK")
op.object_type = "STAIR_ARROW"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Hidden", icon="CON_TRACKTO")
op.object_type = "HIDDEN_LINE"
op.data_type = "mesh"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Level (Plan)", icon="SORTBYEXT")
op.object_type = "PLAN_LEVEL"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Level (Section)", icon="TRIA_DOWN")
op.object_type = "SECTION_LEVEL"
op.data_type = "curve"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Breakline", icon="FCURVE")
op.object_type = "BREAKLINE"
op.data_type = "mesh"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Line", icon="MESH_MONKEY")
op.object_type = "LINEWORK"
op.data_type = "mesh"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Batting", icon="FORCE_FORCE")
op.object_type = "BATTING"
op.data_type = "mesh"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op.description = "Add batting annotation.\nThickness could be changed through Thickness property of BBIM_Batting property set"
op = row.operator("bim.add_annotation", text="Fill Area", icon="NODE_TEXTURE")
op.object_type = "FILL_AREA"
row = layout.row(align=True)
op = row.operator("bim.add_annotation", text="Fall", icon="SORT_ASC")
op.object_type = "FALL"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
op = row.operator("bim.add_annotation", text="Revision", icon="VOLUME_DATA")
op.object_type = "REVISION_CLOUD"
op.data_type = tool.Drawing.get_annotation_data_type(op.object_type)
row = layout.row(align=True)
row.prop(self.props, "should_draw_decorations", text="Viewport Annotations")
row.enabled = context.scene.camera is not None
@@ -434,6 +574,8 @@ class BIM_UL_drawinglist(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
selected_icon = "CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT"
row.prop(item, "is_selected", text="", icon=selected_icon)
icon = "UV_FACESEL"
if item.target_view == "ELEVATION_VIEW":
icon = "UV_VERTEXSEL"
@@ -450,26 +592,37 @@ class BIM_UL_drawinglist(bpy.types.UIList):
class BIM_UL_sheets(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
if item.is_sheet:
if item.is_expanded:
row.operator(
"bim.contract_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
).sheet = item.ifc_definition_id
else:
row.operator(
"bim.expand_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
).sheet = item.ifc_definition_id
else:
row.label(text="", icon="BLANK1")
if item.reference_type == "DRAWING":
row.label(text="", icon="IMAGE_DATA")
elif item.reference_type == "SCHEDULE":
row.label(text="", icon="LONGDISPLAY")
name = "{} - {}".format(item.identification or "X", item.name or "Unnamed")
row.label(text=name)
else:
if not item:
layout.label(text="", translate=False)
return
row = layout.row(align=True)
if item.is_sheet:
if item.is_expanded:
row.operator(
"bim.contract_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
).sheet = item.ifc_definition_id
else:
row.operator(
"bim.expand_sheet", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
).sheet = item.ifc_definition_id
row.label(text=f"{item.identification} - {item.name}")
else:
row.label(text="", icon="BLANK1")
if item.reference_type == "DRAWING":
row.label(text="", icon="IMAGE_DATA")
elif item.reference_type == "SCHEDULE":
row.label(text="", icon="LONGDISPLAY")
elif item.reference_type == "TITLEBLOCK":
row.label(text="", icon="MENU_PANEL")
elif item.reference_type == "REVISION":
row.label(text="", icon="RECOVER_LAST")
elif item.reference_type == "REFERENCE":
row.label(text="", icon="IMAGE_REFERENCE")
if item.identification:
name = f"{item.identification} - {item.name or 'Unnamed'}"
else:
name = item.name or "Unnamed"
row.label(text=name)
@@ -0,0 +1,286 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2023 @Andrej730
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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/>.
import os
import bpy
import blenderbim.tool as tool
from blenderbim.bim.helper import prop_with_search
from bpy.types import WorkSpaceTool
# from blenderbim.bim.module.model.data import AuthoringData, RailingData, RoofData
from blenderbim.bim.module.drawing.prop import ANNOTATION_TYPES_DATA
from blenderbim.bim.module.drawing.data import DecoratorData, AnnotationData
from blenderbim.bim.ifc import IfcStore
import blenderbim.bim.handler
# declaring it here to avoid circular import problems
class Operator:
def execute(self, context):
IfcStore.execute_ifc_operator(self, context)
blenderbim.bim.handler.refresh_ui_data()
return {"FINISHED"}
class AnnotationTool(WorkSpaceTool):
bl_space_type = "VIEW_3D"
bl_context_mode = "OBJECT"
bl_idname = "bim.annotation_tool"
bl_label = "Annotation Tool"
bl_description = "Gives you Annotation related superpowers"
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.annotation")
bl_widget = None
bl_keymap = tool.Blender.get_default_selection_keypmap() + (
("bim.annotation_hotkey", {"type": "A", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_A")]}),
("bim.annotation_hotkey", {"type": "C", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_C")]}),
("bim.annotation_hotkey", {"type": "E", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_E")]}),
("bim.annotation_hotkey", {"type": "F", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_F")]}),
("bim.annotation_hotkey", {"type": "G", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_G")]}),
("bim.annotation_hotkey", {"type": "K", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_K")]}),
("bim.annotation_hotkey", {"type": "M", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_M")]}),
("bim.annotation_hotkey", {"type": "O", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_O")]}),
("bim.annotation_hotkey", {"type": "Q", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_Q")]}),
("bim.annotation_hotkey", {"type": "R", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_R")]}),
("bim.annotation_hotkey", {"type": "T", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_T")]}),
("bim.annotation_hotkey", {"type": "V", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_V")]}),
("bim.annotation_hotkey", {"type": "X", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_X")]}),
("bim.annotation_hotkey", {"type": "Y", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_Y")]}),
("bim.annotation_hotkey", {"type": "D", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_D")]}),
("bim.annotation_hotkey", {"type": "E", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_E")]}),
("bim.annotation_hotkey", {"type": "O", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_O")]}),
)
def draw_settings(context, layout, ws_tool):
# Unlike operators, Blender doesn't treat workspace tools as a class, so we'll create our own.
AnnotationToolUI.draw(context, layout)
def add_layout_hotkey_operator(layout, text, hotkey, description):
modifiers = {
"A": "EVENT_ALT",
"S": "EVENT_SHIFT",
}
modifier, key = hotkey.split("_")
row = layout.row(align=True)
row.label(text="", icon=modifiers[modifier])
row.label(text="", icon=f"EVENT_{key}")
op = row.operator("bim.annotation_hotkey", text=text)
op.hotkey = hotkey
op.description = description
return op, row
# TODO: move to operator
def create_annotation_type(context):
# just empty to store parameters
props = context.scene.BIMAnnotationProperties
object_type = props.object_type
create_representation = props.create_representation_for_type
drawing = tool.Ifc.get_entity(bpy.context.scene.camera)
if props.create_representation_for_type:
obj = tool.Drawing.create_annotation_object(drawing, object_type)
else:
obj = bpy.data.objects.new(object_type, None)
obj.name = f"{object_type}_TYPE"
obj.location = context.scene.cursor.location
tool.Drawing.ensure_annotation_in_drawing_plane(obj)
drawing = tool.Ifc.get_entity(context.scene.camera)
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing), object_type)
element = tool.Drawing.run_root_assign_class(
obj=obj,
ifc_class="IfcTypeProduct",
predefined_type=object_type,
should_add_representation=create_representation,
context=ifc_context,
ifc_representation_class=tool.Drawing.get_ifc_representation_class(object_type),
)
element.ApplicableOccurrence = f"IfcAnnotation/{object_type}"
tool.Blender.select_and_activate_single_object(context, obj)
# TODO: move to operator
def create_annotation_occurence(context):
# object_type = context.scene.BIMAnnotationProperties.object_type
props = context.scene.BIMAnnotationProperties
relating_type = tool.Ifc.get().by_id(int(props.relating_type_id))
object_type = props.object_type
drawing = tool.Ifc.get_entity(context.scene.camera)
obj = tool.Drawing.create_annotation_object(drawing, object_type)
obj.name = relating_type.Name
ifc_context = tool.Drawing.get_annotation_context(tool.Drawing.get_drawing_target_view(drawing), object_type)
relating_type_repr = tool.Drawing.get_annotation_representation(relating_type)
element = tool.Drawing.run_root_assign_class(
obj=obj,
ifc_class="IfcAnnotation",
predefined_type=object_type,
should_add_representation=not bool(relating_type_repr),
context=ifc_context,
ifc_representation_class=tool.Drawing.get_ifc_representation_class(object_type),
)
blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type)
tool.Ifc.run("group.assign_group", group=tool.Drawing.get_drawing_group(drawing), products=[element])
tool.Collector.assign(obj)
tool.Blender.select_and_activate_single_object(context, obj)
def create_annotation():
props = bpy.context.scene.BIMAnnotationProperties
create_type_occurence = props.relating_type_id != "0"
if create_type_occurence:
create_annotation_occurence(bpy.context)
else:
object_type = props.object_type
bpy.ops.bim.add_annotation(object_type=object_type, data_type=ANNOTATION_TYPES_DATA[object_type][-1])
class AnnotationToolUI:
@classmethod
def draw(cls, context, layout):
cls.layout = layout
cls.props = context.scene.BIMAnnotationProperties
row = cls.layout.row(align=True)
if not tool.Ifc.get():
row.label(text="No IFC Project", icon="ERROR")
return
if not AnnotationData.is_loaded:
AnnotationData.load()
cls.draw_type_selection_interface()
if context.active_object and context.selected_objects:
cls.draw_edit_object_interface(context)
cls.draw_create_object_interface()
@classmethod
def draw_create_object_interface(cls):
row = cls.layout.row(align=True)
op, row = add_layout_hotkey_operator(cls.layout, "Add Type", "S_C", "Create a new annotation type")
selected_icon = "CHECKBOX_HLT" if cls.props.create_representation_for_type else "CHECKBOX_DEHLT"
row.prop(cls.props, "create_representation_for_type", text="", icon=selected_icon)
@classmethod
def draw_edit_object_interface(cls, context):
if DecoratorData.get_ifc_text_data(bpy.context.object):
add_layout_hotkey_operator(cls.layout, "Edit Text", "S_E", "")
@classmethod
def draw_type_selection_interface(cls):
# shared by both sidebar and header
object_type = cls.props.object_type
row = cls.layout.row(align=True)
row.label(text="", icon="FILE_VOLUME")
prop_with_search(row, cls.props, "object_type", text="")
row = cls.layout.row(align=True)
row.label(text="", icon="FILE_3D")
prop_with_search(row, cls.props, "relating_type_id", text="")
create_type_occurence = cls.props.relating_type_id != "0"
label = "Add Type Occurence" if create_type_occurence else "Add Annotation"
add_layout_hotkey_operator(cls.layout, label, "S_A", "Create a new annotation")
if object_type in ("TEXT", "STAIR_ARROW"):
add_layout_hotkey_operator(
cls.layout,
"Bulk Tag",
"S_T",
"Create new annotations and automatically adjust them to the selected objects",
)
add_layout_hotkey_operator(
cls.layout, "Readjust", "S_G", "Readjust tags based on the products they are assigned to"
)
class Hotkey(bpy.types.Operator, Operator):
bl_idname = "bim.annotation_hotkey"
bl_label = "Hotkey"
bl_options = {"REGISTER", "UNDO"}
hotkey: bpy.props.StringProperty()
description: bpy.props.StringProperty()
@classmethod
def poll(cls, context):
return tool.Ifc.get()
@classmethod
def description(cls, context, operator):
return operator.description or ""
def _execute(self, context):
self.props = context.scene.BIMAnnotationProperties
getattr(self, f"hotkey_{self.hotkey}")()
def invoke(self, context, event):
# https://blender.stackexchange.com/questions/276035/how-do-i-make-operators-remember-their-property-values-when-called-from-a-hotkey
self.props = context.scene.BIMAnnotationProperties
return self.execute(context)
def draw(self, context):
pass
def hotkey_S_T(self):
props = bpy.context.scene.BIMAnnotationProperties
object_type = props.object_type
related_objects = bpy.context.selected_objects
for related_object in related_objects:
create_annotation()
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode="OBJECT")
tool.Drawing.setup_annotation_object(obj, object_type, related_object)
def hotkey_S_A(self):
create_annotation()
def hotkey_S_E(self):
if not bpy.context.object:
return
if DecoratorData.get_ifc_text_data(bpy.context.object):
bpy.ops.bim.edit_text_popup()
def hotkey_S_G(self):
for obj in bpy.context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element or not element.is_a("IfcAnnotation"):
continue
related_product = tool.Drawing.get_assigned_product(element)
if not related_product:
continue
related_object = tool.Ifc.get_object(related_product)
tool.Drawing.setup_annotation_object(obj, element.ObjectType, related_object)
def hotkey_S_C(self):
create_annotation_type(bpy.context)
@@ -27,6 +27,11 @@ classes = (
operator.OverrideDelete,
operator.OverrideDuplicateMove,
operator.OverrideDuplicateMoveLinked,
operator.OverrideDuplicateMoveLinkedMacro,
operator.OverrideDuplicateMoveMacro,
operator.OverrideJoin,
operator.OverrideModeSetEdit,
operator.OverrideModeSetObject,
operator.OverrideOutlinerDelete,
operator.OverridePasteBuffer,
operator.RemoveConnection,
@@ -35,6 +40,7 @@ classes = (
operator.SwitchRepresentation,
operator.UpdateParametricRepresentation,
operator.UpdateRepresentation,
prop.BIMObjectGeometryProperties,
prop.BIMGeometryProperties,
ui.BIM_PT_derived_placements,
ui.BIM_PT_representations,
@@ -48,19 +54,33 @@ addon_keymaps = []
def register():
operator.OverrideDuplicateMoveMacro.define("BIM_OT_override_object_duplicate_move")
operator.OverrideDuplicateMoveMacro.define("TRANSFORM_OT_translate")
operator.OverrideDuplicateMoveLinkedMacro.define("BIM_OT_override_object_duplicate_move_linked")
operator.OverrideDuplicateMoveLinkedMacro.define("TRANSFORM_OT_translate")
bpy.types.Object.BIMGeometryProperties = bpy.props.PointerProperty(type=prop.BIMObjectGeometryProperties)
bpy.types.Scene.BIMGeometryProperties = bpy.props.PointerProperty(type=prop.BIMGeometryProperties)
bpy.types.OBJECT_PT_transform.append(ui.BIM_PT_transform)
bpy.types.VIEW3D_MT_object.append(ui.object_menu)
wm = bpy.context.window_manager
if wm.keyconfigs.addon:
km = wm.keyconfigs.addon.keymaps.new(name="Object Mode", space_type="EMPTY")
kmi = km.keymap_items.new("bim.override_object_duplicate_move", "D", "PRESS", shift=True)
kmi = km.keymap_items.new("bim.override_object_duplicate_move_linked", "D", "PRESS", alt=True)
kmi = km.keymap_items.new("bim.override_object_join", "J", "PRESS", ctrl=True)
kmi = km.keymap_items.new("bim.override_object_duplicate_move_macro", "D", "PRESS", shift=True)
kmi = km.keymap_items.new("bim.override_object_duplicate_move_linked_macro", "D", "PRESS", alt=True)
kmi = km.keymap_items.new("bim.override_paste_buffer", "V", "PRESS", ctrl=True)
kmi = km.keymap_items.new("bim.override_mode_set_edit", "TAB", "PRESS")
kmi = km.keymap_items.new("bim.override_object_delete", "X", "PRESS")
kmi = km.keymap_items.new("bim.override_object_delete", "DEL", "PRESS")
kmi.properties.confirm = False
km = wm.keyconfigs.addon.keymaps.new(name="Mesh", space_type="EMPTY")
kmi = km.keymap_items.new("bim.override_mode_set_object", "TAB", "PRESS")
km = wm.keyconfigs.addon.keymaps.new(name="Curve", space_type="EMPTY")
kmi = km.keymap_items.new("bim.override_mode_set_object", "TAB", "PRESS")
km = wm.keyconfigs.addon.keymaps.new(name="Outliner", space_type="OUTLINER")
kmi = km.keymap_items.new("bim.override_paste_buffer", "V", "PRESS", ctrl=True)
kmi = km.keymap_items.new("bim.override_outliner_delete", "X", "PRESS")
@@ -71,6 +91,7 @@ def unregister():
bpy.types.VIEW3D_MT_object.remove(ui.object_menu)
bpy.types.OBJECT_PT_transform.remove(ui.BIM_PT_transform)
del bpy.types.Scene.BIMGeometryProperties
del bpy.types.Object.BIMGeometryProperties
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
@@ -35,12 +35,18 @@ class RepresentationsData:
@classmethod
def load(cls):
cls.data = {"representations": cls.representations()}
cls.data["contexts"] = cls.contexts()
cls.is_loaded = True
@classmethod
def representations(cls):
results = []
element = tool.Ifc.get_entity(bpy.context.active_object)
active_representation_id = None
if bpy.context.active_object.data and hasattr(bpy.context.active_object.data, "BIMMeshProperties"):
active_representation_id = bpy.context.active_object.data.BIMMeshProperties.ifc_definition_id
representations = []
if element.is_a("IfcProduct") and element.Representation:
representations = element.Representation.Representations
@@ -57,6 +63,7 @@ class RepresentationsData:
"ContextIdentifier": "",
"TargetView": "",
"RepresentationType": representation_type or "",
"is_active": representation.id() == active_representation_id,
}
if representation.ContextOfItems.is_a("IfcGeometricRepresentationSubContext"):
data["ContextIdentifier"] = representation.ContextOfItems.ContextIdentifier or ""
@@ -64,6 +71,25 @@ class RepresentationsData:
results.append(data)
return results
@classmethod
def contexts(cls):
results = []
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
results.append((str(element.id()), element.ContextType or "Unnamed", ""))
for element in tool.Ifc.get().by_type("IfcGeometricRepresentationSubContext", include_subtypes=False):
results.append(
(
str(element.id()),
"{}/{}/{}".format(
element.ContextType or "Unnamed",
element.ContextIdentifier or "Unnamed",
element.TargetView or "Unnamed",
),
"",
)
)
return results
class ConnectionsData:
data = {}
@@ -78,24 +104,44 @@ class ConnectionsData:
def connections(cls):
results = []
element = tool.Ifc.get_entity(bpy.context.active_object)
for rel in getattr(element, "ConnectedTo", []):
connected_to = getattr(element, "ConnectedTo", [])
connected_from = getattr(element, "ConnectedFrom", [])
for rel in connected_to:
if element.is_a("IfcDistributionPort"):
related_element = rel.RelatedPort
related_element_connection_type = ""
else:
related_element = rel.RelatedElement
related_element_connection_type = rel.RelatedConnectionType
results.append(
{
"id": rel.id(),
"is_relating": True,
"Name": rel.RelatedElement.Name or "Unnamed",
"ConnectionType": rel.RelatingConnectionType,
"Name": related_element.Name or "Unnamed",
"ConnectionType": related_element_connection_type,
}
)
for rel in getattr(element, "ConnectedFrom", []):
for rel in connected_from:
if element.is_a("IfcDistributionPort"):
relating_element = rel.RelatingPort
relating_element_connection_type = ""
else:
relating_element = rel.RelatingElement
relating_element_connection_type = rel.RelatingConnectionType
results.append(
{
"id": rel.id(),
"is_relating": False,
"Name": rel.RelatingElement.Name or "Unnamed",
"ConnectionType": rel.RelatedConnectionType,
"Name": relating_element.Name or "Unnamed",
"ConnectionType": relating_element_connection_type,
}
)
return results
@@ -126,10 +172,18 @@ class DerivedPlacementsData:
@classmethod
def load_collection(cls):
cls.collection = bpy.data.objects.get(bpy.context.active_object.users_collection[0].name)
cls.collection = None
cls.collection_z = 0
if cls.collection:
cls.collection_z = cls.collection.matrix_world.translation.z
element = tool.Ifc.get_entity(bpy.context.active_object)
if not element:
return
parent = ifcopenshell.util.element.get_aggregate(element)
if not parent:
parent = ifcopenshell.util.element.get_container(element)
if parent:
cls.collection = tool.Ifc.get_object(parent)
if cls.collection:
cls.collection_z = cls.collection.matrix_world.translation.z
@classmethod
def has_collection(cls):
@@ -38,6 +38,7 @@ class Helper:
bm = bmesh.new()
bm.from_mesh(mesh)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
bm.faces.ensure_lookup_table()
face = None
@@ -61,6 +62,7 @@ class Helper:
bm = bmesh.new()
bm.from_mesh(mesh)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
bm.faces.ensure_lookup_table()
potential_faces = []
@@ -88,6 +90,7 @@ class Helper:
bm = bmesh.new()
bm.from_mesh(mesh)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
bm.faces.ensure_lookup_table()
potential_faces = []
@@ -289,6 +292,7 @@ class Helper:
bm = bmesh.new()
bm.from_mesh(mesh)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
bm.faces.ensure_lookup_table()
potential_faces = []
@@ -385,6 +389,7 @@ class Helper:
bm = bmesh.new()
bm.from_mesh(mesh)
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
bm.faces.ensure_lookup_table()
faces = bm.faces
@@ -28,12 +28,12 @@ import ifcopenshell.api
import blenderbim.core.geometry as core
import blenderbim.core.style
import blenderbim.core.root
import blenderbim.core.drawing
import blenderbim.tool as tool
import blenderbim.bim.handler
from mathutils import Vector
from blenderbim.bim import import_ifc
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.root.prop import get_contexts
class Operator:
@@ -59,27 +59,20 @@ class AddRepresentation(bpy.types.Operator, Operator):
bl_idname = "bim.add_representation"
bl_label = "Add Representation"
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty()
context_id: bpy.props.IntProperty()
ifc_representation_class: bpy.props.StringProperty()
profile_set_usage: bpy.props.IntProperty()
def _execute(self, context):
ifc_context = self.context_id
if not ifc_context and get_contexts(self, context):
ifc_context = int(context.scene.BIMRootProperties.contexts or "0") or None
ifc_context = int(context.active_object.BIMGeometryProperties.contexts or "0") or None
if ifc_context:
ifc_context = tool.Ifc.get().by_id(ifc_context)
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
core.add_representation(
tool.Ifc,
tool.Geometry,
tool.Style,
tool.Surveyor,
obj=obj,
obj=context.active_object,
context=ifc_context,
ifc_representation_class=self.ifc_representation_class,
profile_set_usage=tool.Ifc.get().by_id(self.profile_set_usage) if self.profile_set_usage else None,
ifc_representation_class=None,
profile_set_usage=None,
)
@@ -196,7 +189,8 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
ifcopenshell.api.run("boundary.assign_connection_geometry", tool.Ifc.get(), **settings)
return
core.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
if tool.Ifc.is_moved(obj):
core.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
if material and material.is_a() in ["IfcMaterialProfileSet", "IfcMaterialLayerSet"]:
# These objects are parametrically based on an axis and should not be modified as a mesh
@@ -205,6 +199,13 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
old_representation = self.file.by_id(obj.data.BIMMeshProperties.ifc_definition_id)
context_of_items = old_representation.ContextOfItems
# TODO: remove this code a bit later
# added this as a fallback for easier transition some annotation types to 3d
# if they were create before as 2d
element = tool.Ifc.get_entity(obj)
if tool.Drawing.is_annotation_object_type(element, ("FALL", "SECTION_LEVEL", "PLAN_LEVEL")):
context_of_items = tool.Drawing.get_annotation_context("MODEL_VIEW")
gprop = context.scene.BIMGeoreferenceProperties
coordinate_offset = None
if gprop.has_blender_offset and obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT":
@@ -257,6 +258,20 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
obj.data.BIMMeshProperties.ifc_definition_id = int(new_representation.id())
obj.data.name = f"{old_representation.ContextOfItems.id()}/{new_representation.id()}"
# TODO: In simple scenarios, a type has a ShapeRepresentation of ID
# 123. This is then mapped through mapped representations by
# occurrences, with no cartesian transformation. In this case, the mesh
# data is 100% shared and therefore all have the same mesh name
# referencing ID 123. (i.e. the local origins are shared). However, in
# complex scenarios, occurrences may have their own cartesian
# transformation (via MappingTarget). This will mean that occurrences
# will not share the same mesh data and will instead reference a
# different ShapeRepresentation ID. In this scenario, we have to
# propagate the obj.data back to the type itself and all sibling
# occurrences and accommodate their individual cartesian
# transformations.
core.remove_representation(tool.Ifc, tool.Geometry, obj=obj, representation=old_representation)
if obj.data.BIMMeshProperties.ifc_parameters:
core.get_representation_ifc_parameters(tool.Geometry, obj=obj)
@@ -352,55 +367,13 @@ class CopyRepresentation(bpy.types.Operator, Operator):
return r.MappedRepresentation
class OverrideDeleteTrait:
def delete_ifc_object(self, obj):
element = tool.Ifc.get_entity(obj)
if not element:
return
IfcStore.delete_element(element)
if obj.users_collection and obj.users_collection[0].name == obj.name:
parent = ifcopenshell.util.element.get_aggregate(element)
if not parent:
parent = ifcopenshell.util.element.get_container(element)
if parent:
parent_obj = tool.Ifc.get_object(parent)
if parent_obj:
parent_collection = bpy.data.collections.get(parent_obj.name)
for child in obj.users_collection[0].children:
parent_collection.children.link(child)
bpy.data.collections.remove(obj.users_collection[0])
if getattr(element, "FillsVoids", None):
self.remove_filling(element)
if element.is_a("IfcOpeningElement"):
if element.HasFillings:
for rel in element.HasFillings:
self.remove_filling(rel.RelatedBuildingElement)
else:
if element.VoidsElements:
self.delete_opening_element(element)
else:
if getattr(element, "HasOpenings", None):
for rel in element.HasOpenings:
self.delete_opening_element(rel.RelatedOpeningElement)
for port in ifcopenshell.util.system.get_ports(element):
self.remove_port(port)
def delete_opening_element(self, element):
bpy.ops.bim.remove_opening(opening_id=element.id())
def remove_filling(self, element):
bpy.ops.bim.remove_filling(filling=element.id())
def remove_port(self, port):
blenderbim.core.system.remove_port(tool.Ifc, tool.System, port=port)
class OverrideDelete(bpy.types.Operator, OverrideDeleteTrait):
class OverrideDelete(bpy.types.Operator):
bl_idname = "bim.override_object_delete"
bl_label = "IFC Delete"
bl_options = {"REGISTER", "UNDO"}
use_global: bpy.props.BoolProperty(default=False)
confirm: bpy.props.BoolProperty(default=True)
is_batch: bpy.props.BoolProperty(name="Is Batch", default=False)
@classmethod
def poll(cls, context):
@@ -408,7 +381,7 @@ class OverrideDelete(bpy.types.Operator, OverrideDeleteTrait):
def execute(self, context):
# Deep magick from the dawn of time
if IfcStore.get_file():
if tool.Ifc.get():
return IfcStore.execute_ifc_operator(self, context)
for obj in context.selected_objects:
bpy.data.objects.remove(obj)
@@ -417,21 +390,57 @@ class OverrideDelete(bpy.types.Operator, OverrideDeleteTrait):
return {"FINISHED"}
def invoke(self, context, event):
if self.confirm:
if tool.Ifc.get():
total_elements = len(tool.Ifc.get().wrapped_data.entity_names())
total_polygons = sum([len(o.data.polygons) for o in context.selected_objects if o.type == "MESH"])
# These numbers are a bit arbitrary, but basically batching is only
# really necessary on large models and large geometry removals.
self.is_batch = total_elements > 500000 and total_polygons > 2000
if self.is_batch:
return context.window_manager.invoke_props_dialog(self)
elif self.confirm:
return context.window_manager.invoke_confirm(self, event)
elif self.confirm:
return context.window_manager.invoke_confirm(self, event)
self.confirm = True
return self.execute(context)
def draw(self, context):
row = self.layout.row()
row.label(text="Warning: Faster deletion will use more memory.", icon="ERROR")
row = self.layout.row()
row.prop(self, "is_batch", text="Enable Faster Deletion")
def _execute(self, context):
if self.is_batch:
ifcopenshell.util.element.batch_remove_deep2(tool.Ifc.get())
for obj in context.selected_objects:
self.delete_ifc_object(obj)
bpy.data.objects.remove(obj)
if tool.Ifc.get_entity(obj):
tool.Geometry.delete_ifc_object(obj)
else:
bpy.data.objects.remove(obj)
if self.is_batch:
old_file = tool.Ifc.get()
old_file.end_transaction()
new_file = ifcopenshell.util.element.unbatch_remove_deep2(tool.Ifc.get())
new_file.begin_transaction()
tool.Ifc.set(new_file)
self.transaction_data = {"old_file": old_file, "new_file": new_file}
IfcStore.add_transaction_operation(self)
# Required otherwise gizmos are still visible
context.view_layer.objects.active = None
return {"FINISHED"}
def rollback(self, data):
tool.Ifc.set(data["old_file"])
data["old_file"].undo()
class OverrideOutlinerDelete(bpy.types.Operator, OverrideDeleteTrait):
def commit(self, data):
data["old_file"].redo()
tool.Ifc.set(data["new_file"])
class OverrideOutlinerDelete(bpy.types.Operator):
bl_idname = "bim.override_outliner_delete"
bl_label = "IFC Delete"
bl_options = {"REGISTER", "UNDO"}
@@ -482,8 +491,7 @@ class OverrideOutlinerDelete(bpy.types.Operator, OverrideDeleteTrait):
objects_to_delete.add(bpy.data.objects.get(item.name))
for obj in objects_to_delete:
# This is the only difference
self.delete_ifc_object(obj)
bpy.data.objects.remove(obj)
tool.Geometry.delete_ifc_object(obj)
return {"FINISHED"}
def get_collection_objects_and_children(self, collection):
@@ -499,10 +507,87 @@ class OverrideOutlinerDelete(bpy.types.Operator, OverrideDeleteTrait):
return {"objects": objects, "children": children}
class OverrideDuplicateMoveMacro(bpy.types.Macro):
bl_idname = "bim.override_object_duplicate_move_macro"
bl_label = "IFC Duplicate Objects"
bl_options = {"REGISTER", "UNDO"}
class OverrideDuplicateMove(bpy.types.Operator):
bl_idname = "bim.override_object_duplicate_move"
bl_label = "IFC Duplicate Objects"
bl_options = {"REGISTER", "UNDO"}
is_interactive: bpy.props.BoolProperty(name="Is Interactive", default=True)
@classmethod
def poll(cls, context):
return len(context.selected_objects) > 0
def execute(self, context):
# Deep magick from the dawn of time
if IfcStore.get_file():
IfcStore.execute_ifc_operator(self, context)
if self.new_active_obj:
context.view_layer.objects.active = self.new_active_obj
return {"FINISHED"}
new_active_obj = None
for obj in context.selected_objects:
new_obj = obj.copy()
if obj.data:
new_obj.data = obj.data.copy()
if obj == context.active_object:
new_active_obj = new_obj
for collection in obj.users_collection:
collection.objects.link(new_obj)
obj.select_set(False)
new_obj.select_set(True)
if new_active_obj:
context.view_layer.objects.active = new_active_obj
return {"FINISHED"}
def _execute(self, context):
self.new_active_obj = None
# Track decompositions so they can be recreated after the operation
relationships = tool.Root.get_decomposition_relationships(context.selected_objects)
old_to_new = {}
for obj in context.selected_objects:
new_obj = obj.copy()
if obj.data:
new_obj.data = obj.data.copy()
if obj == context.active_object:
self.new_active_obj = new_obj
for collection in obj.users_collection:
collection.objects.link(new_obj)
obj.select_set(False)
new_obj.select_set(True)
# clear object's collection so it will be able to have it's own
new_obj.BIMObjectProperties.collection = None
# Copy the actual class
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
if new:
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
if array_pset:
array_pset = tool.Ifc.get().by_id(array_pset["id"])
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new, pset=array_pset)
old_to_new[tool.Ifc.get_entity(obj)] = [new]
if new.is_a("IfcRelSpaceBoundary"):
tool.Boundary.decorate_boundary(new_obj)
# Recreate decompositions
tool.Root.recreate_decompositions(relationships, old_to_new)
blenderbim.bim.handler.purge_module_data()
class OverrideDuplicateMoveLinkedMacro(bpy.types.Macro):
bl_idname = "bim.override_object_duplicate_move_linked_macro"
bl_label = "IFC Duplicate Linked"
bl_options = {"REGISTER", "UNDO"}
class OverrideDuplicateMoveLinked(bpy.types.Operator):
bl_idname = "bim.override_object_duplicate_move_linked"
bl_label = "IFC Duplicate Linked"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
@@ -519,8 +604,6 @@ class OverrideDuplicateMove(bpy.types.Operator):
new_active_obj = None
for obj in context.selected_objects:
new_obj = obj.copy()
if obj.data:
new_obj.data = obj.data.copy()
if obj == context.active_object:
new_active_obj = new_obj
for collection in obj.users_collection:
@@ -529,7 +612,6 @@ class OverrideDuplicateMove(bpy.types.Operator):
new_obj.select_set(True)
if new_active_obj:
context.view_layer.objects.active = new_active_obj
bpy.ops.transform.translate("INVOKE_DEFAULT")
return {"FINISHED"}
def _execute(self, context):
@@ -550,70 +632,117 @@ class OverrideDuplicateMove(bpy.types.Operator):
# Copy the actual class
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
if new:
old_to_new[tool.Ifc.get_entity(obj)] = [new]
# Recreate decompositions
tool.Root.recreate_decompositions(relationships, old_to_new)
bpy.ops.transform.translate("INVOKE_DEFAULT")
blenderbim.bim.handler.purge_module_data()
class OverrideDuplicateMoveLinked(bpy.types.Operator):
bl_idname = "bim.override_object_duplicate_move_linked"
bl_label = "IFC Duplicate Linked"
@classmethod
def poll(cls, context):
return len(context.selected_objects) > 0
def execute(self, context):
# Deep magick from the dawn of time
if IfcStore.get_file():
IfcStore.execute_ifc_operator(self, context)
if self.new_active_obj:
context.view_layer.objects.active = self.new_active_obj
return {"FINISHED"}
new_active_obj = None
for obj in context.selected_objects:
new_obj = obj.copy()
if obj == context.active_object:
new_active_obj = new_obj
for collection in obj.users_collection:
collection.objects.link(new_obj)
obj.select_set(False)
new_obj.select_set(True)
if new_active_obj:
context.view_layer.objects.active = new_active_obj
bpy.ops.transform.translate("INVOKE_DEFAULT")
return {"FINISHED"}
def _execute(self, context):
self.new_active_obj = None
# Track decompositions so they can be recreated after the operation
relationships = tool.Root.get_decomposition_relationships(context.selected_objects)
old_to_new = {}
for obj in context.selected_objects:
new_obj = obj.copy()
if obj == context.active_object:
self.new_active_obj = new_obj
for collection in obj.users_collection:
collection.objects.link(new_obj)
obj.select_set(False)
new_obj.select_set(True)
# Copy the actual class
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
if new:
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
if array_pset:
array_pset = tool.Ifc.get().by_id(array_pset["id"])
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new, pset=array_pset)
old_to_new[tool.Ifc.get_entity(obj)] = new
# Recreate decompositions
tool.Root.recreate_decompositions(relationships, old_to_new)
bpy.ops.transform.translate("INVOKE_DEFAULT")
blenderbim.bim.handler.purge_module_data()
return {"FINISHED"}
class OverrideJoin(bpy.types.Operator, Operator):
bl_idname = "bim.override_object_join"
bl_label = "IFC Join"
bl_options = {"REGISTER", "UNDO"}
def invoke(self, context, event):
if not tool.Ifc.get():
return bpy.ops.object.join()
return self.execute(context)
def _execute(self, context):
if not tool.Ifc.get():
return bpy.ops.object.join()
if not context.active_object:
return
self.target = context.active_object
self.target_element = tool.Ifc.get_entity(self.target)
if self.target_element:
return self.join_ifc_obj()
return self.join_blender_obj()
def join_ifc_obj(self):
representation = tool.Ifc.get().by_id(self.target.data.BIMMeshProperties.ifc_definition_id)
if representation.RepresentationType in ("Tessellation", "Brep"):
for obj in bpy.context.selected_objects:
if obj == self.target:
continue
element = tool.Ifc.get_entity(obj)
if element:
ifcopenshell.api.run("root.remove_product", tool.Ifc.get(), product=element)
bpy.ops.object.join()
bpy.ops.bim.update_representation(obj=self.target.name, ifc_representation_class="")
elif representation.RepresentationType == "SweptSolid":
target_placement = np.array(self.target.matrix_world)
items = list(representation.Items)
for obj in bpy.context.selected_objects:
if obj == self.target:
continue
element = tool.Ifc.get_entity(obj)
# Non IFC elements cannot be joined since we cannot guarantee SweptSolid compliance
if not element:
obj.select_set(False)
continue
# Only objects of the same representation type can be joined
obj_rep = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
if obj_rep.RepresentationType != "SweptSolid":
obj.select_set(False)
continue
placement = np.array(obj.matrix_world)
for item in obj_rep.Items:
copied_item = ifcopenshell.util.element.copy_deep(tool.Ifc.get(), item)
for style in item.StyledByItem:
copied_style = ifcopenshell.util.element.copy(tool.Ifc.get(), style)
copied_style.Item = copied_item
if copied_item.Position:
position = ifcopenshell.util.placement.get_axis2placement(copied_item.Position)
else:
position = np.eye(4)
position = placement @ position
position = np.linalg.inv(target_placement) @ position
copied_item.Position = tool.Ifc.get().createIfcAxis2Placement3D(
tool.Ifc.get().createIfcCartesianPoint([float(n) for n in position[:, 3][:3]]),
tool.Ifc.get().createIfcDirection([float(n) for n in position[:, 2][:3]]),
tool.Ifc.get().createIfcDirection([float(n) for n in position[:, 0][:3]]),
)
items.append(copied_item)
ifcopenshell.api.run("root.remove_product", tool.Ifc.get(), product=element)
representation.Items = items
bpy.ops.object.join()
core.switch_representation(
tool.Ifc,
tool.Geometry,
obj=self.target,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
apply_openings=True,
)
def join_blender_obj(self):
for obj in bpy.context.selected_objects:
if obj == self.target:
continue
element = tool.Ifc.get_entity(obj)
if element:
ifcopenshell.api.run("root.remove_product", tool.Ifc.get(), product=element)
bpy.ops.object.join()
class OverridePasteBuffer(bpy.types.Operator):
bl_idname = "bim.override_paste_buffer"
bl_label = "IFC Paste BIM Objects"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
bpy.ops.view3d.pastebuffer()
@@ -621,3 +750,220 @@ class OverridePasteBuffer(bpy.types.Operator):
for obj in context.selected_objects:
blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=obj)
return {"FINISHED"}
class OverrideModeSetEdit(bpy.types.Operator):
bl_idname = "bim.override_mode_set_edit"
bl_label = "IFC Mode Set Edit"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
objs = context.selected_objects or ([context.active_object] if context.active_object else [])
active_obj = context.active_object
if context.active_object:
context.active_object.select_set(True)
element = tool.Ifc.get_entity(context.active_object)
if element and element.is_a("IfcRelSpaceBoundary"):
return bpy.ops.bim.enable_editing_boundary_geometry()
for obj in objs:
if not obj:
continue
if not obj.data:
obj.select_set(False)
continue
element = tool.Ifc.get_entity(obj)
if not element:
continue
# We are switching from OBJECT to EDIT mode.
usage_type = tool.Model.get_usage_type(element)
if usage_type is not None and usage_type not in ("PROFILE", "LAYER3"):
# Parametric objects shall not be edited as meshes as they
# can be modified to be incompatible with the parametric
# constraints.
obj.select_set(False)
continue
representation = tool.Geometry.get_active_representation(obj)
if not representation:
continue
if (
tool.Pset.get_element_pset(element, "BBIM_Door")
or tool.Pset.get_element_pset(element, "BBIM_Window")
or tool.Pset.get_element_pset(element, "BBIM_Stair")
):
obj.select_set(False)
continue
if usage_type == "PROFILE":
if len(context.selected_objects) == 1:
bpy.ops.bim.hotkey(hotkey="A_E", description="")
return {"FINISHED"}
else:
self.report({"INFO"}, "Only a single profile-based representation can be edited at a time.")
obj.select_set(False)
continue
if (
tool.Geometry.is_profile_based(obj.data)
or usage_type == "LAYER3"
or tool.Geometry.is_swept_profile(representation)
or tool.Pset.get_element_pset(element, "BBIM_Roof")
or tool.Pset.get_element_pset(element, "BBIM_Railing")
):
if len(context.selected_objects) == 1:
bpy.ops.bim.hotkey(hotkey="S_E", description="")
return {"FINISHED"}
else:
self.report({"INFO"}, "Only a single profile-based representation can be edited at a time.")
obj.select_set(False)
continue
if tool.Geometry.is_meshlike(representation):
if getattr(element, "HasOpenings", None):
# Mesh elements with openings must disable openings
# so that you can edit the original topology.
core.switch_representation(
tool.Ifc,
tool.Geometry,
obj=obj,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
apply_openings=False,
)
obj.data.BIMMeshProperties.mesh_checksum = tool.Geometry.get_mesh_checksum(obj.data)
else:
obj.select_set(False)
continue
if not context.selected_objects or len(context.selected_objects) != len(objs):
# We are trying to edit at least one non-mesh-like object : Display a hint to the user
self.report({"INFO"}, "Only mesh-compatible representations may be edited in edit mode.")
if context.active_object not in context.selected_objects:
# The active object is non-mesh-like. Set a valid object (or None) as active
context.view_layer.objects.active = context.selected_objects[0] if context.selected_objects else None
if context.active_object:
bpy.ops.object.mode_set(mode="EDIT", toggle=True)
else:
# restore the selection if nothing worked
for obj in objs:
obj.select_set(True)
context.view_layer.objects.active = active_obj
return {"FINISHED"}
def invoke(self, context, event):
if not tool.Ifc.get():
return bpy.ops.object.mode_set(mode="EDIT", toggle=True)
return self.execute(context)
class OverrideModeSetObject(bpy.types.Operator):
bl_idname = "bim.override_mode_set_object"
bl_label = "IFC Mode Set Object"
bl_options = {"REGISTER", "UNDO"}
should_save: bpy.props.BoolProperty(name="Should Save", default=True)
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
for obj in self.edited_objs:
if self.should_save:
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
if getattr(tool.Ifc.get_entity(obj), "HasOpenings", False):
self.reload_representation(obj)
else:
self.reload_representation(obj)
for obj in self.unchanged_objs_with_openings:
self.reload_representation(obj)
return {"FINISHED"}
def reload_representation(self, obj):
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
core.switch_representation(
tool.Ifc,
tool.Geometry,
obj=obj,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
apply_openings=True,
)
def draw(self, context):
if self.is_valid:
row = self.layout.row()
row.prop(self, "should_save")
else:
row = self.layout.row()
row.label(text="No Geometry Found: Object will revert to previous state.")
def invoke(self, context, event):
self.is_valid = True
self.should_save = True
bpy.ops.object.mode_set(mode="EDIT", toggle=True)
if not tool.Ifc.get():
return {"FINISHED"}
if context.active_object:
element = tool.Ifc.get_entity(context.active_object)
if element and element.is_a("IfcRelSpaceBoundary"):
return bpy.ops.bim.edit_boundary_geometry()
objs = context.selected_objects or [context.active_object]
self.edited_objs = []
self.unchanged_objs_with_openings = []
for obj in objs:
if not obj:
continue
element = tool.Ifc.get_entity(obj)
if not element:
continue
if tool.Profile.is_editing_profile():
profile_id = context.scene.BIMProfileProperties.active_profile_id
if profile_id:
profile = tool.Ifc.get().by_id(profile_id)
if tool.Ifc.get_object(profile): # We are editing an arbitrary profile
bpy.ops.bim.edit_arbitrary_profile()
elif tool.Pset.get_element_pset(element, "BBIM_Railing"):
bpy.ops.bim.cad_hotkey(hotkey="S_Q")
elif tool.Pset.get_element_pset(element, "BBIM_Roof"):
bpy.ops.bim.cad_hotkey(hotkey="S_Q")
elif tool.Model.get_usage_type(element) == "PROFILE":
bpy.ops.bim.edit_extrusion_axis()
else:
bpy.ops.bim.edit_extrusion_profile()
return self.execute(context)
elif obj.data.BIMMeshProperties.ifc_definition_id:
if not tool.Geometry.has_geometric_data(obj):
self.is_valid = False
self.should_save = False
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
if tool.Geometry.is_meshlike(
representation
) and obj.data.BIMMeshProperties.mesh_checksum != tool.Geometry.get_mesh_checksum(obj.data):
self.edited_objs.append(obj)
elif getattr(element, "HasOpenings", None):
self.unchanged_objs_with_openings.append(obj)
if self.edited_objs:
return context.window_manager.invoke_props_dialog(self)
return self.execute(context)
@@ -18,6 +18,7 @@
import bpy
from blenderbim.bim.prop import StrProperty, Attribute
from blenderbim.bim.module.geometry.data import RepresentationsData
from bpy.types import PropertyGroup
from bpy.props import (
PointerProperty,
@@ -31,6 +32,16 @@ from bpy.props import (
)
def get_contexts(self, context):
if not RepresentationsData.is_loaded:
RepresentationsData.load()
return RepresentationsData.data["contexts"]
class BIMObjectGeometryProperties(PropertyGroup):
contexts: EnumProperty(items=get_contexts, name="Contexts")
class BIMGeometryProperties(PropertyGroup):
# Revit workaround
should_use_presentation_style_assignment: BoolProperty(name="Force Presentation Style Assignment", default=False)
@@ -36,6 +36,7 @@ class BIM_PT_representations(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_geometry_object"
@classmethod
@@ -57,7 +58,7 @@ class BIM_PT_representations(Panel):
layout.label(text="No representations found")
row = layout.row(align=True)
prop_with_search(row, context.scene.BIMRootProperties, "contexts", text="")
prop_with_search(row, context.active_object.BIMGeometryProperties, "contexts", text="")
row.operator("bim.add_representation", icon="ADD", text="")
for representation in RepresentationsData.data["representations"]:
@@ -66,7 +67,7 @@ class BIM_PT_representations(Panel):
row.label(text=representation["ContextIdentifier"])
row.label(text=representation["TargetView"])
row.label(text=representation["RepresentationType"])
op = row.operator("bim.switch_representation", icon="OUTLINER_DATA_MESH", text="")
op = row.operator("bim.switch_representation", icon="FILE_REFRESH" if representation["is_active"] else "OUTLINER_DATA_MESH", text="")
op.should_switch_all_meshes = True
op.should_reload = True
op.ifc_definition_id = representation["id"]
@@ -81,6 +82,7 @@ class BIM_PT_connections(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_geometry_object"
@classmethod
@@ -185,6 +187,7 @@ class BIM_PT_derived_placements(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "OBJECT_PT_transform"
def draw(self, context):
@@ -49,7 +49,7 @@ class BIM_OT_cityjson2ifc(Operator):
class BIM_OT_find_cityjson_lod(Operator):
bl_idname = "bim.find_cityjson_lod"
bl_label = "Find LODs in CityJSON file"
bl_label = "Find LODs in CityJSON File"
bl_context = "scene"
def execute(self, context):
@@ -33,6 +33,7 @@ classes = (
operator.ToggleGroup,
operator.UnassignGroup,
operator.UpdateGroup,
operator.SelectGroupElements,
prop.ExpandedGroups,
prop.Group,
prop.BIMGroupProperties,
@@ -275,3 +275,19 @@ class UpdateGroup(bpy.types.Operator, tool.Ifc.Operator):
)
bpy.ops.bim.load_groups()
return {"FINISHED"}
class SelectGroupElements(bpy.types.Operator):
bl_idname = "bim.select_group_elements"
bl_label = "Select Group elements"
bl_options = {"REGISTER", "UNDO"}
group: bpy.props.IntProperty()
@classmethod
def poll(cls, context):
return bool(tool.Ifc.get() and context.active_object)
def execute(self, context):
elements = tool.Drawing.get_group_elements(tool.Ifc.get().by_id(self.group))
tool.Spatial.select_products(elements)
return {"FINISHED"}
@@ -75,6 +75,7 @@ class BIM_PT_object_groups(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_utilities_object"
@classmethod
@@ -106,6 +107,7 @@ class BIM_PT_object_groups(Panel):
for group in ObjectGroupsData.data["groups"]:
row = self.layout.row(align=True)
row.label(text=group["name"])
row.operator("bim.select_group_elements", text="", icon="RESTRICT_SELECT_OFF").group = group["id"]
op = row.operator("bim.unassign_group", text="", icon="X")
op.group = group["id"]
@@ -0,0 +1,54 @@
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# 2023 Bruno Postle <bruno@postle.net>, Bruno Perdigão <brunoperdigao@tutanota.com>,
# Massimo Fabbro <maxfb87@yahoo.it>
import bpy
from . import ui, prop, operator
classes = (
operator.AddFileToRepo,
operator.AddRemote,
operator.AddTag,
operator.CloneRepo,
operator.CommitChanges,
operator.CreateRepo,
operator.DeleteRemote,
operator.DeleteTag,
operator.DiscardUncommitted,
operator.DisplayRevision,
operator.DisplayUncommitted,
operator.Fetch,
operator.Merge,
operator.ObjectLog,
operator.Push,
operator.RefreshGit,
operator.SwitchRevision,
prop.IfcGitTag,
prop.IfcGitListItem,
prop.IfcGitProperties,
ui.IFCGIT_PT_panel,
ui.COMMIT_UL_List,
ui.IFCGIT_PT_revision_inspector,
)
def register():
bpy.types.Scene.IfcGitProperties = bpy.props.PointerProperty(type=prop.IfcGitProperties)
def unregister():
del bpy.types.Scene.IfcGitProperties
@@ -0,0 +1,174 @@
import bpy
import os
import shutil
# import tool
import blenderbim.tool as tool
def refresh():
IfcGitData.is_loaded = False
class IfcGitData:
data = {}
is_loaded = False
@classmethod
def make_sure_is_loaded(cls):
if not cls.is_loaded:
cls.load()
@classmethod
def load(cls):
cls.data = {
"repo": cls.repo(),
"remotes": cls.remotes(),
"branch_names": cls.branch_names(),
"remote_names": cls.remote_names(),
"remote_urls": cls.remote_urls(),
"path_ifc": cls.path_ifc(),
"branches_by_hexsha": cls.branches_by_hexsha(),
"tags_by_hexsha": cls.tags_by_hexsha(),
"name_ifc": cls.name_ifc(),
"dir_name": cls.dir_name(),
"base_name": cls.base_name(),
"working_dir": cls.working_dir(),
"untracked_files": cls.untracked_files(),
"is_detached": cls.is_detached(),
"active_branch_name": cls.active_branch_name(),
"is_dirty": cls.is_dirty(),
"commit": cls.commit(),
"current_revision": cls.current_revision(),
"git_exe": cls.git_exe(),
"ifcmerge_exe": cls.ifcmerge_exe(),
}
cls.is_loaded = True
@classmethod
def repo(cls):
if bool(tool.Ifc.get()):
path_ifc = tool.Ifc.get_path()
if os.path.isfile(path_ifc):
return tool.IfcGit.repo_from_path(path_ifc)
return None
@classmethod
def remotes(cls):
if cls.repo():
return cls.repo().remotes
return None
@classmethod
def branch_names(cls):
return []
@classmethod
def remote_names(cls):
return []
@classmethod
def remote_urls(cls):
result = {}
if cls.repo():
for remote in cls.repo().remotes:
result[remote.name] = remote.url
return result
@classmethod
def path_ifc(cls):
path_ifc = tool.Ifc.get_path()
if os.path.isfile(path_ifc):
return tool.Ifc.get_path()
return None
@classmethod
def branches_by_hexsha(cls):
try:
if tool.IfcGitRepo.repo.branches:
return tool.IfcGit.branches_by_hexsha(tool.IfcGitRepo.repo)
except:
return {}
@classmethod
def tags_by_hexsha(cls):
if tool.IfcGitRepo.repo:
return tool.IfcGit.tags_by_hexsha(tool.IfcGitRepo.repo)
return {}
@classmethod
def name_ifc(cls):
if bool(tool.Ifc.get()):
path_ifc = tool.Ifc.get_path()
if tool.IfcGitRepo.repo and os.path.isfile(path_ifc):
working_dir = tool.IfcGitRepo.repo.working_dir
return os.path.relpath(path_ifc, working_dir)
return None
@classmethod
def dir_name(cls):
if bool(tool.Ifc.get()):
path_ifc = tool.Ifc.get_path()
if os.path.isfile(path_ifc):
return os.path.dirname(path_ifc)
return None
@classmethod
def base_name(cls):
if bool(tool.Ifc.get()):
path_ifc = tool.Ifc.get_path()
if os.path.isfile(path_ifc):
return os.path.basename(path_ifc)
return None
@classmethod
def working_dir(cls):
if cls.repo():
return cls.repo().working_dir
@classmethod
def untracked_files(cls):
if cls.repo():
return cls.repo().untracked_files
return []
@classmethod
def is_detached(cls):
if cls.repo():
return cls.repo().head.is_detached
@classmethod
def active_branch_name(cls):
if cls.repo() and not cls.is_detached():
return cls.repo().active_branch.name
@classmethod
def is_dirty(cls):
if cls.repo() and cls.git_exe():
path_ifc = tool.Ifc.get_path()
if os.path.isfile(path_ifc):
return cls.repo().is_dirty(path=path_ifc)
return False
@classmethod
def commit(cls):
props = bpy.context.scene.IfcGitProperties
if len(props.ifcgit_commits) > 0:
item = props.ifcgit_commits[props.commit_index]
if cls.repo():
return cls.repo().commit(rev=item.hexsha)
@classmethod
def current_revision(cls):
props = bpy.context.scene.IfcGitProperties
if len(props.ifcgit_commits) > 0:
return tool.IfcGitRepo.repo.commit()
@classmethod
def git_exe(cls):
return shutil.which("git")
@classmethod
def ifcmerge_exe(cls):
return shutil.which("ifcmerge")
@@ -0,0 +1,387 @@
import os
import re
import bpy
import blenderbim.core.ifcgit as core
import blenderbim.tool as tool
from blenderbim.bim.module.ifcgit.data import IfcGitData, refresh
class CreateRepo(bpy.types.Operator):
"""Initialise a Git repository"""
bl_label = "Create Git repository"
bl_idname = "ifcgit.createrepo"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
path_ifc = IfcGitData.data["path_ifc"]
if not os.path.isfile(path_ifc):
return False
if IfcGitData.data["repo"]:
# repo already exists
return False
if re.match("^/home/[^/]+/?$", os.path.dirname(path_ifc)):
# don't make ${HOME} a repo
return False
return True
def execute(self, context):
core.create_repo(tool.IfcGit, tool.Ifc)
refresh()
return {"FINISHED"}
class AddFileToRepo(bpy.types.Operator):
"""Add a file to a repository"""
bl_label = "Add file to repository"
bl_idname = "ifcgit.addfile"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
path_ifc = IfcGitData.data["path_ifc"]
if not os.path.isfile(path_ifc):
return False
if not IfcGitData.data["repo"]:
# repo doesn't exist
return False
return True
def execute(self, context):
core.add_file(tool.IfcGit, tool.Ifc)
refresh()
return {"FINISHED"}
class CloneRepo(bpy.types.Operator):
"""Clone a remote Git repository"""
bl_label = "Clone repository"
bl_idname = "ifcgit.clone_repo"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
props = context.scene.IfcGitProperties
if (
props.remote_url
and props.local_folder
and os.path.isdir(props.local_folder)
and not os.listdir(props.local_folder)
):
return True
return False
def execute(self, context):
props = context.scene.IfcGitProperties
core.clone_repo(tool.IfcGit, props.remote_url, props.local_folder, self)
props.remote_url = ""
refresh()
return {"FINISHED"}
class DiscardUncommitted(bpy.types.Operator):
"""Discard saved changes and update to HEAD"""
bl_label = "Discard uncommitted changes"
bl_idname = "ifcgit.discard"
bl_options = {"REGISTER"}
def execute(self, context):
core.discard_uncomitted(tool.IfcGit, tool.Ifc)
refresh()
return {"FINISHED"}
class CommitChanges(bpy.types.Operator):
"""Commit current saved changes"""
bl_label = "Commit changes"
bl_idname = "ifcgit.commit_changes"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
props = context.scene.IfcGitProperties
repo = IfcGitData.data["repo"]
if props.commit_message == "":
return False
if (
repo
and repo.head.is_detached
and (
not tool.IfcGit.is_valid_ref_format(props.new_branch_name)
or props.new_branch_name in [branch.name for branch in repo.branches]
)
):
cls.poll_message_set(
"The new branch name is invalid, please insert a valid branch name (eg. with no spaces, ...)"
)
return False
return True
def execute(self, context):
repo = IfcGitData.data["repo"]
core.commit_changes(tool.IfcGit, tool.Ifc, repo)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
class AddTag(bpy.types.Operator):
"""Tag selected revision"""
bl_label = "Tag selected revision"
bl_idname = "ifcgit.add_tag"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
props = context.scene.IfcGitProperties
if props.new_tag_name == "":
return False
repo = IfcGitData.data["repo"]
if repo and (
not tool.IfcGit.is_valid_ref_format(props.new_tag_name)
or props.new_tag_name in [tag.name for tag in repo.tags]
):
return False
return True
def execute(self, context):
repo = IfcGitData.data["repo"]
core.add_tag(tool.IfcGit, repo)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
class DeleteTag(bpy.types.Operator):
"""Delete a tag"""
bl_label = "Delete tag"
bl_idname = "ifcgit.delete_tag"
bl_options = {"REGISTER"}
tag_name: bpy.props.StringProperty()
def execute(self, context):
repo = IfcGitData.data["repo"]
core.delete_tag(tool.IfcGit, repo, self.tag_name)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
class RefreshGit(bpy.types.Operator):
"""Refresh revision list"""
bl_label = ""
bl_idname = "ifcgit.refresh"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
repo = IfcGitData.data["repo"]
if repo:
return True
return False
def execute(self, context):
repo = IfcGitData.data["repo"]
core.refresh_revision_list(tool.IfcGit, repo, tool.Ifc)
refresh()
return {"FINISHED"}
class DisplayRevision(bpy.types.Operator):
"""Colourise objects by selected revision"""
bl_label = ""
bl_idname = "ifcgit.display_revision"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
props = context.scene.IfcGitProperties
if props.ifcgit_commits:
return True
def execute(self, context):
core.colourise_revision(tool.IfcGit)
refresh()
return {"FINISHED"}
class DisplayUncommitted(bpy.types.Operator):
"""Colourise uncommitted objects"""
bl_label = "Show uncommitted changes"
bl_idname = "ifcgit.display_uncommitted"
bl_options = {"REGISTER"}
def execute(self, context):
repo = IfcGitData.data["repo"]
core.colourise_uncommitted(tool.IfcGit, tool.Ifc, repo)
refresh()
return {"FINISHED"}
class SwitchRevision(bpy.types.Operator):
"""Switches the repository to the selected revision and reloads the IFC file"""
bl_label = ""
bl_idname = "ifcgit.switch_revision"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
props = context.scene.IfcGitProperties
if props.ifcgit_commits:
return True
def execute(self, context):
core.switch_revision(tool.IfcGit, tool.Ifc)
refresh()
return {"FINISHED"}
class Merge(bpy.types.Operator):
"""Merges the selected branch into working branch"""
bl_label = "Merge this branch"
bl_idname = "ifcgit.merge"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
props = context.scene.IfcGitProperties
if IfcGitData.data["ifcmerge_exe"] and props.ifcgit_commits and not IfcGitData.data["is_detached"]:
return True
return False
def execute(self, context):
if core.merge_branch(tool.IfcGit, tool.Ifc, self):
refresh()
return {"FINISHED"}
else:
return {"CANCELLED"}
class Push(bpy.types.Operator):
"""Pushes the working branch to selected remote"""
bl_label = "Push working branch"
bl_idname = "ifcgit.push"
bl_options = {"REGISTER"}
def execute(self, context):
props = context.scene.IfcGitProperties
repo = IfcGitData.data["repo"]
core.push(tool.IfcGit, repo, props.select_remote, self)
return {"FINISHED"}
class Fetch(bpy.types.Operator):
"""Fetches from the selected remote"""
bl_label = "Fetch from remote"
bl_idname = "ifcgit.fetch"
bl_options = {"REGISTER"}
def execute(self, context):
props = context.scene.IfcGitProperties
repo = IfcGitData.data["repo"]
remote = repo.remotes[props.select_remote]
remote.fetch()
return {"FINISHED"}
class AddRemote(bpy.types.Operator):
"""Add a remote repository"""
bl_label = "Add Remote"
bl_idname = "ifcgit.add_remote"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
IfcGitData.make_sure_is_loaded()
props = context.scene.IfcGitProperties
repo = IfcGitData.data["repo"]
if (
not repo
or not tool.IfcGit.is_valid_ref_format(props.remote_name)
or not props.remote_url
or props.remote_name in [remote.name for remote in repo.remotes]
):
return False
return True
def execute(self, context):
repo = IfcGitData.data["repo"]
core.add_remote(tool.IfcGit, repo)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
class DeleteRemote(bpy.types.Operator):
"""Delete the selected remote"""
bl_label = "Delete Remote"
bl_idname = "ifcgit.delete_remote"
bl_options = {"REGISTER"}
def execute(self, context):
repo = IfcGitData.data["repo"]
core.delete_remote(tool.IfcGit, repo)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
class ObjectLog(bpy.types.Operator):
"""Displays Git log of selected object"""
bl_label = "Selected Object History"
bl_idname = "ifcgit.object_log"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
if not context.active_object:
cls.poll_message_set("No Active Object")
elif not context.active_object.BIMObjectProperties.ifc_definition_id:
cls.poll_message_set("Active Object doesn't have an IFC definition")
else:
return True
def execute(self, context):
step_id = context.active_object.BIMObjectProperties.ifc_definition_id
core.entity_log(tool.IfcGit, tool.Ifc, step_id, self)
return {"FINISHED"}
@@ -0,0 +1,142 @@
import bpy
from bpy.types import PropertyGroup
from bpy.props import (
StringProperty,
BoolProperty,
CollectionProperty,
IntProperty,
EnumProperty,
)
from blenderbim.bim.module.ifcgit.data import IfcGitData
def git_branches(self, context):
"""branches enum"""
# NOTE "Python must keep a reference to the strings returned by
# the callback or Blender will misbehave or even crash"
IfcGitData.data["branch_names"] = sorted([branch.name for branch in IfcGitData.data["repo"].heads])
if "main" in IfcGitData.data["branch_names"]:
IfcGitData.data["branch_names"].remove("main")
IfcGitData.data["branch_names"] = ["main"] + IfcGitData.data["branch_names"]
if IfcGitData.data["remotes"]:
for remote in IfcGitData.data["remotes"]:
for remote_branch in remote.refs:
IfcGitData.data["branch_names"].append(remote_branch.name)
return [(myname, myname, myname) for myname in IfcGitData.data["branch_names"]]
def git_remotes(self, context):
"""remotes enum"""
IfcGitData.data["remote_names"] = sorted([remote.name for remote in IfcGitData.data["remotes"]])
if "origin" in IfcGitData.data["remote_names"]:
IfcGitData.data["remote_names"].remove("origin")
IfcGitData.data["remote_names"] = ["origin"] + IfcGitData.data["remote_names"]
return [(myname, myname, myname) for myname in IfcGitData.data["remote_names"]]
def update_revlist(self, context):
"""wrapper to trigger update of the revision list"""
bpy.ops.ifcgit.refresh()
props = context.scene.IfcGitProperties
props.commit_index = 0
class IfcGitTag(PropertyGroup):
"""Properties of a Git tag"""
name: StringProperty(
name="Tag name",
default="",
)
message: StringProperty(
name="Tag message",
default="",
)
class IfcGitListItem(PropertyGroup):
"""Group of properties representing an item in the list."""
hexsha: StringProperty(
name="Git hash",
description="checksum for this commit",
default="Uncommitted data!",
)
relevant: BoolProperty(
name="Is relevant",
description="does this commit reference our ifc file",
default=False,
)
author_name: StringProperty(
name="Author Name",
default="",
)
author_email: StringProperty(
name="Author Email",
default="",
)
message: StringProperty(
name="Commit Message",
default="",
)
tags: CollectionProperty(type=IfcGitTag, name="List of revision tags")
class IfcGitProperties(PropertyGroup):
ifcgit_commits: CollectionProperty(type=IfcGitListItem, name="List of git items")
commit_index: IntProperty(name="Index for my_list", default=0)
commit_message: StringProperty(
name="Commit message",
description="A human readable description of these changes",
default="",
)
new_branch_name: StringProperty(
name="New branch name",
description="A short name used to refer to this branch",
default="",
)
new_tag_name: StringProperty(
name="New tag name",
description="A short name used to refer to this tag",
default="",
)
new_tag_message: StringProperty(
name="Tag message (optional)",
description="An optional human readable description of this tag",
default="",
)
remote_name: StringProperty(
name="New remote name",
description="A local name for a remote Git repository",
default="",
)
remote_url: StringProperty(
name="Git URL",
description="A URL pointing to a Git repository",
default="",
)
local_folder: StringProperty(
name="Local folder",
description="A local Git repository path",
default="",
subtype="DIR_PATH",
)
display_branch: EnumProperty(items=git_branches, update=update_revlist)
select_remote: EnumProperty(items=git_remotes)
ifcgit_filter: EnumProperty(
items=[
("all", "All", "All revisions"),
("tagged", "Tagged", "Tagged revisions"),
("relevant", "Relevant", "Revisions for this project"),
],
update=update_revlist,
)
@@ -0,0 +1,241 @@
import bpy
import time
from blenderbim.bim.module.ifcgit.data import IfcGitData
class IFCGIT_PT_panel(bpy.types.Panel):
"""Scene Properties panel to interact with IFC repository data"""
bl_label = "IFC Git"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "BIM_PT_project_info"
def draw(self, context):
if not IfcGitData.is_loaded:
IfcGitData.load()
layout = self.layout
path_ifc = IfcGitData.data["path_ifc"]
if not IfcGitData.data["git_exe"]:
row = layout.row()
row.label(text="Git is not installed", icon="ERROR")
return
props = context.scene.IfcGitProperties
# TODO if file isn't saved, offer to save to disk
row = layout.row()
if path_ifc:
if IfcGitData.data["repo"]:
name_ifc = IfcGitData.data["name_ifc"]
row.label(text=IfcGitData.data["working_dir"], icon="SYSTEM")
if name_ifc in IfcGitData.data["untracked_files"]:
row.operator(
"ifcgit.addfile",
text="Add '" + name_ifc + "' to repository",
icon="FILE",
)
else:
row.label(text=name_ifc, icon="FILE")
else:
row.operator(
"ifcgit.createrepo",
text="Create '" + IfcGitData.data["dir_name"] + "' repository",
icon="SYSTEM",
)
row.label(text=IfcGitData.data["base_name"], icon="FILE")
return
else:
row.label(text="No Git repository found", icon="SYSTEM")
row.label(text="No IFC project saved", icon="FILE")
box = layout.box()
row = box.row()
row.label(text="Clone a remote Git repository")
row = box.row()
row.prop(props, "remote_url")
row = box.row()
row.prop(props, "local_folder")
row = box.row()
row.operator("ifcgit.clone_repo", icon="IMPORT")
return
is_dirty = IfcGitData.data["is_dirty"]
if is_dirty:
row = layout.row()
row.label(text="Saved changes have not been committed", icon="ERROR")
row = layout.row()
row.operator("ifcgit.display_uncommitted", icon="SELECT_DIFFERENCE")
row.operator("ifcgit.discard", icon="TRASH")
row = layout.row()
row.prop(props, "commit_message")
if IfcGitData.data["is_detached"]:
row = layout.row()
row.label(text="HEAD is detached, commit will create a branch", icon="ERROR")
row.prop(props, "new_branch_name")
row = layout.row()
row.operator("ifcgit.commit_changes", icon="GREASEPENCIL")
row = layout.row()
if IfcGitData.data["is_detached"]:
row.label(text="Working branch: Detached HEAD")
else:
row.label(text="Working branch: " + IfcGitData.data["active_branch_name"])
grouped = layout.row()
column = grouped.column()
row = column.row()
row.prop(props, "display_branch", text="Browse branch")
row.prop(props, "ifcgit_filter", text="Filter revisions")
row = column.row()
row.template_list(
"COMMIT_UL_List",
"The_List",
props,
"ifcgit_commits",
props,
"commit_index",
)
column = grouped.column()
row = column.row()
row.operator("ifcgit.refresh", icon="FILE_REFRESH")
if not is_dirty:
row = column.row()
row.operator("ifcgit.display_revision", icon="SELECT_DIFFERENCE")
row = column.row()
row.operator("ifcgit.switch_revision", icon="CURRENT_FILE")
row = column.row()
row.operator("ifcgit.merge", icon="EXPERIMENTAL", text="")
if not props.ifcgit_commits:
return
item = props.ifcgit_commits[props.commit_index]
if not item.relevant:
row = layout.row()
row.label(text="Revision unrelated to current IFC project", icon="ERROR")
box = layout.box()
column = box.column(align=True)
row = column.row()
row.label(text=item.hexsha)
row = column.row()
row.label(text=item.author_name + " <" + item.author_email + ">")
for message_line in item.message.split("\n"):
row = column.row()
row.label(text=message_line)
for tag in item.tags:
box = layout.box()
item = box.row()
column = item.column(align=True)
row = column.row()
row.label(text=tag.name)
row.operator("ifcgit.delete_tag", icon="PANEL_CLOSE").tag_name = tag.name
if tag.message:
for message_line in tag.message.split("\n"):
row = column.row()
row.label(text=message_line)
box = layout.box()
row = box.row()
row.prop(props, "new_tag_name")
row = box.row()
row.prop(props, "new_tag_message")
row = box.row()
row.operator("ifcgit.add_tag", icon="GREASEPENCIL")
if IfcGitData.data["remotes"]:
row = layout.row()
row.prop(props, "select_remote", text="Select remote")
urls = IfcGitData.data["remote_urls"]
row.label(text=urls[props.select_remote])
row.operator("ifcgit.delete_remote", text="", icon="PANEL_CLOSE")
row = layout.row()
row.operator("ifcgit.push", icon="EXPORT")
row.operator("ifcgit.fetch", icon="IMPORT")
box = layout.box()
row = box.row()
row.prop(props, "remote_name")
row = box.row()
row.prop(props, "remote_url")
row = box.row()
row.operator("ifcgit.add_remote", icon="ADD")
class COMMIT_UL_List(bpy.types.UIList):
"""List of Git commits"""
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
props = context.scene.IfcGitProperties
current_revision = IfcGitData.data["current_revision"]
# TODO Figure how this "item" can be acesse in "data.py"
# so it's possible to move the ".commit"
commit = IfcGitData.data["repo"].commit(rev=item.hexsha)
lookup = IfcGitData.data["branches_by_hexsha"]
refs = ""
if item.hexsha in lookup:
for branch in lookup[item.hexsha]:
if branch.name == props.display_branch:
refs = "[" + branch.name + "] "
lookup = IfcGitData.data["tags_by_hexsha"]
if item.hexsha in lookup:
for tag in lookup[item.hexsha]:
refs += "{" + tag.name + "} "
if commit == current_revision:
layout.label(text="[HEAD] " + refs + commit.message.split("\n")[0], icon="DECORATE_KEYFRAME")
else:
layout.label(text=refs + commit.message.split("\n")[0], icon="DECORATE_ANIMATE")
layout.label(text=time.strftime("%c", time.localtime(commit.committed_date)))
class IFCGIT_PT_revision_inspector(bpy.types.Panel):
"""Tool panel to interact with revision history"""
bl_idname = "IFCGIT_PT_revision_inspector"
bl_label = "Git History"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "BlenderBIM"
def draw(self, context):
if not IfcGitData.is_loaded:
IfcGitData.load()
layout = self.layout
if not IfcGitData.data["git_exe"]:
row = layout.row()
row.label(text="Git is not installed", icon="ERROR")
return
row = layout.row()
row.operator(
"ifcgit.object_log",
icon="TEXT",
)
@@ -100,6 +100,7 @@ class BIM_PT_library_references(Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
bl_order = 1
bl_parent_id = "BIM_PT_misc_object"
@classmethod
@@ -31,13 +31,16 @@ classes = (
operator.ContractMaterialCategory,
operator.CopyMaterial,
operator.DisableEditingAssignedMaterial,
operator.DisableEditingMaterial,
operator.DisableEditingMaterials,
operator.DisableEditingMaterialSetItem,
operator.DisableEditingMaterialSetItemProfile,
operator.DisableEditingMaterials,
operator.EditAssignedMaterial,
operator.EditMaterial,
operator.EditMaterialSetItem,
operator.EditMaterialSetItemProfile,
operator.EnableEditingAssignedMaterial,
operator.EnableEditingMaterial,
operator.EnableEditingMaterialSetItem,
operator.EnableEditingMaterialSetItemProfile,
operator.ExpandMaterialCategory,
@@ -96,6 +96,7 @@ class ObjectMaterialData:
cls.data["total_thickness"] = cls.total_thickness()
cls.data["materials"] = cls.materials()
cls.data["type_material"] = cls.type_material()
cls.data["material_type"] = cls.material_type()
cls.is_loaded = True
@classmethod
@@ -244,3 +245,17 @@ class ObjectMaterialData:
else:
name_attr = "Name"
return getattr(material, name_attr, "Unnamed") or "Unnamed"
@classmethod
def material_type(cls):
material_types = [
"IfcMaterial",
"IfcMaterialConstituentSet",
"IfcMaterialLayerSet",
"IfcMaterialProfileSet",
"IfcMaterialList",
]
version = tool.Ifc.get_schema()
if version == "IFC2X3":
material_types = ["IfcMaterial", "IfcMaterialLayerSet", "IfcMaterialList"]
return [(m, m, ifcopenshell.util.doc.get_entity_doc(version, m).get("description", "")) for m in material_types]

Some files were not shown because too many files have changed in this diff Show More