test-create-and-associate-layout.jsonā¢1.44 kB
{"method":"tools/call","params":{"name":"project_execute","arguments":{"projectId":"S000009result_1278407893","code":"import os\nresult = {}\ntry:\n layout_file = r'H:\\go\\reports\\Input\\tabelle_report.lay'\n result['file_exists'] = os.path.exists(layout_file)\n result['file_size'] = os.path.getsize(layout_file) if os.path.exists(layout_file) else 0\n \n if os.path.exists(layout_file):\n # Metodo corretto secondo COM API:\n # 1. Crea nuovo GlobalLayout con visum.AddGlobalLayout()\n # 2. Associa il file con layout.AssociateGlobalLayoutFile()\n \n layout = visum.AddGlobalLayout()\n result['layout_created'] = True\n result['layout_number'] = layout.AttValue('No')\n \n # Associa il file .lay al layout appena creato\n layout.AssociateGlobalLayoutFile(layout_file)\n result['file_associated'] = True\n \n # Verifica lo stato dopo associazione\n result['layout_name'] = layout.AttValue('Name')\n result['layout_file'] = layout.AttValue('GlobalLayoutFile')\n result['status'] = 'SUCCESS - Layout created and file associated'\n else:\n result['error'] = 'File not found'\n result['status'] = 'FAILED'\n \nexcept Exception as e:\n result['error'] = str(e)\n result['status'] = 'FAILED'\nresult","description":"Crea GlobalLayout e associa tabelle_report.lay"}},"jsonrpc":"2.0","id":7}