Good to know it!!
I have tested and a lot of information is lost. All IFC info is not imported. But it’s a good workarround when you receive a model using Trimble as CDE.
I’m thinking now if could be possible with point clouds models.I have to try it.
Here is it…
EDITED according @dezmo suggestions below.
module Rtches
module CreateIfcTagsStructure
def self.add_layer_include(dict_name, comp_def, layer_name)
layer_name.add(dict_name)
comp_def.instances.each{|inst| inst.layer=dict_name}
@type_list.push(dict_name)
end
def self.check_component_aply(comp_def, layer_name)
dict = comp_def.attribute_dictionary("AppliedSchemaTypes")
return unless dict #has no Schema
checkifc23 = comp_def.attribute_dictionary("IFC 2x3") #is ifc 2x3
checkifc4 = comp_def.attribute_dictionary("IFC 4") #is ifc 4
if checkifc23 # ifc schema 2x3
add_layer_include(dict["IFC 2x3"], comp_def, layer_name)
elsif checkifc4 # ifc schema 2x3
add_layer_include(dict["IFC 4"], comp_def, layer_name)
end
end
def self.create_apply_tags()
model = Sketchup.active_model
layers = model.layers
defs = model.definitions
model.start_operation('Ifc to Tag',true)
@type_list = []
defs.each do |comp_def|
check_component_aply(comp_def, layers)
end
model.commit_operation
textList = "Tags created:"
@type_list.uniq.each{|tl| textList= textList + "\n" + tl}
UI.messagebox(textList)
end
end
end
Rtches::CreateIfcTagsStructure::create_apply_tags()
I would suggest to use variable names which are much more talkative, e.g. like what Dan uses…
I mean e.g.: :
def self.add_layer_include(dict_name, element, layer_name)
Here the element
is a component definition, so I would call it as comp_def
The layer_name
is suggesting me it is a string, however it is a Layers object (collection of layers) , so I would call it as layers
(similar apply for
ly = mod.layers
defs.each do |element| check_component_aply(element, ly)
)
layer_name.add(dict_name) unless layer_name.include?(dict_name)
The unless
condition here is redundant, you do not need to use it.
The Layers #add method is used to add a new layer.
If you give the name of a Layer that is already defined, it will return the existing Layer rather than adding a new one.
I really appreciate all your suggestions. It makes me a better developer (starter developer but developer…)
I have edited the previous code
Except layer_name
is not a string name, it is the set of layers, ie: layer_set
would be a better variable.
Also dict_name
is not really the name of any dictionary. It is the applied schema type for a given loaded schema (either "IFC 2x3"
or "IFC 4"
) and it’s value is the Classification given when tagging with the classifier tool.
For example, if I tag a definition’s instance as "IFCBuildingStorey"
then this is the string value of the first argument. It is not a dictionary name. It is a classification. And so the new layer would have this name.
Even so …
… is inefficient.
The reason is the when you use a string to assign a layer to a Drawingelement
, it must do a lookup in the entity’s model layers collection using the string name. You are doing this lookup in every pass through the loop in every assignment.
Generally you should always try to determine things that will not change before the loop. In this case the preceding #add
statement returns the layer object reference that you should use …
def self.add_layer_include(classification, comp_def, layer_set)
ifc_layer = layer_set.add(classification)
comp_def.instances.each { |inst| inst.layer= ifc_layer }
@type_list.push(classification)
end
me, being a simple architect, how do I run this code then, on the imported ifc ?
Can you select based on ifc classes? If so then maybe TrimBim could be the ifc translator when syncing the ifc to the model. Would be nice to get that to the Mac also then.
Also: ifc´s always have colors that are very un-architectural. Would be cool to have the option to purge those colors when syncing, instead of deleting them every time after each sync to get rid of the “kids theme park” effects.
You should have to find a menu in Sketchup called “ruby console”.
Copy and paste the code and press intro.
Each IFC category will be a tag and each element will be tagged.
Colors come from the software that generates the Ifc
Hello everyone,
Nice to see all those kind of solutions but, i’m not a very coding person.
I think that we should be able to import IFC4 without going through all this…
I hope a simple import is going to be the solution, just update it please !
Thanks.
I converted it into a plugin. You only have to install it, import an Ifc model, run the plugin and wait a second… I think it’s faster than waiting Sketchup to include that.
Hello Rtches,
That sounds like a great solution, where can i find it ? Under which name (if it’s in the Sketchup’s warehouse) ?
Thaaanks !
Sorry. I forgot to write the link. Here is it
Thank you so much for this Plugin, it’s really efficient, it will save us time and energy !!