CADViewer Technical Documentation, Installation Guide and Reference Samples Library

Block Substitution

The graphical image of a Block can be substituted with another image object.

Firstly, ensure the drawing is processed with Blocks converted into Space Objects, below as a sample,the audiovisual block is being processed in CADViewer.


Conversion parameters

		cadviewer.cvjs_conversion_clearAXconversionParameters();

		// process blocks with a given name, in this case "audiovisual"
		cadviewer.cvjs_conversion_addAXconversionParameter("blockname", "audiovisual");		 

		// process all invisible attributes in the block 
		cadviewer.cvjs_conversion_addAXconversionParameter("ia", "");		 

		// open the modelspace 
		cadviewer.cvjs_conversion_addAXconversionParameter("model", "");		 
							
		// Load file - needs the svg div name and name and path of file to load
		cadviewer.cvjs_LoadDrawing("floorPlan", FileName );

Secondly, make a loop over all instances of the block and substitute the image, using the API method cvjs_replaceSpaceObjectPathWithImage() :

Image Substitution/Overlay


function AudioVisual(){

  var spaceObjectIds = cadviewer.cvjs_getSpaceObjectIdList();
      console.log(" IDs:"+spaceObjectIds.length);

  var loadSpaceImage_Location = "data:image/svg+xml;base64, PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgdmlld0JveD0iLTExMDAgLTIwMCAyMjAwIDIyMDAiCiAgIGhlaWdodD0iMjIwMCIKICAgd2lkdGg9IjIyMDAiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlkPSJzdmcyIgogICB2ZXJz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NTcgLTQ4LjA4LC00OC4wOCAwLC0yNi41MSAyMS41NywtNDguMDggNDguMDgsLTQ4LjA4IDI2LjUxLDAgNDguMDgsMjEuNTcgNDguMDgsNDguMDggMCwyNi41MSAtMjEuNTcsNDguMDggLTQ4LjA4LDQ4LjA4IHogbSAwLC0yMTMuNjkgYyAtOTEuMzIsMCAtMTY1LjYxLDc0LjI5IC0xNjUuNjEsMTY1LjYxIDAsOTEuMzIgNzQuMjksMTY1LjYxIDE2NS42MSwxNjUuNjEgOTEuMzIsMCAxNjUuNjEsLTc0LjI5IDE2NS42MSwtMTY1LjYxIDAsLTkxLjMyIC03NC4yOSwtMTY1LjYxIC0xNjUuNjEsLTE2NS42MSIgLz4KPC9nPjwvZz48L3N2Zz4="
  var id;

    for (var spc in spaceObjectIds){		
        id = spaceObjectIds[spc];
        console.log("AudioVisual id="+id+" spc:"+spc);
      cadviewer.cvjs_replaceSpaceObjectPathWithImage("floorPlan", id, loadSpaceImage_Location);
    }

  }

Before Block Substitution

Blocks

After Block Substitution

Blocks
Last updated on 29 Aug 2022
Published on 8 Aug 2022