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
- clearTemporaryShapes
- clearTemporaryShapesByIds
- drawArc
- drawArrow3d
- drawCylinder
- drawFlatLines
- drawLines
- drawPoints
- drawPolylines
- drawPromptLine
- drawText
- getCamera
- getModelSnapshot
- getScreenSnopShot
- getViewport
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
Name | Type |
---|---|
ids | string [] |
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
Name | Type | Description |
---|---|---|
arc | KArc3d | The input arc. |
option? | KDrawLinesOption | - |
Returns
Object
Success returns to the id of arc, else null.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
arrow3dParameter | KArrow3dParameter | The parameter of the arrow3d. |
option? | KDrawArrow3dOption | The option to draw. For the default value you can reference the KDrawArrow3dOption class. |
Returns
Object
Success returns to the id of arrow3d, else null.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
cylinderParameter | KCylinderParameter | The parameter of the cylinder. |
option? | KDrawCylinderOption | The option to draw. For the default value you can reference the KDrawCylinderOption class. |
Returns
Object
Success returns to the id of cylinder, else null.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
points | KPoint3d [][] | The points for each flat lines. |
option? | KDrawLinesOption | The 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.
Name | Type |
---|---|
ids | string [] |
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
Name | Type | Description |
---|---|---|
points | KPoint3d [] | The endpoints of lines. |
option? | KDrawLinesOption | The option to draw. For the default value you can reference the KDrawLinesOption class. |
Returns
Object
Success returns to the id of lines, else null.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
points | KPoint3d [] | The points to draw. |
option? | KDrawPointsOption | The option to draw. For the default value you can reference the KDrawPointsOption class. |
Returns
Object
Success returns to the id of points, else null.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
points | KPoint3d [][] | The points for each polyline. |
option? | KDrawLinesOption | The 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.
Name | Type |
---|---|
ids | string [] |
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
Name | Type | Description |
---|---|---|
startPoint | KPoint3d | The start point of the prompt line. |
endPoint | KPoint3d | The end point of the prompt line. |
normal? | KVector3d | The 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? | string | The 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.
Name | Type |
---|---|
id | string |
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
Name | Type | Description |
---|---|---|
text | string | The text to draw. |
position | KPoint3d | The position of text. |
direction? | KVector3d | The 3D direction to text. If not set, the text always be horizontal on the view. |
option? | KDrawTextOption | The option to draw. For the default value you can reference the KDrawTextOption class. |
Returns
Object
Success returns to the id of text, else null.
Name | Type |
---|---|
id | string |
Defined in
api.d.ts:5041
getCamera
▸ getCamera(): KCamera
获取相机
Get the camera handle.
Returns
The camera handle.
Defined in
api.d.ts:4914
getModelSnapshot
▸ getModelSnapshot(groupInstances
, cameraPosture?
, cameraPreset?
): HostPromise
<string
>
用于获取指定模型的截图(不包括画布背景)
Parameters
Name | Type | Description |
---|---|---|
groupInstances | KGroupInstance [] | 要截图的指定模型 |
cameraPosture? | Object | 自定义相机位姿参数设置 |
cameraPosture.cameraPosition | KPoint3d | - |
cameraPosture.cameraUpDirection | KVector3d | - |
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
The viewport.
Defined in
api.d.ts:4923