Observers not fired when importing files
- SketchUp/LayOut Version: 2018
- 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
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.
For comparison, using these test observers on SU 2016 ...
Are you seeing different results in other SketchUp versions?
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.
Logged as SU-40185
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.
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.
@thomthom Please update issue title to reflect this is a DAE import issue.
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.
If it's that prevalent, the issue should be elevated.
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.
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?