几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】adding attributes (http://www.dimcax.com/hust/showthread.php?t=15049)

yang686526 2009-05-04 03:43 PM

【转帖】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::oncreateblock( 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


所有的时间均为北京时间。 现在的时间是 05:41 PM.