CADViewer Technical Documentation, Installation Guide and Reference Samples Library

API controls for Load/Save

API Controlled Redlines Load/Save

The following two methods cvjs_saveStickyNotesRedlinesUser() and cvjs_loadStickyNotesRedlinesUser controls if Redlines are loaded/saved through the Modals, or directly controlled. The standard setup for loading through modals are as follows:


// This method is linked to the save redline icon in the imagemap
function cvjs_saveStickyNotesRedlinesUser(){
// there are two modes, user handling of redlines
// alternatively use the build in redline file manager
cadviewer.cvjs_openRedlineSaveModal("floorPlan");
// custom method startMethodRed to set the name and location of redline to save
// see implementation below
//startMethodRed();
// API call to save stickynotes and redlines
//cadviewer.cvjs_saveStickyNotesRedlines("floorPlan", false, "");;
}

// This method is linked to the load redline icon in the imagemap
function cvjs_loadStickyNotesRedlinesUser(){
cadviewer.cvjs_openRedlineLoadModal("floorPlan");
// first the drawing needs to be cleared of stickynotes and redlines
//cvjs_deleteAllStickyNotes();
//cvjs_deleteAllRedlines();
// custom method startMethodRed to set the name and location of redline to load
// see implementation below
// startMethodRed();
// API call to load stickynotes and redlines
//cadviewer.cvjs_loadStickyNotesRedlines("floorPlan", "");
}
function startMethodRed(){
    var v1 = "/content/redlines/v7/"+cadviewer.cvjs_computeDynamicRedlineNamePath()+"all-users.json";
    var v2 = "/content/redlines/v7/"+cadviewer.cvjs_computeDynamicRedlineNamePath()+"all-users.json";
    cadviewer.cvjs_setStickyNoteRedlineUrl(v1);
    cadviewer.cvjs_setStickyNoteSaveRedlineUrl(v2);
}

When changing to direct control of redline load/save, the API methods:

  1. cvjs_openRedlineSaveModal() - modal is used to open redlines
  2. cvjs_openRedlineLoadModal() -modal is used to save redlines

must be replaced with the API methods for direct save:

  1. cvjs_saveStickyNotesRedlines() - save is done directly, bypassing modal
  2. cvjs_loadStickyNotesRedlines() - load is done directly, bypassing modal

Furthermore, two API methods must be set to define the server side path and name to the load location and save location of the redlines:

  1. cvjs_setStickyNoteRedlineUrl() - load location of redline
  2. cvjs_setStickyNoteSaveRedlineUrl() - save location of redline

Below are the implementation of cvjs_saveStickyNotesRedlinesUser() and cvjs_loadStickyNotesRedlinesUser when load/save directly from server.

// This method is linked to the save redline icon in the imagemap
function cvjs_saveStickyNotesRedlinesUser(){
// there are two modes, user handling of redlines
// alternatively use the build in redline file manager
//cadviewer.cvjs_openRedlineSaveModal("floorPlan");
// custom method startMethodRed to set the name and location of redline to save
// see implementation below
startMethodRed();
// API call to save stickynotes and redlines
cadviewer.cvjs_saveStickyNotesRedlines("floorPlan", false, "");;
}

// This method is linked to the load redline icon in the imagemap
function cvjs_loadStickyNotesRedlinesUser(){
//cadviewer.cvjs_openRedlineLoadModal("floorPlan");
// first the drawing needs to be cleared of stickynotes and redlines
// custom method startMethodRed to set the name and location of redline to load
// see implementation below
startMethodRed();
// API call to load stickynotes and redlines
cadviewer.cvjs_loadStickyNotesRedlines("floorPlan", "");
}
function startMethodRed(){
    var v1 = "/content/redlines/v7/"+cadviewer.cvjs_computeDynamicRedlineNamePath()+"all-users.json";
    var v2 = "/content/redlines/v7/"+cadviewer.cvjs_computeDynamicRedlineNamePath()+"all-users.json";
    cadviewer.cvjs_setStickyNoteRedlineUrl(v1);
    cadviewer.cvjs_setStickyNoteSaveRedlineUrl(v2);
}

NOTE: The method cadviewer.cvjs_computeDynamicRedlineNamePath() is optional. It is used to ceate a unique path based on the location of the current drawing. This is useful as programmers can set a single redline, for example all-users.json associated with the file, and all users can then work around a single redline with multiple user created content in it.

HAVE FUN!
Last updated on 6 Feb 2023
Published on 9 Apr 2020