How to use Accessors section in SOLIDWORKS API Help

Edit ArticleEdit Article

Accessibility of certain interface can be found in the Accessors section of specific interface in the SOLIDWORKS API Help documentation.

For example, the snapshot below is an Accessors section of the IAnnotation Interface

Accessors section in API Help documentation
Accessors section in API Help documentation

Which means that the pointer to IAnnotation Interface could be retrieved either via IAnnotation::GetNext2 Method or IAnnotationView::Annotations property or other properties or methods in this list.

Some of the interfaces can be explicitly or implicitly cast from one to another. For example IModelDoc2 represents the parent interface (although there is no direct inheritance) for IPartDoc, IAssemblyDoc, IDrawingDoc interfaces.

Which means that both parent and specific object would be pointing to the same object in memory.


Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Set swPart = swModel


Dim swModel As IModelDoc2
Dim swPart As IPartDoc = CType(swModel, IPartDoc)


IModelDoc2 model;
IPartDoc part = model as IPartDoc;


hres = pModelDoc->QueryInterface(IID_IPartDoc, (LPVOID*)&pPartDoc);


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial