Although there is no a direct way in the “Export CAD” tool to export a only a subset of rays using a filter string, it can be done creating a new Source File object based on the rays that you want to filter.
You can find an example of how to create a source file object in the following article from our knowledge base (Generating a SDF section):
How to export ray trace results in IES format
Once you have this subset of rays saved, you can input the new Source File Object in your system and delete the original ones. You will see in the layout only the rays that pass your filter and then, you can export this as CAD file as usual.
Check also this article which describes the necessary settings in order for SolidWorks to display the ray patterns exported from OpticStudio:
How to show exported rays in SolidWorks and Autodesk Inventor
Thank you for your instructions Berta,
By the way, in case of an error arising while exporting CAD through ZOS, one can try changing the “use ACIS Libraries” options as unchecked. This move may solve the exporting CAD problem, if any.