-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better openings, speed and stability improvements
- openings(cutting components) now still cut holes when overlapping and on/over the face edges - Speed improvements by replacing individual "add_face" calls with "fill_from_mesh" - Stability improvements because of better use of observers. - Removed the GUID field from the menu because it doesn't match the IFC export GUID - fix side-faces normal direction in openings
- Loading branch information
1 parent
5afe576
commit 67e4990
Showing
10 changed files
with
714 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# bim-tools.rb | ||
# | ||
# Copyright (C) 2015 Jan Brouwer <[email protected]> | ||
# Copyright (C) 2016 Jan Brouwer <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -15,16 +15,6 @@ | |
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# roadmap: | ||
# columns | ||
|
||
# roadmap 0.14: | ||
# fix side-faces normal direction in openings | ||
# fix project properties(different way of reading/writing properties? one at a time instead of array?) | ||
# get rid of entitiesobservers | ||
# improve IFC export | ||
# speed up hidden edges | ||
|
||
require 'sketchup.rb' | ||
require 'extensions.rb' | ||
|
||
|
@@ -43,7 +33,7 @@ module BimTools | |
|
||
# Create Extension | ||
bimtools = SketchupExtension.new "bim-tools", File.join( PATH, 'bim-tools_loader.rb' ) | ||
bimtools.version = '0.13.4' | ||
bimtools.version = '0.14.0' | ||
bimtools.description = "Tools to create building parts and export these to IFC." | ||
Sketchup.register_extension bimtools, true | ||
end # module BimTools | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# clsBtProject.rb | ||
# | ||
# Copyright (C) 2012 Jan Brouwer <[email protected]> | ||
# Copyright (C) 2016 Jan Brouwer <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -58,7 +58,6 @@ def initialize(id=nil, name=nil, description=nil) | |
set_organisation_name #@organisation_name = @default.get("organisation_name") | ||
set_organisation_description #@organisation_description = @default.get("organisation_description") | ||
|
||
|
||
# set initial value for toggle button | ||
toggle_value = @model.get_attribute "bim-tools", "visible_geometry" | ||
|
||
|
@@ -72,10 +71,10 @@ def initialize(id=nil, name=nil, description=nil) | |
@visible_geometry = true | ||
end | ||
|
||
@lib = ClsBtLibrary.new # would ClsBtEntities be a better name? | ||
@lib = ClsBtLibrary.new #(?) would ClsBtEntities be a better name? | ||
|
||
@source_tracker = SourceTracker.new(self) | ||
#id=#("id") # do or do not use "project" in method names? | ||
#id=#("id") #(?) do or do not use "project" in method names? | ||
name=()#("name") | ||
description=()#("description") | ||
|
||
|
@@ -174,29 +173,10 @@ def new_guid | |
guid = '';22.times{|i|guid<<'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$'[rand(64)]} | ||
return guid | ||
end | ||
# def name=(name=nil) | ||
# | ||
# # check if active_model already contains BtProject / IFC data and pass these to the project instance. | ||
# if name.nil? | ||
# @name = @model.get_attribute "ifc", "IfcProject_Name", nil | ||
# else | ||
# @name = name | ||
# @model.set_attribute "ifc", "IfcProject_Name", @name | ||
# end | ||
# end | ||
# def description=(description=nil) | ||
# | ||
# # check if active_model already contains BtProject / IFC data and pass these to the project instance. | ||
# if description.nil? | ||
# @description = @model.get_attribute "ifc", "IfcProject_Description", nil | ||
# else | ||
# @description = description | ||
# @model.set_attribute "ifc", "IfcProject_Description", @description | ||
# end | ||
# end | ||
# this method is used to update / set the value of several project-data-fields(such as name and description) | ||
def set_project_data(new_value, old_value, ifc_name, default_name) | ||
# new_value = (optional) new name | ||
# old_value = current name | ||
# ifc_name = name of the IFC value field in the project´s ifc attributes | ||
|
@@ -364,7 +344,7 @@ def refresh_geometry(bt_entity) | |
UI.stop_timer( @delay ) | ||
# temporarily turn off observers to prevent creating geometry multiple times | ||
Brewsky::BimTools::ObserverManager.toggle | ||
Brewsky::BimTools::ObserverManager.suspend | ||
@model = Sketchup.active_model | ||
|
@@ -433,7 +413,7 @@ def refresh_geometry(bt_entity) | |
@model.active_view.refresh # Refresh model | ||
# switch observers back on | ||
Brewsky::BimTools::ObserverManager.toggle | ||
Brewsky::BimTools::ObserverManager.resume | ||
} | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# ObserverManager.rb | ||
# | ||
# Copyright (C) 2015 Jan Brouwer <[email protected]> | ||
# Copyright (C) 2016 Jan Brouwer <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -135,6 +135,20 @@ def deactivate | |
|
||
# what to do when component is placed? cut hole if possible. | ||
def onElementAdded(entities, entity) | ||
if entity.is_a?(Sketchup::ComponentInstance) | ||
unless entity.glued_to.nil? | ||
source = entity.glued_to | ||
|
||
# run only if added entity cuts_opening | ||
if entity.definition.behavior.cuts_opening? | ||
|
||
# check if entity is part of a building element | ||
if bt_entity = BimTools.active_BtProject.library.source_to_bt_entity(BimTools.active_BtProject, source) | ||
bt_entity.update_geometry | ||
end | ||
end | ||
end | ||
end | ||
|
||
# if cutting-component? | ||
# if glued? | ||
|
@@ -250,6 +264,20 @@ def self.toggle | |
self.load | ||
end | ||
end | ||
|
||
#temporarily deactivate observers | ||
def self.suspend | ||
@app_observer.deactivate | ||
@entities_observer.deactivate | ||
@selection_observer.deactivate | ||
end | ||
|
||
#reactivate suspended observers | ||
def self.resume | ||
@app_observer.activate | ||
@entities_observer.activate | ||
@selection_observer.activate | ||
end | ||
end # module ObserverManager | ||
end # module BimTools | ||
end # module Brewsky |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# clsBuildingElement.rb | ||
# | ||
# Copyright (C) 2012 Jan Brouwer <[email protected]> | ||
# Copyright (C) 2016 Jan Brouwer <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -39,10 +39,6 @@ def deleted? | |
|
||
# if source object is unrecoverable, self_destruct bt_entity | ||
def self_destruct | ||
|
||
# get connecting entities for updating geometry after deletion | ||
edges = self.source.edges # works only for face! | ||
|
||
@deleted = true | ||
unless @source.deleted? | ||
source.hidden= false | ||
|
@@ -51,27 +47,22 @@ def self_destruct | |
if @source.attribute_dictionaries | ||
@source.attribute_dictionaries.delete 'ifc' | ||
end | ||
|
||
# get connecting entities for updating geometry after deletion | ||
edges = self.source.edges # works only for face! | ||
|
||
# update connecting bt_entities | ||
find_linked_elements() | ||
end | ||
|
||
unless @geometry.deleted? | ||
@geometry.erase! | ||
end | ||
|
||
# remobe bt_entity from library | ||
@project.library.entities.delete(self) | ||
|
||
# update connecting geometry after deletion | ||
a_connecting_faces = Array.new # Array to hold al connecting faces | ||
edges.each do |edge| | ||
unless edge.deleted? | ||
edge.faces.each do |face| | ||
# add only bt-source-faces to array, bt-entities must not react to "normal" faces | ||
if @project.library.source_to_bt_entity(@project, face) | ||
a_connecting_faces << @project.library.source_to_bt_entity(@project, face) # shorter?????? | ||
end | ||
end | ||
end | ||
end | ||
@project.bt_entities_set_geometry(a_connecting_faces) | ||
@project.bt_entities_set_geometry(@linked_elements) | ||
end | ||
|
||
# hide OR geometry OR source | ||
|
@@ -146,9 +137,21 @@ def element_type=(type) | |
|
||
# checks if the source entity is valid, and if not searches for new source entity | ||
def check_source | ||
if @source.deleted? | ||
@project.source_recovery | ||
if @deleted == true | ||
self_destruct | ||
return false | ||
else | ||
if @source.deleted? | ||
|
||
# when to use source_recovery or find_source???????????????? | ||
#@project.source_recovery | ||
if find_source == false | ||
self_destruct | ||
return false | ||
end | ||
end | ||
end | ||
return true | ||
end | ||
|
||
# checks if the geometry group is valid, and if not creates new geometry | ||
|
@@ -158,14 +161,19 @@ def check_geometry | |
end | ||
end | ||
|
||
# (?) search only in root entities collection? | ||
# if source object = renamed, find the new name | ||
def find_source | ||
entities = Sketchup.active_model.entities | ||
entities.each do |entity| | ||
guid = entity.get_attribute "ifc", "guid" | ||
if guid == @guid | ||
@source = entity | ||
break | ||
entities.each do |ent| | ||
if ent.is_a? Sketchup::Face # (!) only faces? | ||
guid = ent.get_attribute "ifc", "guid" | ||
if guid == @guid | ||
@source = ent | ||
return @source | ||
else | ||
return false | ||
end | ||
end | ||
end | ||
end | ||
|
@@ -185,17 +193,6 @@ def find_source | |
def set_guid | ||
@guid = @project.new_guid | ||
end | ||
def find_bt_entity_for_face(source) | ||
bt_entity = nil | ||
@project.library.entities.each do |ent| | ||
if source == ent.source # als het vlak voorkomt in de bt-library | ||
bt_entity = ent | ||
break | ||
end | ||
end | ||
bt_entity | ||
return bt_entity | ||
end | ||
end | ||
end # module BimTools | ||
end # module Brewsky |
Oops, something went wrong.