[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxProperties Window Custom
Class: MxPropertiesWindowCustom
2d.MxPropertiesWindowCustom
Add custom properties to the MxProperties Window Custom properties window
Table of contents
Constructors
Methods
- getEntityProperties
- onEvent_getProperties
- onEvent_setProperties
- setEntityProperties
- setEntitySupportCustom
Constructors
constructor
• new MxPropertiesWindowCustom()
Methods
getEntityProperties
▸ getEntityProperties(id
): MxPropertiesWindowCustomValue
[]
Attribute UI program call to obtain custom attributes of a given entity
Parameters
Name | Type |
---|---|
id | McObjectId |
Returns
MxPropertiesWindowCustomValue
[]
onEvent_getProperties
▸ onEvent_getProperties(call
): void
Plugin program call, register and return object custom property functions.
Parameters
Name | Type |
---|---|
call | (id : McObjectId ) => MxPropertiesWindowCustomValue [] |
Returns
void
Example
//On the property interface, obtain the object property event.
MxCpp.PropertiesWindow.onEvent_getProperties((id: McObjectId) => {
let ent = id.getMcDbEntity();
if (!ent) return [];
let dn = ent.getxDataDouble("DN");
let len = ent.getxDataDouble("LEN");
let ret = [];
if (dn.ret) {
ret.push({
sVarName: "DN",
iVarType: MxPropertiesWindowCustomValueType.kDouble,
val: dn.val,
isOnlyRead: false
});
}
if (len.ret) {
ret.push({
sVarName: "LEN",
iVarType: MxPropertiesWindowCustomValueType.kDouble,
val: len.val,
isOnlyRead: false
});
}
return ret;
})
onEvent_setProperties
▸ onEvent_setProperties(call
): void
Plugin program call, register and set object custom property functions.
Parameters
Name | Type |
---|---|
call | (id : McObjectId , prop : MxPropertiesWindowCustomValue ) => void |
Returns
void
Example
//On the property interface, the event of object property being modified.
MxCpp.PropertiesWindow.onEvent_setProperties((id: McObjectId, prop: any) => {
let ent = id.getMcDbEntity();
if (!ent) return;
if (prop.sVarName == "DN") {
ent.setxDataDouble("DN", prop.val);
}
else if (prop.sVarName == "LEN") {
ent.setxDataDouble("LEN", prop.val);
}
});
setEntityProperties
▸ setEntityProperties(id
, prop
): void
Attribute UI program call, set custom attributes for a given entity
Parameters
Name | Type |
---|---|
id | McObjectId |
prop | MxPropertiesWindowCustomValue |
Returns
void
setEntitySupportCustom
▸ setEntitySupportCustom(id
, isCustomProperties?
): void
The plugin program is called to set the state of the object to support custom properties displayed in the property window.
Parameters
Name | Type | Default value |
---|---|---|
id | McObjectId | undefined |
isCustomProperties | boolean | true |
Returns
void
Example
import { MxCADUiPrEntity, MxCpp } from "mxcad";
//Set object extension property values.
async function Mx_TestExProp() {
let selEntity1 = new MxCADUiPrEntity();
SelElement1.setMessage ("Select the object to enable custom properties");
let idText = await selEntity1.go();
if (!idText.isValid()) return;
let ent = idText.getMcDbEntity();
MxCpp.PropertiesWindow.setEntitySupportCustom(idText);
//Set object extension property values.
ent.setxDataDouble("DN", 100);
ent.setxDataDouble("LEN", 2000);
}