<div>Hi, I'm trying to create a qgis plugin in python. And I have a problem with coping layout's items from one printlayout template to another printlayout template.<br></div><div><br></div><div>When I execute this code:<br></div><div><br></div><div>  composition.loadFromTemplate(doc, QgsReadWriteContext(), True)<br></div><div>        composition.setName(layoutName)<br></div><div><br></div><div>        layout_model_name = "LayoutNameModel"<br></div><div>        layout_model = project.layoutManager().layoutByName(layout_model_name)<br></div><div><br></div><div>        if layout_model is not None:<br></div><div>            all_items = layout_wzor.items()<br></div><div>            for item in all_items:<br></div><div>                if isinstance(item, QgsLayoutItemPolyline) or isinstance(item, QgsLayoutItemPicture) or isinstance(item, QgsLayoutItemMap) or isinstance(item, QgsLayoutItemLegend):<br></div><div>                    composition.addItem(item_new)<br></div><div><br></div><div><br></div><div>I lose map's focus during exporting to pdf.<br></div><div><br></div><div>And when I execute this code:<br></div><div><br></div><div>        layout_name1 = 'Name_First_Layout'<br></div><div>        layout1 = project.layoutManager().layoutByName(layout_name1)<br></div><div><br></div><div>        layout_name2 = 'Name_Second_Layout'<br></div><div>        layout2 = project.layoutManager().layoutByName(layout_name2)<br></div><div><br></div><div>        item_name = 'Map 1'<br></div><div>        item1 = layout1.itemById(item_name)<br></div><div><br></div><div><br></div><div>        if item1 and isinstance(item1, QgsLayoutItemMap):<br></div><div>            item2 = QgsLayoutItemMap(layout2)<br></div><div>            item2.setRect(item1.rect())<br></div><div><br></div><div>            item2.setLayers(item1.layers())<br></div><div>            item2.setExtent(item1.extent())<br></div><div>            item2.setScale(item1.scale())<br></div><div><br></div><div>            layout2.addLayoutItem(item2)<br></div><div><br></div><div><br></div><div>The map suddenly disappears from the printlayout during export and is not visible in the pdf file. Although it is visible on list of objects on the right side of the layout.<br></div><div><br></div><div>Maybe you have some idea how to solve this problem?<br></div><div><br></div><div>Thank you for your help ;)<br></div>