JSON Structure & JSON Commands
Below are the API methods for operating on the Space Objects JSON Stucture. For manipulation of data fields inside Space Objects, see:
NOTE: When loading or saving multiple Space Objects, they will sequentially stored in a JSON element named ‘SpaceObjects’. The links below will open the command documentation in the CADViewer JavaScript API.
- cvjs_createNewJSonSpaceObject() - create a new JSON Space Object
- cvjs_loadSpaceObjectsDirect() - load up a JSON Space object array from a file-location into the drawing
- cvjs_setSpaceObjectDirect() - set a single JSON Space Object
- cvjs_setSpaceObjectsStructureDirect() - set an entire collection/array of JSON Space Objects into the drawing
- cvjs_addCustomSpaceObject() - add a custom structure as a JSON Space Object
- cvjs_returnSpaceObjectClicked() - return the Space Object clicked
- cvjs_returnAllSpaceObjects() - return the collection of all JSON Space Objects
- cvjs_returnSpaceObjectID() return a JSON Space Object based on ID
The SpaceObject JSON structure
The API method cvjs_createNewJSonSpaceObject() creates a default Space Object with the following structure. This is the template used for all Space Object interaction.
var jsonStructure =  	{	
  "path": path,
  "tags": tags, 
  "node": node, 
  "area": area, 
  "outerhtml": outerHTML, 
  "occupancy": occupancy, 
  "name": name, 
  "type": type, 
  "id": id, 
  "defaultcolor": defaultcolor, 
  "highlightcolor": highlightcolor, 
  "selectcolor": selectcolor, 
  "layer": layer, 
  "group": group, 
  "linked": linked, 
  "attributes": attributes, 
  "attributeStatus": attributeStatus, 
  "displaySpaceObject": displaySpaceObject,
  "translate_x": translate_x, 
  "translate_y": translate_y, 
  "zvalue": zvalue, 
  "scale_x": scale_x ,
  "scale_y": scale_y ,
  "rotate": rotate, 
  "transform": transform, 
  "svgx": svgx, 
  "svgy": svgx, 
  "dwgx": dwgx, 
  "dwgy": dwgy , 
  "customContent" : mycustomcontent,
  "pageNumber" : "",
  "pageName" : "",
  "block" : "",
  "blockAttributeId" : "",
  "blockAttributeCount" : ""
  "clickhandler" : "enable",
  "parent" : "none",
  "zvalue": "1",
}
The application programmer can grab these JSON objects and manipulate them using the API methods listed at the top of this section.
User controlled SpaceObject Fields:
Below are listed the SpaceObject field that users can modify in their code. NOTE: , the field “id” most differ and the field “name” should differ between SpaceObjects.
  "tags": tags, 
  "node": node, 
  "occupancy": occupancy, 
  "name": name, 
  "type": type, 
  "id": id, 
  "defaultcolor": defaultcolor, 
  "highlightcolor": highlightcolor, 
  "selectcolor": selectcolor, 
  "layer": layer, 
  "group": group, 
  "attributes": attributes, 
  "attributeStatus": attributeStatus, 
  "displaySpaceObject": displaySpaceObject,
  "customContent" : mycustomcontent,
  "zvalue": myzvalue,
}
NOTE: The field: “customContent” allows the application programmer to add their own content to the JSON Space object.
Reserved Space Object Fields:
Below are listed the reserved fields that CADViewer uses internally to position and manipulate the SpaceObjects.
  "path": path,
  "outerhtml": outerHTML, 
  "linked": linked, 
  "attributeStatus": attributeStatus, 
  "displaySpaceObject": displaySpaceObject,
  "translate_x": translate_x, 
  "translate_y": translate_y, 
  "zvalue": zvalue, 
  "scale_x": scale_x ,
  "scale_y": scale_y ,
  "rotate": rotate, 
  "transform": transform, 
  "svgx": svgx, 
  "svgy": svgx, 
  "dwgx": dwgx, 
  "dwgy": dwgy , 
  "pageNumber" : "",
  "pageName" : "",
  "block" : "",
  "blockAttributeId" : "",
  "blockAttributeCount" : ""
  "clickhandler" : "enable",
  "parent" : "none",