![]() |
【转帖】create block
create block
create block i am want to create block in autocad. i has created blocktablerecord in blocktable. now i want to insert the block(created blocktablerecord ). visual studio 2005 c++ dwgdirect c++ libraries 2.3.1 coding: void export::createprimitive( oddbdatabase* pdb, oddbblocktablerecord* pblock, dotcad:rawing::layer^ layer, oddbobjectid btrid ) { oddbblockreferenceptr pblkref = oddbblockreference::createobject(); pblkref->setdatabasedefaults( pdb ); oddbobjectid btrrefid = pblock->appendoddbentity( pblkref ); pblkref->setlayer( convertlayer( pdb, layer ), true ); pblkref->setblocktablerecord(btrid); pblkref->setscalefactors( odgescale3d( 20, 20, 20 ) ); oddbblockreferenceptr pblkref1 = btrrefid.safeopenobject( oddb::kforwrite ); odgematrix3d blkxfm; blkxfm.settranslation( odgevector3d( 1.0, 0.0, 0.0 ) ); pblkref1->transformby(blkxfm); oddbblocktablerecordptr pblockdef = btrid.safeopenobject(); oddbobjectiteratorptr piter = pblockdef->newiterator(); oddbentityptr pentity; oddbattributedefinitionptr pattdef; for(piter->start(); !piter->done(); piter->step()) { pentity = piter->entity(); pattdef = oddbattributedefinition::cast(pentity); if((!pattdef.isnull()) && (!pattdef->isconstant())) { oddbattributeptr patt = oddbattribute::createobject(); patt->setdatabasedefaults( pdb ); pblkref1->appendattribute( patt ); patt->setpropertiesfrom ( pattdef, false ); patt->setalignmentpoint ( pattdef->alignmentpoint() ); patt->setheight ( pattdef->height() ); patt->sethorizontalmode ( pattdef->horizontalmode() ); patt->setnormal ( pattdef->normal() ); patt->setoblique ( pattdef->oblique() ); patt->setposition ( pattdef->position() ); patt->setrotation ( pattdef->rotation() ); patt->settextstring ( pattdef->textstring() ); patt->settextstyle ( pattdef->textstyle() ); patt->setwidthfactor ( pattdef->widthfactor() ); patt->settextstring ( l"the value" ); patt->transformby ( blkxfm ); } } } the block can't display,why? pattdef" is always null. help me . thanks! (i was referenced "odwriteex" of examples) block reference may be invisible if - block does not contain entities :-) - the entities are on invisible (or frozen) layer, - the block reference is inserted into a block (pblock) which is not referenced from model of paper spaces (pblock is not inserted into layouts). pattdef would be always null if the block table record contains no oddbattributedefinition entities. try to load the saved file into odamfcapp and examine it's structure in tree control. sergey slezkin thank you very much. now ok. |
所有的时间均为北京时间。 现在的时间是 08:14 AM. |