2019-12-03
01:15 PM
- last edited on
2022-09-29
09:54 AM
by
Daniel Kassai
API_AttrTypeID typeID = API_MaterialID;
API_Attribute attrib;
API_AttributeDefExt defs;
BNZeroMemory(&attrib, sizeof(API_Attribute));
attrib.header.typeID = typeID;
strcpy(attrib.header.name, u8"玻璃 - 蓝色");
err = ACAPI_Attribute_Get(&attrib);
if (err == NoError) {
err = ACAPI_Attribute_GetDefExt(typeID, attrib.header.index, &defs);
if (err == APIERR_BADID) {
BNZeroMemory(&defs, sizeof(API_AttributeDefExt));
err = NoError;
}
//能见度100
attrib.material.transpPc = 100;
if (err == NoError) {
strcpy(attrib.header.name, name.ToCStr().Get());
err = ACAPI_Attribute_Create(&attrib,nullptr);
}
ACAPI_DisposeAttrDefsHdlsExt(&defs);
}
2019-12-03 02:43 PM
GS::UniString attrName (u8"玻璃 - 蓝色"); attrib.header.uniStringNamePtr = &attrName;and instead of strcpy(attrib.header.name, name.ToCStr().Get()); use:
attrib.header.uniStringNamePtr = &name;Best, Akos
2019-12-04 02:08 AM
Akos wrote:According to your method,the problem also occuers.
Hi,
Please use attrib.header.uniStringNamePtr Instead of attrib.header.name, because the .name is limited in length:
GS::UniString attrName (u8"玻璃 - 蓝色"); attrib.header.uniStringNamePtr = &attrName;and instead of strcpy(attrib.header.name, name.ToCStr().Get()); use:
attrib.header.uniStringNamePtr = &name;Best, Akos
2019-12-04 10:41 AM
DevJeer wrote:I notice you've changed the call for creating the material to
Akos wrote:According to your method,the problem also occuers.
Hi,
Please use attrib.header.uniStringNamePtr Instead of attrib.header.name, because the .name is limited in length:
GS::UniString attrName (u8"玻璃 - 蓝色"); attrib.header.uniStringNamePtr = &attrName;and instead of strcpy(attrib.header.name, name.ToCStr().Get()); use:
attrib.header.uniStringNamePtr = &name;Best, Akos
2019-12-04 05:57 PM
{
GS::UniString name (u8"能见度100");
API_AttrTypeID typeID = API_MaterialID;
API_Attribute attrib = {};
API_AttributeDefExt defs = {};
GSErrCode err = NoError;
GS::UniString attrName(u8"玻璃 - 蓝色");
attrib.header.typeID = typeID;
attrib.header.uniStringNamePtr = &attrName;
//strcpy(attrib.header.name, u8"玻璃 - 蓝色");
err = ACAPI_Attribute_Get (&attrib);
if (err == NoError)
{
err = ACAPI_Attribute_GetDefExt (typeID, attrib.header.index, &defs);
if (err == APIERR_BADID)
{
err = NoError;
}
//能见度100
attrib.material.transpPc = 100;
if (err == NoError)
{
attrib.header.uniStringNamePtr = &name;
//strcpy(attrib.header.name, name.ToCStr().Get());
err = ACAPI_Attribute_CreateExt (&attrib, &defs);
}
}
ACAPI_DisposeAttrDefsHdlsExt(&defs);
return;
}
I think the main problem was calling ACAPI_Attribute_Create instead of ACAPI_Attribute_CreateExt.2019-12-05 02:20 AM
API_AttrTypeID typeID = API_MaterialID;
GSErrCode err = NoError;
API_Attribute attrib={};
API_AttributeDefExt defs={};
attrib.header.typeID = typeID;
//strcpy(attrib.header.name, u8"玻璃 - 蓝色");
GS::UniString materialName(u8"玻璃 - 蓝色");
attrib.header.uniStringNamePtr = &materialName;
err = ACAPI_Attribute_Get(&attrib);
if (err == NoError) {
err = ACAPI_Attribute_GetDefExt(typeID, attrib.header.index, &defs);
if (err == APIERR_BADID) {
BNZeroMemory( & defs, sizeof(API_AttributeDefExt));
err = NoError;
}
//能见度100
attrib.material.transpPc = 100;
if (err == NoError) {
//strcpy(attrib.header.name, name.ToCStr().Get());
GS::UniString attrName(u8"界线");
attrib.header.uniStringNamePtr = &attrName;
err = ACAPI_Attribute_CreateExt( &attrib, &defs);
}
ACAPI_DisposeAttrDefsHdlsExt(&defs);
}
The same problem also occurs.