Hide Table of Contents

Get Info on Plane/Axis Example (C++ COM)

This example shows how to get parameter information for the currently selected reference plane or reference axis.


void GetRefObjectInfo()





 // Retrieve IModelDoc pointer

 hres = UserApp->getSWApp()->get_IActiveDoc( &m_ModelDoc );  

 if( m_ModelDoc == NULL )



long type;


// Helper function

IFeature* m_Feature = GetSelectedFeature( m_ModelDoc, &type ); 


if( m_Feature != NULL )


BSTR bFeatName;


// Get feature name

hres = m_Feature->get_Name( &bFeatName );    

BSTR bTypeName;


// Get the feature type

hres = m_Feature->GetTypeName( &bTypeName );    

CString featName( bFeatName );

CString typeName( bTypeName );

CString message;        


// Display message to user

message.Format( _T("Type: %s\nName: %s"), typeName, featName );





// If the selected feature is a Reference Plane

if (type == swSelDATUMPLANES)      



// Get the RefPlane interface

hres = m_Feature->IGetSpecificFeature( &iUnk );  


IRefPlane* refPlane = NULL;

hres = iUnk->QueryInterface( IID_IRefPlane, (LPVOID*)&refPlane);

double values[9];

// Get Ref Plane parameters

hres = refPlane->IGetRefPlaneParams( values );   


CString message2;       // Display message to user

message2.Format( _T("RefPlaneParams\nOrigin:%f, %f, %f\n X-Dir:%f, %f, %f\nNormal:%f, %f, %f"), values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8] );

AfxMessageBox( message2 );





else if (type == swSelDATUMAXES)      

// If the selected feature is a Reference Axis




// Get the RefAxis interface

hres = m_Feature->IGetSpecificFeature( &iUnk );  


IRefAxis* refAxis = NULL;

hres = iUnk->QueryInterface( IID_IRefAxis, (LPVOID*)&refAxis);

double values[6];


// Get Ref Axis parameters

hres = refAxis->IGetRefAxisParams( values );   


// Display message to user

CString message2;       

message2.Format( _T("RefPlaneParams\nStartPt:%f, %f, %f\nEndPt:%f, %f, %f"), values[0], values[1], values[2], values[3], values[4], values[5] );

AfxMessageBox( message2 );





// Display message to user

AfxMessageBox( message );       










Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Get Info on Plane/Axis Example (C++ COM)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.