Skip to main content

KGroupDefinition

kds-plugin-document / Exports / KGroupDefinition

Interface: KGroupDefinition

组定义

组定义用来定义一个成组里面的内容。一个成组里面可包括一组酷大师图形实体,如造型面、参考线、参考线段、子级的成组实例等 例如,我们可以画一个茶杯,把它做成一个成组(组定义)。然后为它创建6个实例,围绕在一张桌子的周围 注意,在酷大师图形界面里使用“成组”的命令,会创建一个成组的组定义,并同时创建一个成组的组实例。我们在画布中看到的对象,其实是组实例。 在酷大师图形界面里编辑一个“成组”,实际上是在编辑它的组定义。对组定义的修改,会应用到它所有的组实例上。因此,所有的组实例的外观在组定义修改后,都会变化。 酷大师的组定义可以有两种类型,原生成组和外部模型 在酷大师里用“成组”命令创建的,或用KDesign.makeGroup这个API创建的成组都属于原生成组。我们可以在酷大师里编辑原生成组的组定义内容(即进行“组编辑”) 外部模型是由外部的应用(体现为一个酷大师插件)插入到酷大师方案中的,例如酷大师官方插件中的“智能模型”。外部模型的组定义只能由创建它的外部应用,即酷大师插件来编辑。

The KGroupDefinition class is used to define the contents for a KuDaShi group instance. The group definition is a collection of entities that can be instanced and reused multiple times throughout a KuDaShi model. For example, you could draw a tea-cup once, turn it into a group definition, and then use 6 instances of it to surround a tea table. Editing to the original “definition” will then propagate across all of its instances. The KGroupDefinition class contains sub group instances, shells and auxiliary curves, etc. The group definition has two types, native and xref. The native type means the definition is constructed in KuDaShi, you can edit the definition in KuDaShi. The xref type means the definition is constructed by other applications or services, such as smart 3d text, etc. You can not change the xref definition, or an error will be threw. You can also see the KGroupInstance class for how each copy is defined.

Table of contents

Methods

Methods

findEntity

findEntity(key): KEntity

通过酷大师图形实体的唯一标识符,查找一个酷大师图形实体

The method is used to find and return the entity by its unique key. NOTE: 1.Only supports to find by face, group instance and auxiliary curve's keys. 2. Can only find the entity in the current definition, not recursive.

Parameters

NameTypeDescription
keystringThe input unique key.

Returns

KEntity

The found entity if successful, otherwise null.

Defined in

api.d.ts:2939


getAllCustomPropertiesKey

getAllCustomPropertiesKey(): string[]

获取该成组上所有的业务数据的key

Get all keys of custom property data which set by current plugin.

Returns

string[]

array of keys

Defined in

api.d.ts:3039


getAllReferenceGroupInstances

getAllReferenceGroupInstances(): KGroupInstance[]

获取酷大师方案中,所有应用本成组定义的成组实例

Get all the instances of this group definition.

Returns

KGroupInstance[]

An array of instances of this group definition.

Defined in

api.d.ts:2990


getAuxiliaryCurves

getAuxiliaryCurves(): KAuxiliaryCurve[]

获取参考线

Get all the auxiliary curves in this group definition.

Returns

KAuxiliaryCurve[]

An array of auxiliary curves in this group definition.

Defined in

api.d.ts:2981


getBoundingBox

getBoundingBox(): KBoundingBox3d

获取本成组定义的外包围盒

Get the bounding box of this group definition.

Returns

KBoundingBox3d

The bounding box.

Defined in

api.d.ts:3010


getCustomProperty

getCustomProperty(key): string

获取业务数据

Get custom property data.

Parameters

NameTypeDescription
keystring: unique key for this kind of custom.

Returns

string

Defined in

api.d.ts:3018


getKey

getKey(): string

获取成组的唯一标识符

Get a unique key assigned to a group definition.

Returns

string

The unique key.

Defined in

api.d.ts:2927


getShells

getShells(): KShell[]

获取组定义里直接包含的造型壳体

Get all the shells in this group definition.

Returns

KShell[]

An array of shells in this group definition.

Defined in

api.d.ts:2972


getSubGroupInstances

getSubGroupInstances(): KGroupInstance[]

获取子级的成组实例

Get all the sub group instances in this group definition.

Returns

KGroupInstance[]

An array of sub group instances in this group definition.

Defined in

api.d.ts:2963


getType

getType(): KGroupDefinitionType

获取成组的类型

Get the group definition's type.

Returns

KGroupDefinitionType

The group definition's type.

Defined in

api.d.ts:2918


getVarObject

getVarObject(): KVarObject

Get the varObject of groupDefinition if the groupDefinition's type is variable.

Returns

KVarObject

Defined in

api.d.ts:3046


isInExpressMode

isInExpressMode(): boolean

检查本成组定义是否处于快速模式 快速模式是成组的一种特殊显示模式。在这种模式下,我们不会在酷大师画布中加载成组的Brep数据,而只会加载它的三角网格数据。 这样可以大大减轻内存的压力,从而使酷大师打开更大的方案

Check whether the group definition is in express mode.

Returns

boolean

A flag to indicate whether the group definition is in express mode.

Defined in

api.d.ts:3001


matchEntities

matchEntities(key): KEntity[]

使用酷大师图形实体的唯一标识符,来匹配一个酷大师图形实体 这个 API 和上面的 findEntity 的不同点在于,这里用来查找的key,可以是一个老的 key,不一定是现有的图形实体的 key 例如,在一个矩形的造型面上添加了一条边,将其分割成两个面。那么,用一个老的造型面的key,就可以匹配到两个新的造型面 目前,这种匹配功能只支持造型面和造型边。且只支持当前组定义所直接包含的造型面和造型边的匹配,不包含其子级成组实例里面引用的造型面和造型边

Find the surviviors of the old entity after model modification. Note: 1. only support face and edge for now. 2. only can find the entities in the current definition, not recursive.

Parameters

NameTypeDescription
keystringThe key of an old entity.

Returns

KEntity[]

The survivor entities of the old entity. If the old entity was not modified, then itself will be returned.

Defined in

api.d.ts:2954


setCustomProperty

setCustomProperty(key, data): Object

添加业务数据

Set custom property data. key + value should be as small as possible, we have a maximum size limit which is around 256 characters. count of customProperty can't exceed 100.

Parameters

NameTypeDescription
keystring: key of custom
datastring: support string type

Returns

Object

NameType
isSuccessboolean

Defined in

api.d.ts:3030