Conversion of .msh to .inp

Hello
I want to convert .msh file to .inp file.How can i do that?

Use gmsh to do that. File>Export

Mabey:
meshio: GitHub - nschloe/meshio: 🕸 input/output for many mesh formats
FEconv: GitHub - victorsndvg/FEconv: Program feconv is an utility to convert between several mesh and FE field formats, like ANSYS mesh files (.msh), MD Nastran input files (.bdf), I-Deas Universal (.unv), VTK files (.vtk), etc. If you use a Modulef format to store an intermediate mesh (.mfm). It can transform the FE type of a mesh composed of trangles or tetrahedra, to Lagrange P1 or P2, Raviart-Thomas (face) or Whitney (edge) finite elements. It also uses third-party code to perform bandwidth optimization (CutlHill-McKee optimization).

It’s the native format of Gmsh so just open it and export from there. But be careful not to include additional wire and surface elements since Gmsh exports all 1D, 2D and 3D elements by default and physical groups have to be used to limit this to 3D elements only.

I have written this script to convert .msh file to .inp file which has two physical groups.
import gmsh

def convert_msh_to_inp(msh_file, inp_file):
# Initialize Gmsh
gmsh.initialize()

try:
    # Load the Gmsh mesh
    gmsh.open(msh_file)

    # Write the Abaqus .inp file
    gmsh.write(inp_file)

finally:
    # Finalize Gmsh
    gmsh.finalize()

print(f'Conversion completed. Output written to {inp_file}')

Example usage:

msh_file = r"D:\Mesh Files\PhyCheck.msh"
inp_file = r"D:\Mesh Files\PhyCheck.inp"
convert_msh_to_inp(msh_file, inp_file)

But here i am getting only physical group data like
*Heading
D:\Mesh Files\test.inp
*NODE
1, -55, 60, 20
2, -35, 40, 20
3, -55, 40, 20
4, -35, 40, 0
5, -55, 40, 0
6, -55, 60, 0
7, -55, 56.666666664585, 20
8, -55, 53.33333332385, 20
9, -55, 49.999999976408, 20
10, -55, 46.666666649088, 20
11, -55, 43.333333323272, 20
12, -38.333333348686, 40, 0
13, -41.66666669263, 40, 0
14, -45.00000000477, 40, 0
15, -48.33333333368, 40, 0
16, -51.66666666606, 40, 0
17, -37.222222231281, 40, 17.777777768719
18, -39.444444456895, 40, 15.555555543105
19, -41.666666687367, 40, 13.333333312633
20, -43.888888906023, 40, 11.111111093977
21, -46.111111132215, 40, 8.8888888677846
22, -48.333333346111, 40, 6.6666666538893
23, -50.555555560652, 40, 4.4444444393484
24, -52.777777778888, 40, 2.2222222211115
25, -35, 40, 16.666666659084
26, -35, 40, 13.333333319325
27, -35, 40, 9.9999999692737
28, -35, 40, 6.6666666458789
29, -35, 40, 3.3333333233225
30, -55, 60, 16.666666659084
31, -55, 60, 13.333333319325
32, -55, 60, 9.9999999692737
33, -55, 60, 6.6666666458789
34, -55, 60, 3.3333333233225
35, -55, 42.222222232443, 17.777777767557
36, -55, 44.444444456965, 15.555555543035
37, -55, 46.666666681804, 13.333333318196
38, -55, 48.888888911221, 11.111111088779
39, -55, 51.111111136369, 8.8888888636312
40, -55, 53.333333356018, 6.6666666439815
41, -55, 55.55555557256, 4.4444444274399
42, -55, 57.777777785136, 2.2222222148641
43, -43.191925618735, 40, 8.0510431843771
44, -37.762570802238, 40, 5.024856538245
45, -43.3333333487, 40, 2.8867513275948
46, -38.110847195172, 40, 12.318473603549
47, -48.082064451706, 40, 3.545588790629
48, -37.868879173065, 40, 8.3642888306287
49, -40.852473937865, 40, 9.9789545654168
50, -45.337304844744, 40, 5.399445368228
51, -40.233000409004, 40, 3.2189036556144
52, -40.387636046825, 40, 6.695477367336
53, -36.95550277667, 40, 15.130361378756
54, -50.283079558197, 40, 2.0424510902178
55, -42.496640053602, 40, 5.2503241806301
56, -37.440169353442, 40, 2.4401693466456
57, -45.813876036809, 40, 2.3201941486626
58, -55, 51.950807352704, 11.801986973345
59, -55, 54.98703902141, 17.200420437639
60, -55, 57.113248655573, 11.6666666443
61, -55, 47.688529288318, 16.888089602738
62, -55, 56.454411214962, 6.9179355382962
63, -55, 51.684731490109, 17.123678385939
64, -55, 50.035674931882, 14.142139820912
65, -55, 54.598133274425, 9.659139799256
66, -55, 56.784381876706, 14.756494847528
67, -55, 53.334425867134, 14.594639556476
68, -55, 44.871039190017, 18.044284582666
69, -55, 57.957548914532, 4.7169204299603
70, -55, 54.756199405308, 12.495785564181
71, -55, 57.559830639126, 17.559830637652
72, -55, 57.679558770704, 9.1857611644379
******* E L E M E N T S *************
*ELEMENT, type=CPS3, ELSET=Surface6
1, 25, 2, 17
2, 12, 4, 56
3, 4, 29, 56
4, 16, 24, 5
5, 13, 12, 51
6, 51, 12, 56
7, 14, 13, 45
8, 45, 13, 51
9, 15, 14, 57
10, 14, 45, 57
11, 16, 15, 54
12, 15, 47, 54
13, 47, 15, 57
14, 24, 16, 54
15, 17, 18, 53
16, 25, 17, 53
17, 18, 19, 46
18, 18, 46, 53
19, 19, 20, 49
20, 46, 19, 49
21, 20, 21, 43
22, 20, 43, 49
23, 21, 22, 50
24, 43, 21, 50
25, 22, 23, 47
26, 22, 47, 50
27, 23, 24, 54
28, 47, 23, 54
29, 26, 25, 53
30, 27, 26, 46
31, 46, 26, 53
32, 28, 27, 48
33, 27, 46, 48
34, 29, 28, 44
35, 44, 28, 48
36, 29, 44, 56
37, 49, 43, 52
38, 43, 50, 55
39, 52, 43, 55
40, 44, 48, 52
41, 51, 44, 52
42, 44, 51, 56
43, 50, 45, 55
44, 45, 50, 57
45, 45, 51, 55
46, 48, 46, 49
47, 50, 47, 57
48, 48, 49, 52
49, 51, 52, 55
*ELEMENT, type=CPS3, ELSET=Surface7
50, 7, 1, 71
51, 1, 30, 71
52, 3, 11, 35
53, 6, 42, 34
54, 8, 7, 59
55, 59, 7, 71
56, 9, 8, 63
57, 8, 59, 63
58, 10, 9, 61
59, 61, 9, 63
60, 11, 10, 68
61, 10, 61, 68
62, 35, 11, 68
63, 30, 31, 66
64, 30, 66, 71
65, 31, 32, 60
66, 31, 60, 66
67, 32, 33, 72
68, 60, 32, 72
69, 33, 34, 69
70, 62, 33, 69
71, 33, 62, 72
72, 34, 42, 69
73, 36, 35, 68
74, 37, 36, 61
75, 61, 36, 68
76, 38, 37, 64
77, 37, 61, 64
78, 39, 38, 58
79, 58, 38, 64
80, 40, 39, 65
81, 39, 58, 65
82, 41, 40, 62
83, 62, 40, 65
84, 42, 41, 69
85, 41, 62, 69
86, 58, 64, 67
87, 65, 58, 70
88, 58, 67, 70
89, 63, 59, 67
90, 59, 66, 67
91, 66, 59, 71
92, 60, 65, 70
93, 65, 60, 72
94, 66, 60, 70
95, 61, 63, 64
96, 62, 65, 72
97, 64, 63, 67
98, 67, 66, 70
*ELSET,ELSET=Load
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98,
*ELSET,ELSET=Support
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49,

But i want whole inp data including surface ,volumes,etc.How can i get that through script.

You need to define the physical data. gmsh works on physical groups for the export.