Jump to content
Mr. Arne Bergmann

Did you know? Tips and tricks for feature programming

Recommended Posts

The editor for the Create Function of a feature has some (so far) undocumented (which will change in 3.0) possibilities that can come in handy. So, here's a list of things that you may not be aware of:

Copy/Cut whole lines
If you press the keyboard shortcut for copy or cut (i.e. Ctrl+c and Ctrl+x) without having any text selected, the whole line will be copied/cut. If you then paste it, it will be inserted as a whole line

Select words
Select words works by double clicking on them. Nothing new? Do the same by single clicking an pressing CTRL.

Find next occurence
When using the text search (Ctrl+f) you can press F3 to find the next occurence of the search string

By pressing F1 (or using the question mark button in the toolbar) the documentation browser will open the documentation (if available) of the type/command that is currently under the cursor.

Debugging shortcuts
The debugger can also be controlled by keyboard shortcuts:

  • F5 : start debugging
  • F9 : toggle breakpoint in the current line
  • F10 : execute next line
  • Shift + F5 : stop debugging

More shortcuts
Additional shortcuts:

  • F7 : Evaluate the feature (same as the "Evaluate" button on the lower left)
  • Ctrl+F7 : Apply the changes to the feature (same as the "Apply" button on the lower right)

Collapse code
You may have already noticed that parts of the code can be collapsed by pressing on the little arrow on the left of the code (in between the code and the line numbers). This applies to "block"-statements (e.g. if, while) and can help to get a clearer view of the code as parts that you are currently not interested in can be hidden. What you probably do not know is the ##region/##endregion functionality. This way you can define collapsable regions yourself, e.g.:

##region myRegion
// this is some code
point p()
line c()

The identifier behind the ##region directive allows you to give a name to the region, so you see what's inside when collapsing it.
So the example can be collapsed to

##region myRegion { . . . }

Of course, this only works if collapsing is enabled in the editor settings.

Column select
When using the mouse to select text it is not only possible to select lines, but you can also create a selection that only spans part of a line but expands to other lines. To do so, hold Ctrl+Alt while selecting with the mouse. This can come in handy when you want to change the type or name of multiple objects, for example. These screenshots should illustrate it a little better:
feature defining 4 points:
Select using Ctrl+Alt:
Type fvector3:

That's about it for now, however here's a little teaser about the news in the next release:

Auto close blocks
The editor automagically adds the corresponding keyword when starting a new block statement (e.g. if/while).

New language features
The feature language has been expanded a little further. The biggest news are:

foreach -> iterate over objectlists and entitygroups in a very convenient way. Forget about all those castTo commands and counter variables!
You probably know code like this:

unsigned i(0)
while(i < myObjectList.getcount())
f3dpoint p (myObjectList.at(i).castTo(F3dpoint))
if (!(!p))
i += 1

Now, you can just write this:

foreach(f3dpoint p in myObjectList)

switch -> getting lost in all those if/elseif cascades? The new switch statement should solve that.

unsigned i(2)
switch (i)
case 1
echo("i is 1")
case 2
echo("i is 2")
case 3,4,5
echo("i is 3, 4 or 5")
echo("i is larger than 5)

function -> writing the same code inside your feature over and over again? Put it in a function and just call it!

function calculatePlusTwo(double d) : fdouble
return(d + 2)

You can even reimplement existing commands inside your feature:

function echo(string text)
::echo("My Feature" + text)
echo(" wants to say hello")

will output: "My Feature wants to say hello" on the console

Share this post

Link to post
Share on other sites

I've got some more useful shortcuts for feature programming:

You can use these shortcuts instead of using the buttons in the top bar. post-41-0-32910000-1383745082.png


  • comment a row or multiple rows at once use CTRL+K

Select rows you want to comment


Press CTRL+K



  • uncomment a row or multiple rows at once use CTRL+SHIFT+K

Select rows you want to uncomment





Best Regards



Share this post

Link to post
Share on other sites

Hey folks,


here is a video introduction to features or you can watch the video in our video section on our website.


I can also recommend the feature documentation in CAESES. To access it click on the question mark button in the top right corner of the feature definition editor. (or go to create function and press F1 on you keyboard).





Share this post

Link to post
Share on other sites

Check out this blog post which comes with a great summary (PDF) for the feature programming language (contains all the little details that are important)...

Share this post

Link to post
Share on other sites

Feature programming is like Python, JavaScript, Artificial intelligence, Ruby on Rail, etc, Python is one of the most preferred languages out there. Its brevity and high readability makes it so popular among all programmers.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...