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

regenerating associated hatches
regenerating associated hatches
the subject application converts (e.g. units change) an entire drawing, and successfully (with your help) converts non-associated hatch objects by converting the loop(s) and "evaluating the loop(s)".
how do i get the associated hatches to be regenerated using the newly converted entities to which is it associated?
i have tried delaying conversion of all hatches until after all other entities have been converted, and then "evaluating the loop" on all associated hatches. no luck. any help would be appreciated.
note: i am not viewing or displaying the converted file. so, a fix which will simply cause autocad to regenerate the hatch next time the drawing file is opened/loaded would be acceptable.
norm olsen
you may use exevalwatcher module - it does what you need.
or you may do it manually:
assuming that
oddbhatch* phatch - hatch to eval
oddbobjectidarray& assocobjids - associated objects
call
oddbhatchwatcherpeptr eval(phatch)->evaluate(phatch, assocobjids);
vladimir
i'm not the sharpest pencil in the box. i'm having difficulty understanding:
"call oddbhatchwatcherpeptr eval(phatch)->evaluate(phatch, assocobjids);"
oddbhatchwatcherpe has an evaluate function; i can understand that part. i don't understand the
"call oddbhatchwatcherpeptr eval(phatch)"
portion.
i don't see an "eval" function anywhere?
to what object does the "eval" function belong?
does "eval(phatch)" return a oddbhatchwatcherpeptr ?
how does one obtain a pointer to an oddbhatchwatcherpe object?
clearly, i'm missing something obvious here. any help wwould be greatly appreciated.
norm olsen
quote:
originally posted by olsennt
"call oddbhatchwatcherpeptr eval(phatch)->evaluate(phatch, assocobjids);"
sorry, for the unclear reply - 'eval' should be erased there (or statement split in two: cast && call)
the statement means - cast phatch to oddbhatchwatcherpeptr and call oddbhatchwatcherpe::eval
make sure exevalwatcher module is available.
vladimir

hello, it's me again. please understand that despite several hours of searching the help file, andstudying the example, i have no clue as to what an extension protocol is, how they work, and (most omportantly) how to use them. if that makes me stupid, i plead guilty.
i have implemented the exevalwatcher module. how does one use it?
1> does it have to be registered (the help file says it is registered by the initialization)?
2> do you have to close it?
i have arranged for my application to do hatches after everything else is done. i have tried the following code to get the associated hatches evaluated; but none of several different methods of casting seem to work. some compile, but throw a run-time error.
bool tuacadconverter::convert (oddbhatch& object)
{
bool ok (true);
if (object.associative ())
{
oddbobjectidarray dbobjids;
object.getassocobjids(dbobjids);
oddbhatchwatcherpeptr phatchpe = (oddbhatchwatcherpeptr)(&object);
phatchpe->evaluate (&object,dbobjids);
ok = true;
}
else
{
// this stuff works, thanks for your help!!
}
}
it would be most helpful if i had a clue as to what protocol extensions are and how they work. i could probably figure this out if i did. the help file simply makes a very vague statement, and then offers a very confusing example that i can't figure out.
thanks for putting up with my stupidity.
norm olsen
you can find example of using/registering/unregistering protocol extensions in odreadex sample.
in this sample the protocol extension is used for dumping entities.
sergey slezkin
and the answer is . . .
thanks for all your help. i'm not a c++ guru, so it took me a while; but i have finally figured this out.
for others who may encounter this problem:
the help file is somewhat misleading in that the oddbhatchwatcherpe object is not registered by the odinitialize function. it is only registered by the exevalwatcher module. the exevalwatcher is one of those things that needs to be loaded using the dynamic loader business, and this means your application is dependent upon an external .dll (renamed to drx, but still a .dll). thus, using this technique you become subject to dll hell issues.
i have found that you can bypass all of that by registering the oddbhatchwatcherpe object directly in your application. this requires declaring an object using the odstaticrxobject template, defining an instance of this object, and then registering the type and the instance with the target entity, oddbhatch in this case. that is:
odstaticrxobject<oddbhatchwatcherpe> kuhatchwatcher;
oddbhatch::desc()->addx(oddbevalwatcherpe::desc(),&kuhatchwatcher) ;
once this is accomplished, the casting referenced in the previous posts will work and you can get access to the oddbhatchwatcherpe::evaluate () function. this function works fabulously.
best to do this registering business immediately after the odinitialize () call to maintain multi-thread safety, i would presume.
note that the standard distribution includes pre-built exevalwatchers modules for vc8 and vc2003 only. if you're using something else, you'll have to figure out how to build one of these things yourself. the above is a simple way to avoid all of the problems associated with this, providing your application is capable of determining on its own which hatches need to be updated (as my application is).
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)