TS for charts

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

TS for charts // Interactive Artwork

1  |  

Post by Wigand // Aug 19, 2006, 12:52am

Wigand
Total Posts: 462
pic
My second VBScript


To use TS as a chart plotter.


1. I created an Excel-sheet with 3 columms: X,Y,Z


X's are the given values

Y's are in this chart not very important, but I gave them a little drift.

Z's are the results of a formula or maybe samples of measures values


2. I exported the datas as a TAB seperated table.


3. I looked for an input function in VBscript, to load this table into TS

First I tried OPEN, but it was not possible.

Therefore I had to use the "FSO" (FileSystemObject) of Windows to load the file.


4. Loading works. I could see the datas in an output field in LinkEditor.


5. Then I cut my InputLine at the TAB positions to get seperated X,Y and Zs.


6. Now I had the problem to create new objects in Player to show the chart-line.

I didn't want to create a new object by coding all its parameters, materials or koordinates.

I decided to record a macro. That worked well.


7. Copy and paste this code into my new created Sub. Error! VBScript don't understand the Space.CurrentScene().

I noticed that I still worked in a VBScript-object-code. In the recorded macro there was no problem.


8. Therefore I copied my code into the recorded macro.


9. All is fine!


Additional problem:


I looked for the possibility to use the "CommonDialog" of Windows. But unfortunately it needed a Form as a

container.


How could it be possible do show the "CommonDialog"?




Here is my code (charttest.RSObj):


______________________________________


Sub Execute(params)


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile("C:\koords.txt")


Do Until objTextFile.AtEndOfStream

strLine = objTextFile.Readline


posa = InStr(1, strLine, vbTab)

posb = InStr(posa + 1, strLine, vbTab)


x = Left(strLine, posa - 1)

y = Mid(strLine, posa + 1, posb - posa - 1)

z = Right(strLine, Len(strLine) - posb)


scene = Space.CurrentScene()


name2_ = Library.CreateDelegate3D("Primitives", "SDS", "Cone", scene, x, y, z)

Call Node.Select(name2_)


Loop




End Sub

______________________________________


Here are the datas of the koords.txt file:


______________________________________


0 0,0 7,000

1 0,2 7,813

2 0,4 8,486

3 0,6 8,902

4 0,8 8,989

5 1,0 8,732

6 1,2 8,176

7 1,4 7,416

8 1,6 6,584

9 1,8 5,825

10 2,0 5,268

11 2,2 5,011

12 2,4 5,098

13 2,6 5,513

14 2,8 6,186

15 3,0 7,000

Post by frootee // Aug 19, 2006, 6:32am

frootee
Total Posts: 2667
pic
cool!


I like it.

Post by hemulin // Aug 19, 2006, 9:25am

hemulin
Total Posts: 1058
pic
This is a VERY good idea Wigand, I hope it works out, I really like it.

Post by splinters // Aug 19, 2006, 9:40am

splinters
Total Posts: 4148
pic
Hey, Hemulin is back...good holiday?


Just a few days to go now eh?

Post by hemulin // Aug 20, 2006, 11:34am

hemulin
Total Posts: 1058
pic
Hey, Hemulin is back...good holiday?

Just a few days to go now eh?

Oh brilliant, see other thread (no sarcasm intended)

Aaah, 2 and a half weeks, its getting colder already
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn