几何尺寸与公差论坛------致力于产品几何量公差标准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-07, 03:56 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】signs Of Coordinate Values

signs of coordinate values
signs of coordinate values
i am writing a program that converts dwg coordinate data from one coordinate system to another (e.g., a mercator projection to latitude/longitude). my program reads the coordinates from the objects, performs the conversion, then updates the objects. for many files this works very well, but i have run into a file where the signs on the coordinate values are not what i expected. (i was unable to attach the file to this message, but i would be glad to send it via e-mail, if necessary.)
when i look at this file in autocad, all of the coordinates fall within the range of about (2.84e+6, 7.15e+5) to (2.85e+6, 7.24e+5). when i look at the coordinate values of individual oddbpolyline objects using the odamfcapp, some of the coordinates have negative values, even though the extents of the object are positive. sometimes the x value is negative, and sometimes the y value is negative. needless to say, using these values as is causes my coordinate conversions to produce the wrong results.
it appears that this only happens with oddbpolyline objects. other object types seem to have coordinate values that are positive.
i assume that there is another piece of information that i need to take into account in order to make sure i am using the correct coordinate values as input to my coordinate transformation process. does anyone have any ideas as to what this might be?
thanks.
bob
it's been a while since i started this thread, so i thought i would bump it up and add some more information to see if anyone has some answers.
i've noticed that the elevation of the polyline seems to be involved. several of the polylines in the attached file have a negative elevation. when reading coordinates from those objects, the x coordinate of the point returned when i call oddbpolyline::getpointat(odgepolyline3d) differs from the x coordinate of the point returned when i call oddbpolyline::getpointat(odgepolyline2d). (the 2d point is the one that has the negative x coordinate.)
when the elevation is positive, the x and y coordinates for the 2d and 3d points are the same.
to illustrate this, i have attached a zip file containing a .dwg file where this problem occurs, and a modified exprotocolextension.cpp that i used in odreadex to compare the 2d and 3d values returned from the polylines. the 2d points in last polyline (handle 6de) have positive x coordinates, while all of the others have negative x coordinates. all of the x coordinates should be positive. this can also be seen by opening the file in odamfcappdll and looking a the polylines in the model_space block.
my questions are:
1) is there something wrong with the .dwg file? i haven't found other files where this happens, so it seems possible that this is the case.
2) is the flipped sign on the 2d point something to be expected because of the negative elevation, and therefore, something i should account for in my code?
3) is this a bug in dwgdirect?
i am using dwgdirect 2.6.3 with visual studio 2005.
cheers,
bob
attached files (69.6 kb, 0 views)

polyline entity has its object coordinate system (ocs). it's defined by polyline's normal. see odgematrix3d::worldtoplane() and planetoworld() methods. they return transformation matrices convertin between worl coordinate system (wcs) and ocs.
polyline functions returning 2d geometry return it in ocs.
polyline functions returning 3d geometry return it in wcs.
even in 2d drawing ocs and wcs can be different if entity's normal is not (0,0,1) but (0,0,-1).
sergey slezkin
thanks for the information. it sounds like i should be performing the following steps to transform each point in a polyline (assumes simplest case where the polyline is made up entirely of line segments):
code:
// open polyline for write
for (int i = 0; i < polyline-numverts(); i++)
{
odgepoint3d pt;
polyline->getpointat(i, pt); // pt is in wcs coordinates
odgepoint3d ptxf = // transform the wcs point
// convert the transformed wcs point back to ocs
odgepoint3d ocspt = ptxf.transformby(odgematrix3d::worldtoplane(polyline->normal()));
// make a 2d point to update the polyline
odgepoint2d ptout(ocspt.x, ocspt.y);
polyline->setpointat(i, ptout);
}does this look correct?
should i be concerned with the oddbpolyline::isplanar() and oddbpolyline::getplane(), or can i just use the normal?
cheers,
bob
last edited by bobc@bluemarblegeo.com; 3rd november 2008 at 11:57 amfff">. reason: fix code in example
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】set Block Attribute Values yang686526 DirectDWG 0 2009-05-07 03:36 PM
【转帖】read units values yang686526 DirectDWG 0 2009-05-07 12:26 PM
[求助]遍历图块中子图元时,提取子图元的点数据如何不对 yang686526 ObjectARX(AutoLISP) 0 2009-04-22 07:46 PM
【转帖】problem for getting coordinate system axes components yang686526 SolidWorks二次开发 0 2009-04-13 01:34 PM
【转帖】how can i programmatically insert a coordinate system yang686526 SolidWorks二次开发 0 2009-04-12 09:09 PM


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


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