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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-04, 04:46 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】block creation

block creation
block creation
what i have to do for creation a block and a reference to this block ?
i open the blocktable, creates a blocktablerecord and add it to the table.
then i add some entities to the blockrecord. after this i create the blockreference and store it to e.g. modelspace.
the file writing crashes.
can you give more on the nature of the crash and provide some code as well?
codefragment, error message
sorry, many tabs inside the code fragment.
call stack
kernel32! 77f1d479()
msvcrt! 78008fa5()
dd_db! 627ebb1f()
and
kernel32! 77f1d479()
msvcrt! 78008fa5()
dd_db! 6286907c()
nexi_acdd_doccoverdecorator::initializeforconverti ng() line 1112
after crash : !! dwgdirecterror : was open for write
oddbblocktableptr pblocks = m_ad2tbh.m_val->getblocktableid().safeopenobject(oddb::kforwrite) ;
// get an iterator for the block table
oddbsymboltableiteratorptr pblkiter = pblocks->newiterator();
for (pblkiter->start(); ! pblkiter->done(); pblkiter->step())
{
// open the block
blocktablerecordptr pblock = pblkiter->getrecordid().safeopenobject(oddb::kforwrite);
// get an entity iterator
oddbobjectiteratorptr pentiter = pblock->newiterator();
// for each entity in the block
oddbvoidptrarray explodeentityset;
oddbvoidptrarray eraseentityset;
oddbvoidptrarray::iterator it;
n_bool iterisstepped = n_true; // for the first step
for ( ; !pentiter->done () ; )
{
if ( iterisstepped == n_false )
pentiter->step ();
if ( pentiter->done () )
break;
iterisstepped = n_false;
oddbentityptr pentity = pentiter->entity(oddb::kforwrite);
odsmartptr<oddbentity_analyzer> pentanalyzer = pentity;
switch ( pentanalyzer->gettype () )
case dbenttype_hatch :
{
n_char* stringidptr;
oddbvoidptrarray explodeset;
oddbhatch subent;
oddbhatchptr psubent;
psubent = pentity;
int length=0;
odresult result = psubent->explode ( explodeset );
if ( result == eok )
{
oddbblocktablerecordptr newblocktablerecordptr = new oddbblocktablerecord;
if ( !newblocktablerecordptr.isnull() )
{
odstring newname;
newname.format("%s_%d",stringidptr,knum++);
newblocktablerecordptr->setname (newname);
// add the new blocktablerecord to the table
pblocks->add (newblocktablerecordptr);
for ( it = explodeset.begin () ; it != explodeset.end () ; ++it )
{
odrxobjectptr pexplodeobject = (*it);
oddbentityptr pexplodeentity = pexplodeobject;
newblocktablerecordptr->appendoddbentity ( pexplodeentity );
}
// add an insert for the new block
oddbblockreferenceptr insertptr = new oddbblockreference;
if ( !insertptr.isnull () )
{
insertptr->setposition (odgepoint3d(0.0,0.0,0.0));
insertptr->setrotation (0.0);
insertptr->setscalefactors (odgescale3d(1.0,1.0,1.0));
insertptr->setblocktablerecord (newblocktablerecordptr->objectid());
pblock->appendoddbentity ( insertptr );
}
}
eraseentityset.push_back ((odrxobjectptr)(pentity));
}
break;
}
}
for ( it = eraseentityset.begin () ; it != eraseentityset.end () ; ++it )
{
odrxobjectptr peraseobject = (*it);
oddbentityptr peraseentity = peraseobject;
peraseentity->erase ();
}
}
}
outver = oddb::vac15;
s_filetype = oddb::kdwg;
odwrfilebuf fb ( tempfilename.data () );
m_ad2tbh.m_val->writefile ( &fb, s_filetype, outver );
openforwrite exception during file writing means that an attempt was made to save to file an object which was opened for write and was not closed.
after a new object is created or existing one is modified dd needs to perform some actions to make the object and database valid. this actions are performed in 'close' procedure. close is performed at the moment the last smart pointer to the object is destroyed or assigned another value (reference counter is used).
you need use one of methods below:
code:
oddbobjectptr pobj = .....
// object is created or modified
pobj.release();
// or
pobj = null;
pdb->writefile();
or
{
oddbobjectptr pobj = .....
// object is created or modified
}
// object is closed as a result of leaving smart pointer's scope
pdb->writefile();
sergey slezkin
heureka !
hi sergej, thank you,
i searched for "close", "save" and "write" inside the documentation.
regards,
uwe
ps : my bug was
oddbblocktablerecordptr pblock1 = new oddbblocktablerecord;
instead
oddbblocktablerecordptr pblock1 = oddbblocktablerecord::createobject ();
last edited by uspiess@nemetschek.de; 28th january 2004 at 11:54 pmfff">.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】solidworks drawing creation manual yang686526 SolidWorks二次开发 0 2009-04-13 02:31 PM
【转帖】how to get axis pointer at creation time yang686526 SolidWorks二次开发 0 2009-04-12 09:17 PM
【转帖】how to get axis pointer at creation time yang686526 SolidWorks二次开发 0 2009-04-12 06:33 PM
1-354247171 - Automating cylinder creation in SW API huangyhg SolidWorks二次开发 4 2007-09-04 01:09 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多