api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Observers not fired when importing files

Open noelwarren opened this issue 7 years ago • 11 comments

  1. SketchUp/LayOut Version: 2018
  2. OS Platform: Windows

Importing a file through the File->Import... menu entry fails to fire observers.

class DefinitionsObserver
	
	def onComponentAdded(definitions, definition)
		puts definitions, definition
	end

end

class MaterialsObserver
	
	def onMaterialAdd(materials, material)
		puts materials, material
	end
	
end

Sketchup.active_model.definitions.add_observer(DefinitionsObserver.new)
Sketchup.active_model.materials.add_observer(MaterialsObserver.new)

Example file to import Lowpoly_tree_sample.zip

noelwarren avatar Jul 04 '18 10:07 noelwarren

For comparison, using these test observers on SU 2016 ...

class DefinitionsObserver
	
  def onComponentAdded(definitions, definition)
    puts definitions, definition
  end

  def respond_to?(meth)
    puts "SketchUp is polling #{self.class.name} for a #{meth.to_s} callback."
    super(meth)
  end

end

class MaterialsObserver
	
  def onMaterialAdd(materials, material)
    puts materials, material
  end

  def respond_to?(meth)
    puts "SketchUp is polling #{self.class.name} for a #{meth.to_s} callback."
    super(meth)
  end

end

When importing a model with a "Components Sampler/Bench" component within it, ... This is the output I get:

SketchUp is polling MaterialsObserver for a onMaterialAdd callback.

SketchUp is polling DefinitionsObserver for a onComponentAdded callback. (9 times)

SketchUp is polling DefinitionsObserver for a onComponentPropertiesChanged callback.

SketchUp is polling DefinitionsObserver for a onComponentAdded callback. (16 times)

SketchUp is polling MaterialsObserver for a onMaterialRefChange callback. (140 times)

SketchUp is polling DefinitionsObserver for a onComponentPropertiesChanged callback.

SketchUp is polling DefinitionsObserver for a onComponentAdded callback.

This seems correct as the Bench has nested sub-components in it.

ADD: The puts statements in the callbacks work fine and output the #inspect string for the entities.

DanRathbun avatar Jul 04 '18 12:07 DanRathbun

For comparison, using these test observers on SU 2016 ...

Are you seeing different results in other SketchUp versions?

thomthom avatar Jul 09 '18 13:07 thomthom

I myself haven't yet tested in any newer versions (than 16) as my current machine will not run OpenGL 3. I'll get a newer machine later this month and try then.

DanRathbun avatar Jul 14 '18 02:07 DanRathbun

Logged as SU-40185

thomthom avatar Aug 09 '18 15:08 thomthom

Is there an update on this? I don't think it got resolved in 2019. At least our QA team don't seem to think it did.

noelwarren avatar Jul 31 '19 16:07 noelwarren

I just realized noel was giving a DAE file as an example.

(I previously had checked only importing a SKP file.)

So using Noel's "Lowpoly_tree_sample.dae" Collada file and importing from the Downloads folder ...

SU2016:

SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.

SU2017:

SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.

SU2018

SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.

SU2019.2

SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.
SketchUp is polling DefinitionsObserver for a onComponentRemoved callback.

After the import there is a new definition named "skp<random_number>" in the "In Model" collection that is not trapped by the observer. Same for any of it's added materials.

I don't think it got resolved in 2019.

Agreed.

DanRathbun avatar Jul 31 '19 17:07 DanRathbun

@thomthom Please update issue title to reflect this is a DAE import issue.

DanRathbun avatar Jul 31 '19 17:07 DanRathbun

Please update issue title to reflect this is a DAE import issue.

Might be any non-SKP importer... SKP files are loaded differently than other formats imported.

thomthom avatar Aug 16 '19 11:08 thomthom

If it's that prevalent, the issue should be elevated.

DanRathbun avatar Aug 16 '19 21:08 DanRathbun

We just got another report related to this. It seems this is also true for dxf files. So your "Might be any non-SKP importer" theory is probably true.

noelwarren avatar Oct 02 '20 16:10 noelwarren

The absence of firing the onComponentAdded observer is present for DXF, IFC and 3DS importers, which are native to Sketchup.

Still present in SU2025.

Any news about this issue in general?

Fredosixx avatar May 21 '25 15:05 Fredosixx