高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】getting material id from an odavematerial objec
getting material id from an odavematerial object
getting material id from an odavematerial object
hi,
i have a liitle question: how can i delete a material?
i use the static method odavematerial::getattachedmaterial() to get the material id and after that i do the following:
bres = odavematerial::getattachedmaterial(tempid, matid);
if(bres)
{
oddbobjectptr pmat = matid.safeopenobject(oddb::kforwrite);
pmat->erase();
}
so this works fine when i have an attached material, but what can i do when there are some materials which are attached to nothing - then i cannot get the material id.
is there any way to get the material id for non attached materials or is there another method to delete these materials(not using the material id)?
thanks in advance.
nino
hi,
materials can be deleted from the database only by erase() method of corresponding database object.
you can use oddbgetmaterials(oddbdatabase* pdb) method to get all materials of database (see odamfcapp example, materialsdlg.cpp).
regards,
sergey vishnevetsky
yes, of course
i use this method to initialize the list with all the materials that are available in the drawing. but some of them are not attached to anything - so i cannot get their corresponding id because i cannot call getattchedmaterial() for them.
therefore they cannot be deleted untill they become attached to something.
so, does it mean that such materials cannot be deleted from the drawing at all?
thanks a lot.
nino
hi,
the odavematerial class is an interface to material data saved in xdata of oddbblockreference. the lack of objectid() method (or something similar) for odavematerial is our defect and we will add such method in dd 1.14.
as workaround, to get ids of all ave materials in database you can use the next code:
code:
oddbobjectidarray matids;
oddbblocktableptr ptbl = pdb->getblocktableid().safeopenobject();
oddbblocktablerecordptr prec = ptbl->getat("rm_sdb", oddb::kforread);
if (!prec.isnull())
{
prec->getblockreferenceids(matids);
}
regards,
sergey vishnevetsky
|