# creates two features with the add feature tool layer = qgis.utils.iface.activeLayer() # manual interaction ! # select the first feature with the "select features be rectangle"-tool and then do the following line: featId1 = layer.selectedFeaturesIds()[0] # add values to the first feature for i in range(5): layer.changeAttributeValue(featId1, i, (i*10)) # manual interaction ! # select the second feature with the "select features be rectangle"-tool and then do the following line: featId2 = layer.selectedFeaturesIds()[0] # changes the geometry of the second feature newGeom = QgsGeometry.fromPolyline([QgsPoint(1,1), QgsPoint(2,2)]) layer.changeGeometry(featId2, newGeom) qgis.utils.iface.mapCanvas().refresh () # add values to the second feature for i in range(5): layer.changeAttributeValue(featId2, i, (i*10 + 1000)) # get the second feature by using featureAtId... feat = QgsFeature() layer.featureAtId(featId2, feat, True, True) # print values from the second feature for i in range(5): print feat[i].toString() # for some reason the attributeValues to the first feature get printed out. # in the attribute table it looks correct. # feat.geometry().asPolyline() seems to return the right geometry # if I save edits after creating the two new features it works as it should