70001894 Save VDS as DWG on WebControl through web service

Article 70001894
Type HowTo
Product WebJS
Version 8006
Date Added 12/29/2020 12:00:00 AM
Fixed 9.9001.0.1 (12/29/2020 12:00:00 AM)
Submitted by VectorDraw Team

Summary

Instructions for how to save a VDS file to DWG/DGN throught VectorDraw WebControl.

Solution

VectorDraw WebControl can only displays .vds files which is our file format for the web component so when you have a .vds file on a page and you want to save tha file as DXF/DWG you have to create a service that will
upload the vds file on the server, convert it to the preferred supported file format and then download it through the web page.
Bellow you can find some more instructions about the convert operation.

In order to do that you need to write a webservice that reference VDF libraries with vdDocumentComponent and there are 2 ways that the users of your software to be able to open/save DWG/DGN files.
a) If the users of your application want to open/save DWG/DGN files then they need to have installed the FileConverter (Lite or Full) end-user application in their machines.
b) The other way is to become member of OpenDesign (www.opendesign.com) if you are not already member and use their libraries and distribute them with your application (inside your application's setup).
In this case, some dlls that are included in OpenDesign's libraries must be installed in the "customer's machine".

        //Javascript code in the client machine
        vdcanvas.vdAfterSaveDocument =function(saveData)
        {
            //get the original filename
            var path = saveData.dataObject.pathname;
            if (!path) path = 'vdDocument.vds';
            //Call the webservice here --> convert(saveData.dataStream,saveData.dataObject.pathname+".dwg");
        }
        vdcanvas.SaveDocument();
 
        //Webservice in the server machine
        //inputdata: inputdata is the data as come from web javascript method .Represents the contents of a vds file
    
        [System.Web.Services.WebMethod]
        public static void convert(string inputdata, string exportedfilename)
        {
            vdDocumentComponent vdc = new vdDocumentComponent();
            vdDocument doc = vdc.Document;
            bool success = doc.FromScriptData(inputdata);
            if (success)
{ //save to a temporary relative folder in the server string exportedrelativefile = "./Drawings/"+ System.IO.Path.GetFileNameWithoutExtension(exportedfilename) success = doc.ExportToFile(exportedrelativefile); } }

Send comments on this topic.