unable to retrieve Rotation Matrix in solidworks.

Hi,

i want to retrieve Rotation matrix and Translation Matrix using .net api in solidworks 2020. It says "Unable to get instance of an object". Below is the code snippet.

ISldWorks^ swApp = gcnew

ModelDoc2^  swModel = swApp->IActiveDoc2;
ModelDocExtension^ swModelDocExt = swModel->

View3D^ capture = swModelDocExt->Capture3DView();
capture->Activate(true);
 //Get Rotation Matrix
  MathTransform^ rot = capture->Rotation;
  System::Object^ _rot = rot->ArrayData;
  array^ _arr = dynamic_cast^>(_rot);

Regards

SolidworksApi/macros