Jump to content
Developer Wiki and Function Reference Links ×

Script error


Recommended Posts

Hello!

we are working on a project that needs lots of imports from Revit (.rvt and IFC files) on both directions. We are now in need to move our saved vies from VWx to Revit/Naviswors, and we are trying to export toward these our cameras and their settings so to maintain the exact same views on both ends. A colleague wrote a script to do it but we are getting an error and he would need some help on this.

 

This is the script:

 

PROCEDURE ConvertToNavisworks;
VAR
    hCamera : HANDLE;
    cameraName : STRING;
    xmlFile : LONGINT;  { Declare xmlFile as LONGINT instead of TEXT }
    xmlText : STRING;
BEGIN
    { Open the XML file for writing }
    xmlFile := CreateTextFile('S:/2022/2244 URWLD INTERIOR/05. DRAWING/03. MODEL/URWLD 'Clean' Model/URWLD Working File/Camera Information/cameras.xml');

 

   { Start the XML document }
    WriteLn(xmlFile, '<?xml version="1.0" encoding="UTF-8"?>');
    WriteLn(xmlFile, '<Viewpoints>');

 

   { Iterate through each camera position }
    FOR hCamera IN ActLayer(VWCameraNode) DO
    BEGIN
        { Get the camera name }
        cameraName := GetName(hCamera);

 

       { Write the viewpoint element to the XML file }
        WriteLn(xmlFile, '  <Viewpoint>');
        WriteLn(xmlFile, '    <Name>', cameraName, '</Name>');
        WriteLn(xmlFile, '    <Position>', GetCameraPosition(hCamera), '</Position>');
        WriteLn(xmlFile, '    <Orientation>', GetCameraOrientation(hCamera), '</Orientation>');
        WriteLn(xmlFile, '  </Viewpoint>');
    END;

 

   { Close the XML document }
    WriteLn(xmlFile, '</Viewpoints>');
    CloseFile(xmlFile);
END;

 

RUN(ConvertToNavisworks);

 

He says that he is getting an error on line #9:

"identifier not declared"

 

Any Idea? Could any of you script geniuses and wizards help? 🙂 

 

Thanks in advance

 

Cheers and Ciao(s)

 

Marco

Link to comment

CreateTextFile is not a Vectorscript command.

 

Use Open instead, but it is a procedure not a function, so it is not going to give you the xmlFile handle.

 

Also, only a single file can be open at a time, so WriteLN does not take a handle either, so the xmlFile portion of all the WriteLn procedures need to be removed also.

 

And Close in Vectorscript does not use the xmlFile, but takes the same name as you used in the Open procedure.

 

Take a look at Close in the Function Reference for an example that is close to what you are trying to do.

 

HTH

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