Skip to main content

KView

kds-plugin-document / Exports / KView

Interface: KView

酷大师视图窗口

The KView class now contains methods for getting the camera handle. You can access the KView by calling the app.activeView method.

Table of contents

Methods

Methods

clearTemporaryShapes

clearTemporaryShapes(): void

强制清空临时绘制的图形

This method is used to clear temporary shapes.

Returns

void

Defined in

api.d.ts:5116


clearTemporaryShapesByIds

clearTemporaryShapesByIds(ids): void

根据id强制清空临时绘制的图形

This method is used to clear temporary shapes by ids.

Parameters

NameType
idsstring[]

Returns

void

Defined in

api.d.ts:5107


drawArc

drawArc(arc, option?): Object

在视口中临时绘制圆弧线段。

This method is used to draw cylinder. Note: The temporary cylinder will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
arcKArc3dThe input arc.
option?KDrawLinesOption-

Returns

Object

Success returns to the id of arc, else null.

NameType
idstring

Defined in

api.d.ts:5098


drawArrow3d

drawArrow3d(arrow3dParameter, option?): Object

在视口中临时绘制箭头。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw arrow3d. Note: The temporary arrow3d will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
arrow3dParameterKArrow3dParameterThe parameter of the arrow3d.
option?KDrawArrow3dOptionThe option to draw. For the default value you can reference the KDrawArrow3dOption class.

Returns

Object

Success returns to the id of arrow3d, else null.

NameType
idstring

Defined in

api.d.ts:5088


drawCylinder

drawCylinder(cylinderParameter, option?): Object

在视口中临时绘制几何图形。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw cylinder. Note: The temporary cylinder will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
cylinderParameterKCylinderParameterThe parameter of the cylinder.
option?KDrawCylinderOptionThe option to draw. For the default value you can reference the KDrawCylinderOption class.

Returns

Object

Success returns to the id of cylinder, else null.

NameType
idstring

Defined in

api.d.ts:5074


drawFlatLines

drawFlatLines(points, option?): Object

在视口中临时绘制一组有宽度的多段线。

临时绘制的图形元素会在自定义工具退出时,自动清空

This a method to draw a set of flat lines. Note: The temporary lines will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
pointsKPoint3d[][]The points for each flat lines.
option?KDrawLinesOptionThe option to draw. For the default value you can reference the KDrawLinesOption class.

Returns

Object

Success returns to the id of each flat lines, else null.

NameType
idsstring[]

Defined in

api.d.ts:5025


drawLines

drawLines(points, option?): Object

在视口中临时绘制线段。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw a temporary polyline. Note: The temporary lines will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
pointsKPoint3d[]The endpoints of lines.
option?KDrawLinesOptionThe option to draw. For the default value you can reference the KDrawLinesOption class.

Returns

Object

Success returns to the id of lines, else null.

NameType
idstring

Defined in

api.d.ts:4997


drawPoints

drawPoints(points, option?): Object

在视口中临时绘制点。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw temporary points. Note: The temporary points will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
pointsKPoint3d[]The points to draw.
option?KDrawPointsOptionThe option to draw. For the default value you can reference the KDrawPointsOption class.

Returns

Object

Success returns to the id of points, else null.

NameType
idstring

Defined in

api.d.ts:4983


drawPolylines

drawPolylines(points, option?): Object

在视口中临时绘制一组多段线。

临时绘制的图形元素会在自定义工具退出时,自动清空

This a batch method to draw a set of polylines. Note: The temporary lines will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
pointsKPoint3d[][]The points for each polyline.
option?KDrawLinesOptionThe option to draw. For the default value you can reference the KDrawLinesOption class.

Returns

Object

Success returns to the id of each polyline, else null.

NameType
idsstring[]

Defined in

api.d.ts:5011


drawPromptLine

drawPromptLine(startPoint, endPoint, normal?, promptText?): Object

在视口中临时绘制一段提示线。这段提升线类似于酷大师直线绘制工具中的虚线。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw prompt lines. The style is consistent with the drawing line tool in KuDaShi and no modify style interface provided. If the style does not meet the requirements, you may combine other interfaces in this KView class to draw. Note: The temporary prompt line will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
startPointKPoint3dThe start point of the prompt line.
endPointKPoint3dThe end point of the prompt line.
normal?KVector3dThe normal of the prompt line. This normal determines the offset direction from the reference line(which is the line that crosses the start point and the end point.) to the prompt line. Note: The normal must be perpendicular with the reference line.
promptText?stringThe prompt text to draw. If not set, the length between the start point and the end point will be drawn.

Returns

Object

Success returns to the id of promptLine, else null.

NameType
idstring

Defined in

api.d.ts:5060


drawText

drawText(text, position, direction?, option?): Object

在视口中临时绘制一段文字。

临时绘制的图形元素会在自定义工具退出时,自动清空

This method is used to draw temporary text. Note: The temporary text will be cleared when deactivating the KTool.

Parameters

NameTypeDescription
textstringThe text to draw.
positionKPoint3dThe position of text.
direction?KVector3dThe 3D direction to text. If not set, the text always be horizontal on the view.
option?KDrawTextOptionThe option to draw. For the default value you can reference the KDrawTextOption class.

Returns

Object

Success returns to the id of text, else null.

NameType
idstring

Defined in

api.d.ts:5041


getCamera

getCamera(): KCamera

获取相机

Get the camera handle.

Returns

KCamera

The camera handle.

Defined in

api.d.ts:4914


getModelSnapshot

getModelSnapshot(groupInstances, cameraPosture?, cameraPreset?): HostPromise<string>

用于获取指定模型的截图(不包括画布背景)

Parameters

NameTypeDescription
groupInstancesKGroupInstance[]要截图的指定模型
cameraPosture?Object自定义相机位姿参数设置
cameraPosture.cameraPositionKPoint3d-
cameraPosture.cameraUpDirectionKVector3d-
cameraPreset?string进行截图的相机预设视角(可选参数),支持以下几种正视图: - "top":从上方查看 - "bottom":从下方查看 - "left":从左侧查看 - "right":从右侧查看 - "front":从前方查看 - "back":从后方查看 如果同时指定了相机位姿参数和相机预设视角,则采用相机位姿参数 如果未指定相机位姿和相机预设视角,则使用画布相机的当前位姿 请注意,正视图和自定义相机参数设置将始终以模型中心点为截图相机的目视方向 The method is used to get a snapshot of the specified model (excluding the canvas background)

Returns

HostPromise<string>

Return buffer of snapshot data.

Defined in

api.d.ts:4969


getScreenSnopShot

getScreenSnopShot(): string

用于获取当前场景截图 example: const fs = require('fs'); const arr = result.split(','); if (arr.length == 2) { const databuffer = Buffer.from(arr[1], 'base64'); fs.writeFileSync(savePath, databuffer); }

The method is used to get snopshot of current view.

Returns

string

Return buffer of snopshot data.

Defined in

api.d.ts:4938


getViewport

getViewport(): KViewport

获取图形显示视口

Get the viewport for the view.

Returns

KViewport

The viewport.

Defined in

api.d.ts:4923