In OpticStudio, we can calculate the Ray transfer (ABCD) matrix using ZOS API(MATLAB and Python Interactive Extension). My colleague has an idea of doing using operands .We can calculate ray transfer matrix element by knowing Height of incidenct ray,Height of refracted ray ,angle of incidence and angle of refraction .As we have PARY or PAXY operands for showing the height of Ray in X or Y -coordinate respectively and PATY shows tangent of the angle the paraxial ray makes in the Y-Z plane after refraction .As shown in image1 below.

We can export angle of incidence and angle of refraction using PATY Operand and Height of incidenct ray and Height of refracted ray using PARY inYZ Plane to a variable in Matlab .Using these values to calculate A,B,C and D Values for Ray Transfer Matrix . In this Image 2, we can see the ABCD Matrix value in Matlab output console uisng MATLAB-API Interactive extension.

Similar in Python we can obtain value for ABCD Matrix shown in Image 3.