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

dwginfields & dwgoutfields question
dwginfields & dwgoutfields question
hello,
i have a problem with implementation of dwginfileds and dwgoutfileds methods in custom object, derived from dd objects:
class exoddbline : public oddbline
odresult exoddbline::dwginfields(oddbdwgfiler* pfiler)
{
odresult res = oddbline::dwginfields(pfiler);
if (pfiler->filertype() != oddbfiler::kfilefiler)
{
myint = pfiler->rdint32();
}
}
similar i have implemented also dwgoutfileds.
my application reads a dxf/dwg file, and when it finds oddbline entity, it runs this command:
oddblineptr plineent
...
exoddblineptr pexline = exoddbline::createobject();
pexlineptr->copyfrom(plineent);
when content of line entity is copied into new custom entity, dwginfields of custom entity is called, and dd throws an exception, because it tries to read
integer, which was not written into "filer" by original line entity.
am i doing something wrong, or is this an expected behavior and i should put rd... methods in a try-catch block?
i have searched through dd examples, and dwginfields method does not contain try-catch block, so i am a little confused.
can anybody help me regarding this issue?
best regards, tomaz
default implementation of copyfrom() works only for objects of the same class in dd (in arx it always throws exception)
to use copyfrom() in your case you need to override it in your class.
but if you use substitution of run-time class by altering pseudo-constructor (as we discussed in another thread) the situation then both oddbline and exoddbline objects exist is impossible.
exoddbline objects should be created at file loading.
if this is not the case - something is wrong.
have you called exoddbline::rxinit() before loading the file?
sergey slezkin

hi
substitution works fine now (you gave me a solution in the another thread), so i will use this approach - no need to call copyfrom anymore.
thank you for all your help.
best regards, tomaz
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)