The Capabilities and Potential of SolidWorks API
The topic for actually using these objects and methods will be explained in the next topic. From there, the interface would expose the objects and methods the you can use in your macro. For example, if you would like to create a macro that can automate the sketching process, you would look for the ISketch interface.
Knowing that, it is not hard for the average SolidWorks user to find the correct API to use. Now if you have gone through all the name of the interfaces, you would have probably already notice that each interface correspond to some specific feature within SolidWorks. I would like for you to take some time to explore the names of the interfaces in the help page before continuing this article. Each of these interface correspond to certain components of the SolidWorks application. If we refer to the SolidWorks API Help, we can see listed is a huge list of interfaces. Now that we understand what an API is, lets dive deeper into the interface topic.
#Solidworks api vba software
Now that this bridge (API) exists, users can use all of the functions created by the software developers, without the developers worrying about the source code being exposed as illustrated in the image below. The API connects the users code to the highly secretive source code. So now if the software would like to allow users to create their own custom programs in the application, developers would create what is known as an API that acts as a bridge. This source code, of course, is highly proprietary and an industrial secret. In every software, a source code has to be created that contains all of the objects and methods required to run each of the feature you can find in the SolidWorks UI. Users will be able to use this interface to create automation programs.īefore we go further, I would like to bring to attention about how software are made as this would be useful in understanding how SolidWorks API works. The interface, in respect to programming, refers to a whole set of objects and methods within the SolidWorks application. In the case of SolidWorks API, the application refers to SolidWorks. The term application programming interface (API), as the name suggests, refers to a set of interface that can be used to create program for the application. In this series, we will be taking things much more slowly and in depth, as each aspect will be explained in detail.īefore we go into the technical aspects of the SolidWorks API, I would like to give you an understanding of what SolidWorks API actually is, and what it is capable of, and why it is such a powerful tool.
#Solidworks api vba free
To get the quickest start to SolidWorks API, feel free to follow the other series.
#Solidworks api vba series
This series will be running parallel to the more practical approach in SolidWorks API series. When you provide DocID = 0 it tells EPDM to get all the files in the folder specified.This SolidWorks API Fundamentals series will explain the technical details of working with SolidWorks API. If you want to get a single file, try the following adjustment and see if that does it: Set eFile = eVault.GetFileFromPath(fName) You can refer to the documentation for further information and examples. With EPDM, when a file is "shared" it can have multiple parent folder IDs it belongs to, and we can enumerate over then using the methods from iEdmFile5 GetFirstFolderPosition and GetNextFolder.
For getting the latest version, you can use any containing folder, as it will be checked out in all folders. The ProjID property is the ID of the containing folder.
The docID property is the database ID of the document. The code is slightly modified from that posted by Michael Dekoning at įrom first glance, it looks like you are populating the EdmSelItem properties incorrectly. If I manually 'get latest' in the EPDM browser before editing the file, the macro reads it fine. Set BG = eVault.CreateUtility(EdmUtil_BatchGet)Ĭall BG.CreateTree(0, EdmGetCmdFlags.Egcf_SkipExisting) Set eFile = eVault.GetFileFromPath(fName) VaultName = Config.ReadXMLElement(pathConfig, "vaultname") I have tried to get around this by writing a sub to get the latest copy of a file immediatly before editing it to ensure there is always a file present but the code doesnt seem to retrieve the file. If I try and edit a file that has just been edited I get a 'file not found' error (because it's been deleted from cache). My macro checks files out, edits them and checks back in again. Due to a company policy on how the PDM system operates, when the user checks in a file, the local copy is deleted from the users cache.