1 person found this helpful
The following is my current understanding of the subject, but I welcome any correction, clarification, and further insight from others.
The methods with "I" in front, known as in-process methods, include two types of methods:
1. Those that return arrays. These should only be used with in-process, unmanaged C++ (i.e., unmanaged C++ add-ins). These methods reduce the amount of code needed in other parts of an unmanaged C++ program.
2. Those that return pointers. These can be used in any .NET or C++ code. These methods return the pointers directly to SolidWorks API interfaces, which is why no cast is required, unlike normal methods (known as "global" methods since they are useful in all languages and program types) which return simply "object" and therefore require a cast in strong-typed languages.
ISldWorks app; IModelDoc2 model = app.ActiveDoc as IModelDoc2; //explicit cast, compiles IModelDoc2 model = app.ActiveDoc; //compile error IModelDoc2 model = app.IActiveDoc2; //compiles
(Note that the model doc variable was defined as "IModelDoc2" and not "ModelDoc2" for this example to work.)
Aside from removing the need to make an explicit cast, in-process methods might have slightly better performance than global methods. This is the only other benefit I can think of for a method like ISldWorks::IActiveDoc2.
Note that the in-process methods are not doing any different work in SolidWorks than the global methods. They are simply there to supposedly make life easier for the programmer, especially programmers of unmanaged, in-process C++ code. Recently I talked to the head of the SolidWorks API development team and it appears that the API dev team acknowledges that the confusion caused by these methods has not outweighed the benefits, which is why no new in-process methods have been added to the API in recent years.
In-process methods (SolidWorks API Help)
Thank you Keith. But following microsoft recomendations Names of Classes, Structs, and Interfaces
I - means an interface.
Thanks to your conversation with the head of API development, it became clear that it relates to Coding Conventions.
2 people found this helpful
When you see "I" in front of a type, it refers to an interface: ISldWorks, IModelDoc2. But when talking about methods, the "I" stands for in-process:
In-process methods typically begin with the letter I...
(From the "In-process methods" API Help page, linked to in my previous answer.)
In-process methods can return arrays or interfaces, so the "I" in front of a method name shouldn't be understood simply as referring to interfaces. Confusing, no? Wish they had chosen another naming convention for in-process methods.