几何尺寸与公差论坛------致力于产品几何量公差标准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-05, 12:28 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how do i get to draw shapes

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:
  1. acgidrawable
  2. acgidrawable
  3. acdbblocktablerecord
  4. acdbblockreference
  5. acdbline
  6. acdbline
  7. 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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】draw to memory yang686526 DirectDWG 0 2009-05-04 08:06 PM
【转帖】draw a cross cursor in opengl device yang686526 DirectDWG 0 2009-05-04 08:05 PM
【转帖】calculating extents draw yang686526 DirectDWG 0 2009-05-04 05:17 PM
【转帖】insert a pic and draw on i yang686526 SolidWorks二次开发 0 2009-04-13 12:15 PM
【转帖】draw shaft using visual basic application yang686526 SolidWorks二次开发 0 2009-04-12 06:01 PM


所有的时间均为北京时间。 现在的时间是 10:06 AM.


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