Hi All,
Just decided to post a 'scenario' of finding the required API method when writing your SolidWorks API based code.
This thread is started to help developers (especially newbie developers) to quickly sort thing out.
This 'scenario' based on my experience only. Any comments, additions are greatly appreciated.
So this is the sequence of steps I usually follow to find the API method:
1) Searching for the method/interface in the Index tab of API Help (I prefer to use local .chm help instead of web help).
2) If not found, go to Search tab. This one usually shows a lot of results so it may be a problem to investigate them all.
3) Searching for a keyword in Members names/description. For example I need to find a method to insert Design Table. If you type "design table" in Index tab you will only find a GetDesign table method. The issue is the Design Table in API named Family Table that's why index doesn't give me good results. However I can expect that method to insert design table should be either in IModelDoc2 or IModelDocExtension interfaces. So I'm opening the members of IModelDoc2 and clicking ctrl+F for a search and typing "design table" and from the results I see the following:
InsertFamilyTableEdit Edits an open design table from Microsoft Excel.
InsertFamilyTableNew Inserts a new design table from Microsoft Excel into the part.
where my search string is in the description of the method. So I should use IModelDoc2::InsertFamilyTableNew to insert new design table through the API.
4) Using the Accessors section of the API help. If I do know the interface I'm looking for I like to know how to reach this interface. For example I'm looking for the IDimension interface where I like to use the IDimension::SystemValue property to change the dimension value. If I look into the IDimension interface Accessors:
Accessors
IDisplayDimension::GetDimension2
IFeature::Parameter and IFeature::IParameter
IModelDoc2::Parameter and IModelDoc2::IParameter
I should select which one is more suitable for me. For example I can just get it by name via the IModelDoc2::Parameter or get it from IDisplayDimension via IDisplayDimension::GetDimension2 where the IDisplayDimension could be retrieved from the selection.
5) If no luck - the API may be just missed so I'm looking for the workaround through the SolidWorks commands: SldWorks::RunCommand and swCommands_e enumerator. You should know that commands do not support arguments so the only functionality you should expect to find there should be 'void' functionality.
6) Using the SolidWorks forum and Knowledge Base. These are a pretty good resources to find the information. Probably may sense to escalate the priority of this item.
7) Using of public search sites: Google, Bing, etc...
__________________________
Regards,
Merry Christmas and Happy New Year!
Artem Taturevych
Application Engineer at Intercad
Tel: +61 2 9454 4444