how do i get to draw shapes
how do i get to draw shapes
i write an import tool for dwg and dxf files. i can interpret most of acad's entities including text but i can only import truetype fonts. i cannot interpret shx fonts and shapes. how do i get worlddraw to take care of shx fonts and leave ttf fonts only for me (my worldgeometry) to handle.
i installed a protocol extension for dbfont entity (as well as for other entities) so i know when text is about to be drawn. i can test at that point what font i am dealing with but i do not know how make worlddraw to draw shapes for me. what do have i have to do?
thanks
having recieved text() primitive you can process it yourself (ttf) or call base class implementation which will split shx into polylines.
sergey slezkin
i changed my design to be based on odgibasedrawobject instead of on separate (and more abstract) classes giworlddraw, giworldgeometry and gisubentitytraits. i've kept all the methods i had defined for my previous giworldgeometry in there, particularly these: worldline, circle, circulararc, elliparc, polygon, polyline, pline, mesh, shell, text, xline, ray, and nurbs; when my version of text() gets called, i look at its style, and if it uses ttf font i draw the text on my own. otherwise i call odgibasedrawobject::text() to draw it for me. i hoped that would explode the text into simpler entities based on however the shape file was defined, and i would get called to draw primitives such as line and polyline. but the base class' method does not seem to be doing anything because i do not get called at all. what am i missing? what else do i have to override (from odgibasedrawobject) in order to let dwgdirect draw shapes for me? or have i completely misunderstood the concept?
arno歵
i have not been able to resolve this problem yet. does anybody have any idea? the way i draw text goes like this:
in an iteration, i get a oddbtext object. i do not do need to do anything at this higher level, so i call odgibasedrawobject::draw(oddbtext). then later, i receive the text in my version of gigeometry text() function. i test the font, and if it is a truetype, i draw it. if it is a shape or a shapefont, i call odgibasedrawobject::text(...) instead, hoping that the parent method would be able to explode the textinto basic primitives. but it does not do anything. does anybody know what is wrong? please?
note: i tried to play with exhostappservices::findfile() to see if it changes anything. but whether i return a path to an existing txt.shx file or i return the value from default oddbhostappservices, the result is the same - no entities for shx text.
thanks
arno歵
was the ::findfile() success or failure?
environment var:
( i'm sure you are aware already )
acad=f:\program files\autocad 2002\fonts;f:\program files\autocad 2002\support
the default ::filefind returns an empty string. my version would return a path (complete) to a txt.shx font. the text was not rendered in neither of the two cases.
i do not have an acad environment var set. i thought dwgdirect would use a default shape (probably simplex) in case an actual font cannot be found.
if the font is not found dd uses built-in font. previous dd versions displayed squares instead of characters. so the problem is not in findfile(). while drawing text basedrawobject should call polyline function:
code:
void xxx:

olyline(odint32 nbpoints,
const odgepoint3d* pvertexlist,
const odgevector3d* pnormal,
odint32 lbasesubentmarker);
check your function prototype.
sergey slezkin
basedrawobject::text() does not call polyline (prototype's fine); not in my case, anyway. it does not call any other geometry function either. but i have the feeling the problem may be somewhere else. maybe my context is setup incorectly or something like that. i'll dig deeper into the examples again to figure it out.
thanks for your hints
arno歵
look into odvectorizeex. it has only polylinedc(), polygondc() and circle() functions defined.
text() results in polylinedc() calls but if polyline is defined it should be called for text().
sergey slezkin
sergey,
i took your advice and have based my project on the vectorize example (instead of dumper). to start, i only wrote polygondc and polylinedc methods to see how it worked. and it does work indeed, but it crashes evertime i try to import a block either it'd be just a regular block or another compound object like dimensions. first i though that i had something in those two functions so i removed them too - now my simpleview class only overrides regenabort() and deviation(), whereas my simpledevice class defines createview() only. and it still crashes every time i try to open a block. i looked at the stack and it crashes in oddbobjectimpl::destructor when calling free(). that destructor is called from oddbobject::destructor(). i wanted to find out what object exactly caused the crash, so i overrode the draw() method. i created a simple dwg with just one block in it (a rect with two lines as diagonals) and tried to import it. this is the sequence of objects i received in my draw() method:
- acgidrawable
- acgidrawable
- acdbblocktablerecord
- acdbblockreference
- acdbline
- acdbline
- acdbpolyline
all entities of the block were called to be drawn and then it crashed. so it really looks like the block's destructor is doing something wrong.
can you help me?
thanks
arno歵
(btw, i am using the latest 1.09 available.)
hi all,
i've found the problem. entirely my fault. i put oduninitialize into the same try{}...catch{} block where i also created odgsdeviceptr. therefore when odgsdeviceptr was about to leave the scope and needed to delete some stuff, the database was already unitialized and it crashed. it was bad luck, i think, that it crashed only when a block was in the dwg.
now it works like it shoud.
thanks