'Viewer' object has no attribute 'add'

System info:

  • Windows 10
  • python 3.12.9
  • compas 2.10.0
  • compas-ifc 1.5.0
  • compas-viewer 1.4.0
  • compas_occ 1.2.1

I am testing compas for the first time, based on the tutorials found here: tutorials/IFC/README.md at main · compas-dev/tutorials · GitHub

This is my script:

path = 'model.ifc'
model = Model(path)

spaces = model.get_entities_by_type("IfcSpace")

viewer = Viewer(width=1200, height=600)

for entity in spaces:
	viewer.add(entity.body_with_opening, name=entity.name)

viewer.show()

I get the following AttributeError: ‘Viewer’ object has no attribute ‘add’

Could anyone tell me what i am doing wrong? Thank You in advance.

Hey @Daiva

Could you try viewer.scene.add(...) instead?
I suspect the example code my be a little outdated.

Please let me know if that does it.

Chen

Hi @chenkasirer,
thank you for the tip, ir worked!

However now i am facing a new issue: Issue with IFC Model Placement - compas