Jump to content
Developer Wiki and Function Reference Links ×

reading custom import data


Recommended Posts

Hi everybody. I pretty new to VS but I'm learning quickly.

The task at hand is to import custom data from a text file. For example I have three REAL numbers on a line that represent XYZ values.

I want to import these values and apply them to certain symbols XYZ coords. The problem is mainly at the moment that the symbols are already in the document but need updating. What I need help with is Identifing each symbol so that the imported data can be associated with a certain symbol.

I hope this made sense. Thanks in advance.

Link to comment

Nice to meet you.

I think that this is useful for you, though I might have misunderstood.

code:

{

Data file - "Input File.txt" in VectorWorks Folder, text delimited in tab

Name Symbol X Y Z (Name is unique name.)

Name1 Sym1 0.0 0.0 0.0

Name2 Sym1 1.0 0.0 0.0

Name3 Sym2 2.0 0.0 0.0

Name4 Sym2 3.0 0.0 0.0

.

.

.

}

procedure Put3DSymbols;

{$ DEBUG}

const

DataFile = 'Input File.txt';

Msg1 = ' is used other symbol.';

Msg2 = 'Do you replace it by a new symbol?';

Msg3 = ' is used other object.';

Msg4 = 'Do you replace it by a symbol?';

SymbolObj = 15;

LF = Chr(13);

var

h :handle;

x, y, z :real;

x0, y0, z0 :real;

name, sym, sym0 :string;

dummy :string;

procedure CreateSymbol(name, sym:string; x, y, z:real);

begin

NameObject(name);

Symbol(sym, 0, 0, 0);

Move3DObj(LNewObj, x, y, z);

end;{CreateSymbol}

begin{main}

Open(DataFile);

StdReadLn(dummy);

while not EOF(DataFile) do begin

ReadLn(name, sym, x, y, z);

h:= GetObject(name);

if h = nil then begin

CreateSymbol(name, sym, x, y, z);

WriteLn(name, ': is new symbol.');

end

else begin

if GetType(h) = SymbolObj then begin

sym0:= GetSymName(h);

if sym = sym0 then begin

GetSymLoc3D(h, x0, y0, z0);

if (x0 = x) & (y0 = y) & (z0 = z) then begin

WriteLn(name, ': no operation.');

end

else begin

Move3DObj(h, x-x0, y-y0, z-z0);

WriteLn(name, ': moved.');

end;

end

else begin

if YNDialog(Concat('"', name, '"', Msg1, LF, Msg2)) then begin

DelObject(h);

CreateSymbol(name, sym, x, y, z);

WriteLn(name, ': replace symbol"',sym0, '" to symbol"', sym, '".');

end

else begin

WriteLn(name, ': is other symbol"', sym0, '".');

end;

end;

end

else begin

if YNDialog(Concat('"', name, '"', Msg3, LF, Msg4)) then begin

DelObject(h);

CreateSymbol(name, sym, x, y, z);

WriteLn(name, ': replace object(', GetType(h), ') to symbol"', sym, '".');

end

else begin

WriteLn(name, ': is other object(', GetType(h), ')');

end;

end;

end;

ReDraw;

end;

Close(DataFile);

end;

Run(Put3DSymbols);

{

Log file is "Output File" or "Output.txt" in VectorWorks folder.

}
[/code]

Link to comment

Thankyou So much. Having the data altered should not be a huge problem because the data will be generated each time the information is imported or exported.

Yotarou: Thanks heaps from what I read in the script It should do what I'm looking for. Though, i have not tested it and will later tonight and will post back and tell you the results.

Thanks again.

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