STAAD.Pro Help

I. Creating a New Code Snippet

Code snippet files (file extension .snippet) are XML files which contain one or more code snippets to insert along with metadata about the snippet, such as tool tips, titles, etc. They can be created or edited in any plain-text editor.

Tip: It is easiest to copy an existing snippet file, rename it, and edit as needed.

You can save it in a separate folder to organize your snippets. This will add a folder section to your Insert Snippet menu. Otherwise, you can simply save them in the /STAAD/Editor/Snippets/Std/ folder.

The application comes with a few sample snippet files in the installation. However, to add your own Snippets, add the .snippet file to the folder \Users\(user name)\AppData\Local\Bentley\Engineering\STAAD.Pro CONNECT Edition\Default\Editor\Snippets .

When you select Insert Snippet from the right-click pop-up menu, you will then be provided folders for the samples from Bentley as well as those you have created in the your user folder.

Code Snippet Syntax

When editing a snippet file, you should note that there are two primary components to the XML: the <Header> and the <Snippet>. The Header contains the metadata about the code snippet, including the <Title> text and <Description>, which is used as a tool tip in the STAAD.Pro Editor.

The actual code inserted when the snippet is used by the STAAD.Pro Editor is contained in a CDATA section within the <Code> section.

<Code Language="STD">
Tip: If you want line returns before or after the inserted code, you can place those at the beginning or end of the CDATA text. Whitespace (i.e., spaces, tabs, or line returns) outside of the CDATA section have no effect on the inserted snippet.
<Code Language="STD">

Snippet Replacements

You can create replacement strings in a snippet which will be highlighted for the snippet user. These are added in the <Declarations> section within the <Snippet> section.

Each replacement definition has the following structure:

   <ToolTip>Tool tip text.</ToolTip>
   <Default>Default text</Default>
  • name is the replacement name to use within the snippet code.
  • Tool tip text. is the string to show as a tool tip in the STAAD.Pro Editor
  • Default text is the text that will be inserted (and highlighted) in the STAAD.Pro Editor when the snippet is used

To use the replacement within the snippet code, just place dollar signs ("$") before and after the name value.

Snippet Editing Tools

You can use an IDE such as Microsoft Visual Studio, but any plain text editor is capable of editing code snippet files. An editor that is capable of checking XML syntax is recommended, though.

Tip: Notepad++ is a free text editor which, when the XML Tools plugin is installed, is capable of checking XML syntax.