SView Help Center
English (US)

Section

Author: sviewngts Last Updated: 2026-10-29 18:32

Interface List

Interface Name Description
Create Section Create a section
Update Section Progress Update the progress of a section plane
Set Reverse Sectioning Set whether a section plane performs reverse sectioning
Show Section Plane Set whether to show the section plane
Show Capping Plane Set whether to show the capping plane
Add Specified Sections Add the models for specified sectioning
Remove Specified Sections Remove the models for specified sectioning
Clear Specified Sections Clear the models for specified sectioning
Get the section plane Use this interface to obtain the section plane object
Bind the section drag widget Binds the section drag widget
Unbind the section drag widget Unbind the section drag widget
Serialize Serialize section objects into JSON format
Deserialize Deserialize JSON format data into section objects

Creating a Section

   If you need to perform sectioning via the sectioning toolbar, you can directly use the sectioning command.

boxSection('section', document.documentElement.clientWidth>480?SView.Commands.SectionMenu:SView.Commands.MobileSectionMenu);

   If you do not need the sectioning toolbar, use the following interfaces. The same action can be used when creating multiple sections.

let action = new SView.Actions.MultiSectionAction();
action.setScene(scene);
//Set the visibility of the XY-direction section plane
action.setSectionVisible(SView.Actions.SectionDirectionType.SECTION_XY,true);
//Set the visibility of the YZ-direction section plane
action.setSectionVisible(SView.Actions.SectionDirectionType.SECTION_YZ,true);
//Set the visibility of the ZX-direction section plane
action.setSectionVisible(SView.Actions.SectionDirectionType.SECTION_ZX,true);
action.execute();

   Create a custom section. Up to three custom sections can be created. For all other operations on custom sections, the interfaces are the same as those for regular sections; simply change the type to the custom section type.

let action = new SView.Actions.MultiSectionAction();
action.setScene(sview0.getViewer().getScene());
// The first custom section uses SView.Actions.SectionDirectionType.SECTION_CUSTOM1; subsequent ones use SView.Actions.SectionDirectionType.SECTION_CUSTOM2 and SView.Actions.SectionDirectionType.SECTION_CUSTOM3, respectively
// Set the custom section direction
action.setSectionDirection(SView.Actions.SectionDirectionType.SECTION_CUSTOM1, new M3D.M3DMath.Vector3(-0.09183143610620231,-0.9944757739121634,0.05084213257207494));
// Set the custom section position
action.setSectionPosition(SView.Actions.SectionDirectionType.SECTION_CUSTOM1, new M3D.M3DMath.Vector3(1647.3425839982642,1950.741735717373,-1736.2169277216883));
// Set custom section visibility
action.setSectionVisible(SView.Actions.SectionDirectionType.SECTION_CUSTOM1, true);
// Set whether to show the section plane
action.setShowClipPlane(true);
// Set whether to show the capping plane
action.setShowCappingPlane(true);
// Add the first custom section; the subsequent interfaces are addCustom2SectionPlane and addCustom3SectionPlane, respectively
action.addCustom1SectionPlane();

Updating the Section Position

// The position is of type M3D.M3DMath.Vector3. Only the coordinate value for the current direction is needed; pass 0 for the other directions.
// The range of position values can be obtained from the scene bounding box.
let box = scene.getBoundingBox(true);
// Set the section position for the XY direction
action.setSectionPosition(SView.Actions.SectionDirectionType.SECTION_XY, new M3D.M3DMath.Vector3(0, 0, box.Center().z));
// Set the section position for the YZ direction
action.setSectionPosition(SView.Actions.SectionDirectionType.SECTION_YZ, new M3D.M3DMath.Vector3(box.Center().x, 0, 0));
// Set the section position for the ZX direction
action.setSectionPosition(SView.Actions.SectionDirectionType.SECTION_ZX, new M3D.M3DMath.Vector3(0, box.Center().y, 0));
action.setSectionDirection(SView.Actions.SectionDirectionType.SECTION_XY, new M3D.M3DMath.Vector3(0, 0, -1));
action.setSectionDirection(SView.Actions.SectionDirectionType.SECTION_YZ, new M3D.M3DMath.Vector3(-1, 0, 0));
action.setSectionDirection(SView.Actions.SectionDirectionType.SECTION_ZX, new M3D.M3DMath.Vector3(0, -1, 0));
action.execute();

Setting Reverse Sectioning

//Set whether the XY-direction section is reversed
action.setSectionReverse(SView.Actions.SectionDirectionType.SECTION_XY,false);
//Set whether the YZ-direction section is reversed
action.setSectionReverse(SView.Actions.SectionDirectionType.SECTION_YZ,false);
//Set whether the ZX-direction section is reversed
action.setSectionReverse(SView.Actions.SectionDirectionType.SECTION_ZX,false);
//Set all reversed
action.setReverseClip(false);
action.execute();

Setting Whether to Show the Section Plane

//Set whether to show the section plane
action.setShowClipPlane(true);
action.execute();

Setting Whether to Show the Capping Plane

//Set whether to show the section capping plane
action.setShowCappingPlane(true);
action.execute();

Adding Specified Sections

//Add the models for specified sectioning; the parameter is an array of Model objects
action.addSelectedShapes([]);
action.execute();

Removing Specified Sections

//Remove the models for specified sectioning; the parameter is an array of Model objects
action.removeSelectedShapes([]);
action.execute();

Clearing Specified Sections

//Clear the models for specified sectioning
action.clearSelectedShapes();
action.execute();

Get the section plane

// Get the XY section plane
let sectionplane = action.sectionPlane_XY
// Get the YZ section plane
let sectionplane = action.sectionPlane_YZ
// Get the ZX section plane
let sectionplane = action.sectionPlane_ZX
// Get custom section plane 1
let sectionplane = action.sectionPlane_Custom1
// Get custom section plane 2
let sectionplane = action.sectionPlane_Custom2
// Get custom section plane 3
let sectionplane = action.sectionPlane_Custom3
// Get the bounding box section
let sectionBox = action.sectionBox;
// Get the bounding box section planes
let sectionPlanes = sectionBox.getSectionPlanes();

Bind the section drag widget

let sectionDraggerBindAction = new SView.Actions.SectionDraggerBindAction();
sectionDraggerBindAction.setScene(scene);
sectionDraggerBindAction.setSectionPlane(sectionplane);
sectionDraggerBindAction.execute();
let dragger = sectionDraggerBindAction.getDragger();

Unbind the section drag widget

let draggers = scene.getDraggerManager();
draggers.unBindDragger(dragger);

Serializing Sections

//First get the section object
let sectionPlane = null;
//Sections created in H5 are stored in the M3D.Shapes.ShapeType.SECTION type
let sectionList = shapes.getShapes(M3D.Shapes.ShapeType.SECTION);
for(let i=0;i<sectionList.length;i++){
	let section = sectionList[i];
	let sectionPlaneList = section.getPlaneList();
	for(let j=0;j<sectionPlaneList.length;j++){
		sectionPlane = sectionPlaneList[j];
		let sectionPlaneJsonStr = M3D.Reader.SectionFactory.toJsonSectionPlane(sectionPlane);
		break;
	}
}
//Sections read from svlx are stored in the M3D.Shapes.ShapeType.SECTION_PLANE type
let sectionPlaneList = shapes.getShapes(M3D.Shapes.ShapeType.SECTION_PLANE);
for(let j=0;j<sectionPlaneList.length;j++){
	sectionPlane = sectionPlaneList[j];
	let sectionPlaneJsonStr = M3D.Reader.SectionFactory.toJsonSectionPlane(sectionPlane);
}

Deserializing Sections

//The deserialized section planes are stored in the M3D.Shapes.ShapeType.SECTION_PLANE type
let jsonStr = '{"createID":19226,
	"name":"",
	"ShowClipPlane":true,
	"ShowCappingPlane":true,
	"visible":true,
	"version":1.2,
	"reverseClip":false,
	"normalPos":[0,0,1],
	"selectPos":[0,0,22.714599609374886]}';
let jsonObj = JSON.parse(jsonStr);
let plane = M3D.Reader.SectionFactory.fromJson(jsonObj,scene);
//Set the section capping plane visibility to the state recorded in the JSON
plane.setShowCappingPlane(plane.getOriShowCappingPlane());
//Set the section plane visibility to the state recorded in the JSON
plane.setShowClipPlane(plane.getOriShowClipPlane());
//Add the section plane to Shapes
shapes.addShape(plane);
//Show the section plane
plane.setEnable(true);
//Update the scene display
scene.refresh();