Jump to content
Mr. Carsten Fuetterer

File I/O: How to read a file with a feature

Recommended Posts



if you want to read data from text or csv files it's fairly simple to do it in a feature definition.


We use a simple file like this:




To start we create a new feature definition:




In the "create function" tab, we can use the code templates to create a basic control structure:




The variable "FilePath" is not defined and has to be supplied with an argument. In this case I want the object "file" as an argument. So I comment the first line from the feature and create an new argument:




The feature code looks like this:




You can see that a string is  create for each line of the file. So now we have to split this string in order to access the double values. Therefor I use the split command, which has the output of an objectlist. Then I create a point, which accesses each value of that object list:



Now we have to store the points for each line inside an extra objectlist.Therefor we create a new list and add the point:




Finally we create fore example an bsplinecurve, with the new list of points. Additionally encapsulated the while loop into a persistent section in order to visualize the points for each loop. Otherwise we would just see the last point.




Now we create the feature from the feature definition:





We set the path to the reference file:




This nice dialog only appeared, because we didn't allow expressions for the argument inside the feature definition:



The final curve:



I hope this helps you to create you own custom file reader.


best regards










Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...