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

bug exporting oddbline objects?
transformby works for oddbline, doesn't appear to transform other objects
hi,
we have come across a problem whilst exporting .dgw files from our software.
we work in metre units, but sometimes we recieve dwg files with millimetre coordinates. when we import those files, we apply a scaling matrix to each object, that converts the objects to use metre coordinates. the scaling elements of the matrix are, in this case, 0.001 and 0.001.
when exporting the scaled objects, we export them by setting their unscalled coordinates and then calling the transformby method with our scaling matrix. this is an example of the code we use to create a polyline for export:
oddbpolylineptr splwpolyline;
odcmcolor colour(odcmentitycolor::kbycolor);
colour.setrgb(pcadlwpolyline->getcolour().m_rgba.r,pcadlwpolyline->getcolour().m_rgba.g,pcadlwpolyline->getcolour().m_rgba.b);
splwpolyline = oddbpolyline::createobject();
spmodelspace->appendoddbentity(splwpolyline);
splwpolyline->setconstantwidth(pcadlwpolyline->constant_width);
splwpolyline->setelevation(pcadlwpolyline->elevation);
splwpolyline->setthickness(pcadlwpolyline->thickness);
splwpolyline->setnormal( odgevector3d( pcadlwpolyline->extrusion.x, pcadlwpolyline->extrusion.y,pcadlwpolyline->extrusion.z));
splwpolyline->setclosed( (pcadlwpolyline->type_flags & 1) ? true : false);
//
// set individual vertices and their attributes
for(unsigned int nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex)
{
splwpolyline->addvertexat(nindex,odgepoint2d(pcadlwpolyline->vectors[nindex].x,pcadlwpolyline->vectors[nindex].y),pcadlwpolyline->bulge[nindex],pcadlwpolyline->start_width[nindex],pcadlwpolyline->end_width[nindex]);
}
splwpolyline->setlayer(dblayerid, false);
splwpolyline->setcolor(colour);
splwpolyline->transformby(transform);
we add all our cad entities to the model-space block table, then write the dwg database to a file.
loading the exported .dwg into autocad shows lines with the correctly scaled coordinates - that is their start and end points are now in metres and not millimeters. however other objects, like lightweight polylines and circles, still have the original millimetre coordinates.
i added some code to check the polyline vertices before and after calling transformby:
std::vector< vector3 > verticesbefore;
for( nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex )
{
odgepoint2d polypoint;
splwpolyline->getpointat( nindex, polypoint );
verticesbefore.push_back( vector3( polypoint.x, polypoint.y ) );
}
splwpolyline->transformby(transform);
std::vector< vector3 > verticesafter;
for( nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex )
{
odgepoint2d polypoint;
splwpolyline->getpointat( nindex, polypoint );
verticesafter.push_back( vector3( polypoint.x, polypoint.y ) );
}
vector3 is our native object for storing a point.
examining the contents of the before and after std::vectors shows the points to be exactly the same. it appears that no transformation has been applied.
is this a bug in the behaviour of transformby or is this designed behaviour? are there special criteria that need to be met to correctly apply transformby to any object?
indeed can transformby be used universally, or is better to use gettransformedcopy?
thanks,
james stewart
senior developer, legion ltd.
last edited by legion; 25th may 2006 at 05:03 amfff">. reason: change of bug description
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】adding custom objects to a custom dictionary yang686526 DirectDWG 0 2009-05-04 03:43 PM
【转帖】acad custom objects with dwgdirec yang686526 DirectDWG 0 2009-05-04 03:27 PM
【转帖】objectarx&dummies教程(十二)—— deriving from acdbobject yang686526 ObjectARX(C++) 0 2009-04-16 10:40 AM
【转帖】declaring objects and setting objects yang686526 SolidWorks二次开发 0 2009-04-12 08:38 PM


所有的时间均为北京时间。 现在的时间是 03:50 PM.


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