Retrieve selected element raises attribute error

There is no API to do that with Python4Capella, but you can still can the Java API from your python script. In this thread you will find how to declare your menu or elements from a diagram. You can then check this thread to change the color of an element. For the layout you can check his thread.

If you change the style of a diagram element for instance its color, you will also need to mark the feature as customized, otherwise it will be reseted after a refresh of the diagram:

    representation_element.getOwnedStyle().setStrokeColor(color)
    representation_element.getOwnedStyle().getCustomFeatures().add("strokeColor")

an other example to set a workspace image and change the label position:

    style = representation_element.getOwnedStyle()
    helper = org.eclipse.sirius.diagram.ui.business.api.image.WorkspaceImageHelper()
    helper.updateStyle(style, "In-Flight Entertainment System/music.svg")
    style.setShowIcon(True)
    style.setLabelPosition(org.eclipse.sirius.diagram.LabelPosition.NODE_LITERAL)

The PyDev editor will complain that some symbols are not recognized (for instance org), but as runtime EASY will find them. You can remove this error by following this documentation.