Jump to content
Developer Wiki and Function Reference Links ×

Getting Options From external Files


Recommended Posts

Most of the NNA PIOs that use "standard" sizes read that data in from a text file using the Open, and Read or ReadLn commands to pull the data from the file into an array. When you pick the data that you need, either use the data in the array directly, or copy it into variables that may be easier to work with.

Link to comment

Look at the article:

http://developer.vectorworks.net/index.php?title=VS:Parametric_Custom_Shape_Pane

apparently, the functionality is available in VW2009 (could not verify since I have VW2008)

Also as an alternative to using text files, which requires more coding to implement, explore using String Data in the script editor. If the data will not change over the years, then this will be an easier solution.

Link to comment

can you post an example of this in action?.

I can post some snips and maybe you can put them into action. The main script this was done for is very 'file specific' and rather large, so that posting it as a working script doesn't make much sense. It won't do anything without a lot of other stuff in place in the drawing and a properly formatted text file to read on the hard-drive.

This example reads some info from a tab delimited text file that has 3 entries per line. This data is read into a 2 dimensional array that's 3 columns wide. After the array is loaded the info is written from the array to records attached to certain objects in the drawing.

This info could just as easily be written into the parameter record of a PIO. If you're doing that you won't want to use GetFile. Look in VSFR under File I/O for Open and Close, and other functions for file handling.

CONST

???kMaxLines=200;

VAR

???date,node_num,reading,data_file:STRING;

???node_info:ARRAY[1..kMaxLines,1..3] OF STRING;

Procedure read_info;

???Begin

??????line_num := 0;

??????REPEAT

?????????line_num := line_num + 1;

?????????ReadLn(date,node_num,reading);

?????????node_info[line_num,1] := date;

?????????node_info[line_num,2] := node_num;

?????????node_info[line_num,3] := reading;

??????UNTIL (EOF(data_file)) or (line_num = kMaxLines);

???End;

The part of the main body that calls the above:

BEGIN

???GetFile(data_file); {you'll want to do different here for reading into PIO}

???IF NOT DidCancel THEN

??????Begin

?????????read_info;

?????????attach_record;

?????????ForEachObject(write_info,C='nodes');

?????????ForEachObject(draw_flags,C='nodes');

??????End;

END;

Hope this is enuf to get your ball rolling.

WARNING: working with arrays and data files can be very finicky & hazardous to your mental health.

(option-spaced out)

Edited by ccroft
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...