Jump to content
Developer Wiki and Function Reference Links Read more... ×
Paulo Renan Ferrari

Export Worksheet > TXT File (Append and WriteLn)

Recommended Posts

Hi Everyone,

 

I Have a worksheet in Vectorworks, with the CMYK values and, the code/nome of product.

I need to convert this in .xml, like this below:

<D>0.000000,0.117647,0.156863,0.419608</D>

<N>SW 0001&#160; - Mulberry Silk</N>

 

I trying made this with this Script below:

But I have problem with separation after 0 (.), My export script doesn't put dot (.), Decimal point, after 0.

 

MY EXPORT PLUG IN:

000000,3584070,6858410,113725
R129Abóbora

 

I WANT IT TO BE LIKE THIS:

0.000000,0.3584070,0.6858410,0.113725

R129Abóbora

 

PROCEDURE ExportTXTCMYK;

VAR
fileName : STRING;
hplan : HANDLE;
vcode, vnome, vcyan, vmangen, vyellow, vblack : STRING;
numRows, numColumns : INTEGER;
vlin : INTEGER;
vboo: BOOLEAN;

BEGIN

    fileName := 'Suvinil_CMYK.txt';
    Append(fileName);
    
    hplan := GetObject('Teste2l');
    IF (hplan <> NIL) THEN GetWSRowColumnCount(hplan, numRows, numColumns);

vlin := 2;

REPEAT
    
    vcode := GetCellStr(hplan, vlin, 1);
    vnome := GetCellStr(hplan, vlin, 2);
    vcyan := GetCellStr(hplan, vlin, 7);
    vmangen := GetCellStr(hplan, vlin, 8);
    vyellow := GetCellStr(hplan, vlin, 9);
    vblack := GetCellStr(hplan, vlin, 10);

    WriteLn(vcyan,vmangen,vyellow,vblack,vcode,vnome);
    WriteLn;

    {WriteLn('Teste Teste');}
    
    vlin := vlin+1;

UNTIL(vlin>numRows);
    
vboo := EOF('Teste_CMYK.txt');
Close('Teste_CMYK.txt');

END;
RUN (ExportTXTCMYK);

Sherwin-Williams Colors.xml

Captura de Tela 2018-08-14 às 12.04.21.png

Edited by Paulo Renan Ferrari

Share this post


Link to post

I think this is due to your system language settings using the comma as the decimal separator.

 

Probably the most straight forward way to solve this is to convert to strings using the format you want and then writing the strings to the file. That way you will have full control over the output.

 

Num2Str should get you a string value, but it will probably still have the comma as the decimal separator. Loop through using something like the following:

 

ChangePos:=Pos(',',MyStringVariable);

Delete(MyStringVariable,ChangePos,1);

Insert(MyStringVariable,Changepos,'.');

 

HTH.

  • Like 1

Share this post


Link to post

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

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×