Importing IFC4 to Sketchup

Hello,

Is there an Update planned in order to be able to import IFC4 to sketchup ?

We will save a lot of time if this update is available. Our Business rely, for a major part, on the import of IFC, being able to import only IFC2x3 is not safe for long term.

Hope something is going to be done !

Thanks.

2 Likes

I also want layer organisation that exists within the file to also import, regardless of version.

Right now I import through Vectorworks, and export a dwg from there and take that dwg in to sketchup.

Then I can keep the ifc layers, and delete the layers I dont want, with all the fiddle and detailing that bogs down the model and makes it a model of 120mb instead of 25mb

I want a links panel to update each placed ifc, and options for each import to keep the filtering of layers that I chose on last import.

Hello,

Thanks for this answer, is Vectorworks a free software ?
I guess i can try it but it would be a pity to pay for it, we should be able to import IFC4 in Sketchup directly.

I hope a developer will see this issue and do his best to resolve it.

1 Like

Vectorworks is priced in the middle of the pack of CAD solutions. So, not Revit expensive, and you own the license.

Thanks for the tip,
However it cannot be considered as a solution for us, we keep on waiting for an update from Sketchup to resolve it.

Just as an aside, Vectorworks is now a subscription only software.

That solution doesn’t maintain all information. Does it?

No, you loose the ifc classification of objects, but you dont need those if you dont export other peoples work back out as ifc. I only export out my own work, with ifc classes, and that model gets put into a main .smc Solibri file by someone else.

However, you maintain layer information, and from that you get to easily delete away the parts of the import model you dont need. So I can keep my model file size sensibly small. For instance I can mount steel engineer models, and filter away all small parts, nuts ans bolts, that I dont need, if they are labelled correctly into layers. The same goes for every engineer model I put into my design.

If sketchup could import layers to tags I would not use this work-around, of course. :slight_smile: If I could filter away parts of a model consistantly through the history of updates to a linked ifc-file then the native version will be mature enough to use.

It’s not difficult. I’m on it.
At the moment I can create a new Tag for each Ifc Category of an imported Ifc model.
I’m trying now to apply their tag to each element in the model.

Try this code. I hope someone with much more experience than me could help to improve it because you have to wait at least 1 minute for having every item in their layer but for me it works.

module Rtches
  module CreateIfcTagsStructure
    def self.lyCreateInclude(dictName,r,ly)
      ly.add(dictName) unless ly.include? (dictName)
      r.layer = dictName
      @typeList.push(dictName)
    end

    def self.checkComponentAply(r,ly)
        dict = r.attribute_dictionary("AppliedSchemaTypes") 
        checkIfc = dict != nil #has Schema
        checkifc23 =  r.attribute_dictionary("IFC 2x3") != nil #is ifc 2x3
        checkifc4 =  r.attribute_dictionary("IFC 4") != nil #is ifc 4
      if checkIfc #component & ifc schema
        if checkifc23
          dictName = dict["IFC 2x3"]
          lyCreateInclude(dictName,r,ly)
        elsif checkifc4
          dictName = dict["IFC 4"]
          lyCreateInclude(dictName,r,ly)
        else
          "Do nothing"
        end
      end

    end

    def self.createApplyTags()
          @typeList = []
          ly = Sketchup.active_model.layers
          Sketchup.active_model.definitions.each{|r|
          hasDefinition = r.respond_to? (:definition)
          checkComponentAply(r,ly)
          }
          UI.messagebox(@typeList.uniq)
    end
  end
end

Rtches::CreateIfcTagsStructure::createApplyTags()

I suppose @DanRathbun @dezmo will have better ideas in order to have each element in the model taged faster.

@rtches Here is a script that I use to tag all components according to the obtained IFC classification. The total time of the script below to execute correctly tagging 318 classified objects was less than 1 second.

mod = Sketchup.active_model # Open model
defs = mod.definitions # All definitions in model
tgs = mod.layers # All tags in model	

filter_schematype = "IFC 2x3"

mod.start_operation('Classification to Tag',true)
			
	defs.each {|definition|
	if definition.get_attribute("AppliedSchemaTypes", filter_schematype) != nil
		classification = definition.get_attribute("AppliedSchemaTypes", filter_schematype)
		if tgs.include?(classification) == false
			tgs.add(classification)
		end
	 
		definition.instances.each{|instance|
		instance.layer = classification.to_s
		}
	end
	}
			
mod.commit_operation
1 Like

It works perfectly. Mine creates tags instantly but all components was not refreshed until a few minutes. I don’t Know why

I guess because yours does not wrapped into one undoable operation… (This is also forcing SU to finish UI related “background” operations)


BTW. You do not need to quote post just before yours :wink:

Sorry! I’m deletting it

1 Like

That wasn’t the problem @dezmo . The problem was this:

 r.layer = dictName

should be:

r.instances.each{|inst| inst.layer=dictName}

where ‘r’ is a definition

Okay here a few issues …

Do not insert spaces between method call and it’s parameter list !

Correct. Module and class identifiers are snakecase (aka camelcase.)

Incorrect.

In Ruby convention is that method names (and variables) are all lower case with "_" underscore between words.

Re, the parameters list:

  1. The use of cryptic variables makes the code extremely difficult to understand.
    Instead of dictName, r, ly use more descriptive names: dict_name, comp_def, layers.

  2. Separate arguments with a space ie : method_call(dict_name, comp_def, layers)

This is frivolous, and a waste of memory for the literal string.

You can “short-circuit” bailout from the method via …

        return unless dict # has Schema

You do not need to repeatedly call the #!= method to test if a reference is nil.
In Ruby nil and false evaluate as falsey. Everything else evals as truthy.
Just rely upon the interpreter evaluating the expression booleanwise.

You also save the time taken for assigning an unneeded reference variable.

Here you are taking the time to assign a local reference, but only using it once.
No need to assign the reference here if your only going to pass it as an argument to a method call:

      if checkifc23
        layer_create_include(dict["IFC 2x3"], comp_def, layers)
      elsif checkifc4
        layer_create_include(dict["IFC 4"], comp_def, layers)
      end

Regarding indentation

Incorrect indentation. Corrected below:

    def self.createApplyTags()
      @typeList = []
      layers = Sketchup.active_model.layers
      Sketchup.active_model.definitions.each { |comp_def|
        check_component_applied_layers(comp_def, layers)
      }
      UI.messagebox(@typeList.uniq)
    end

Also, the { following the iterator method should be space separated just as you would if instead using doend.

      Sketchup.active_model.definitions.each do |comp_def|
        check_component_applied_layers(comp_def, layers)
      end

In this method, the following statement does nothing and is always false.
(Ie, a definition object does not have a #definition method.)

        hasDefinition = r.respond_to?(:definition)

Also, is a plain messagebox suitable for listing the contents of an array?
What about ?

      UI.messagebox(@typeList.uniq, MB_MULTILINE)
3 Likes

I knew I had a lot of mistakes and I knew I was going to the right person. I am sure that these indications will help me a lot for the following scripts.
Thanks a lot @DanRathbun

As a workaround for IFC4 import, you can open the ifc in Trimble Connect for desktop, select what you need (or just the whole file) and then export the 3D view as TrimBim.
Then import that in SketchUp and see what you can do with it.

exporttrb

TrimBim (.trb) import is SketchUp 2023, only.

3 Likes

Did not see this listed in the Release Notes. Did I miss it?

There is only a mention of improved trb import for Mac…

1 Like