The Basics

What does it take to start and write your own applications? Well, in principle you need two things: at first the required coding knowledge (I will cover that topic in a later article) and second a suitable development environment, which is pretty easy to get. In this article I want to show you 3 possible ways. There are many more, but maybe this choice represents some beginner-friendly ones.

If you want to develop applications for Solied Edge, well then of course you also need Solid Edge itself. For anybody who doesn’t have access to a professional licence, Siemens offers a free community edition since 2022. This one contains the full scope of functions, but is limited to a private, non-commercial use. More infos on that on the Siemens-website

First things first

To make Solid Edge execute demanded actions, there are two ways: either you create a macro or an Addon. An Addon is an exe-file, which is loaded at the start of Solid Edge and is then connected the whole time. That’s why it is possible for Addons to react on so called Solid Edge events and depending on that start own actions. Events are e.g. the opening of a file. An Addon could then the check the opened file for certain properties and show a report about that to the user.

A macro on the other hand is also an executable file, but is only startet on explicit order of the user. This doesn’t necessarily has to be a programm related to Solid Edge. You could for instance reference a program which automatically sends a confirmation email when the user hits a button in Solid Edge. The main purpose will of course be macros which execute actions in Solid Edge. Therefor the macro connects to Solid Edge and then remote controls the application, just like Excel macros do with MS Excel.

VBScript

If you work on a Windows machine, then you might consider this very quick start. Windows contains in the basic configuration the VB Scripting Host. That’s a program which interprets and executes VB Script files. These script files already supply a broad variety of options: beside the common functions of a programming language, you can interact with the user by inputs and outputs, read and write text files, manipulate files and folders in the file system and finally start other programs and access their functions. The possibilities are pretty comprehensive, so be warned to never execute scripts from unknown sources. They could do massive harm. For more information see the link to the language reference

To create script files, you in principle don’t need anything more than a text editor, like e.g. the Windows Editor or Notepad. With that you can instantly write your executeable code. Darin kann man sofort den auszuführenden Code schreiben. The finished file then needs to be saved as <.vbs> instead of <.txt>. So Windows will automatically recognize it as code. Here is an example:

'*******************************************************************
'*                                                                 *
'*     example program to remote control SolidEdge via VBScript    *
'*                                                                 *
'*******************************************************************

' declaration of variables
Dim MySE
Dim NewFile
Dim UserSelection

' connect to SolidEdge
On Error Resume Next
Set MySE= GetObject(, "SolidEdge.Application")
If MySE Is Nothing Then Set MySE= CreateObject("SolidEdge.Application")
MySE.Visible=true

' request info from user
UserSelection=InputBox("Do you want to create a <part> document or a <draft> document?", "your choice", "part")
	
' create new SE document
If UserSelection="part" then
	Set NewFile=MySE.Documents.Add("SolidEdge.PartDocument")
	MsgBox "This is a new part document", VBOKonly, "new part"
Elseif UserSelection="draft" then
	Set NewFile=MySE.Documents.Add("SolidEdge.DraftDocument")
	MsgBox "This is a new draft document", VBOKonly, "new draft"
Else
	MsgBox "Sorry, I didn't understand you.", 0+16, "ERROR"
End If

The VBScript solution is very handy since you don’t need to install any additional programs and can start rightaway. But it has some downsides:

  • it’s only available in Windows (I don’t know, if there are similar solutions for MacOS, Linux etc.)
  • the language is still supported by Microsoft, but will no longer be developed (dead language) -> if you plan to develop applications for a longer time, then you should look out for something else
  • there is no Windows-integrated IDE (integrated development environment) for VBS. If you want to use a third party product, you have to separately install it (which you’re might not allowed to, if you’re working on your company’s computer).
  • there is no (safe) way to protect your source code. The code will always be (more or less) easy accessible for anyone you hand your program to
  • the options to create GUIs (graphical user interface) are very limited to basically Messageboxes for output and Inputboxes for input

VBA Editor

To come over these points, you might switch to another Basic dialect -> VBA (Visual Basic for Applications). It’s available on all computers, that have an MS Office version installed. So chances are high, that you already have a full VBA IDE installed on your computer. This helps you to:

  • better keep the overview as it automatically formats the written code
  • find bugs in the code
  • discover the object model of applications
  • protect your source code, if you want to keep it secret
  • create advanced GUIs, which are already on the level of professional applications

VBA is very similar to VBS and the concept of connecting to other software via COM is the same. So you could basically use the code from the VBS example. The only thing you have to do, is put it in a sub (see example below). To better understand the VBA language see the language reference.

Public Sub example()
    MsgBox "This is an example", vbOKOnly, "VBA"
End Sub

Now although VBA and its Editor are probably a good choice for small and midsize applications. But it also has downsides:

  • you are limited to Visual Basic as the programming language
  • you need to have an MS Office product installed (for development as well as for execution of your code), you cannot create stand-alone exe-files
  • there is no integrated version management

Professional IDE

So when you want to do the next step, you should consider a professional stand-alone IDE. I personally use MS Visual Studio 2019 because it’s free, it offers a lot of features and is very widespread among developers. You could write your programs in Visual Basic, but also in many other languages. I prefer C#.NET, since that is very common for desktop applications and it provides more functionality than VB. However, the choice of a programming language is not as important as many beginners think. It is more important to understand the general concepts, like object orientation etc.

The use of a stand-alone IDE also allows you to create exe-files, that run independent of any MS Office products. If you develop in any of the .NET languages, that furthermore makes you independent of the OS (operating system) of your target machine, since most computers today have the .NET CLR (common language runtime) already installed and therefor can run .NET exe-files.

Visual Studio also supports you to backup, version and share your code with Git/Github.