查看单个帖子
旧 2009-05-04, 03:43 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】adding attributes

adding attributes
adding attributes
hi!
i need to add some attributes in a dxf file, thickness and material type. i'm kind of new to this and have managed to puzzle below function together.
code:
oddbobjectid centity_utils:ncreateblock( oddbdatabaseptr pdb, odstring blkname )
{
// open the block table
oddbblocktableptr pblocks = pdb->getblocktableid().safeopenobject(oddb::kforwrite) ;
//attempt to find the block before inserting
oddbobjectid blkid = pblocks->getat(blkname);
if(blkid.isnull()){
//create block here
oddbblocktablerecordptr pentry = oddbblocktablerecord::createobject();
// block must have a name before adding it to the table.
pentry->setname(blkname);
//create text attribute material type
oddbattributedefinitionptr def = oddbattributedefinition::createobject();
odstring strmaterialtype = (lpctstr)::api_fcc_get_view()->m_strmaterialstring;
def->setprompt("enter material type");
def->settag("material");
def->settextstring( strmaterialtype );
def->setinvisible(false);
pentry->appendoddbentity(def);

//create text attribute material thickness
oddbattributedefinitionptr mydef = oddbattributedefinition::createobject();
odstring strmaterialthickness = (lpctstr)::api_fcc_get_view()->m_strmmvalue;
mydef->setprompt("enter material thickness");
mydef->settag("thickness");
mydef->settextstring( strmaterialthickness );//default value
mydef->setinvisible(false);
pentry->appendoddbentity(mydef);
blkid = pblocks->add(pentry);
}
return blkid;
}i would very much like it to show up in the "autocad text window" ( command line: list/all ) as a block but there's nothing so far.
please! any help would be much appreciated.
thanks!
kennet
afaik "list" lists only entities.
perhaps you may create an insert of your block.
vladimir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)