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

a problem of decimal separator
a problem of decimal separator
hi,
i have some questions about decimal separator when importing:
(1) is decimal seperator always a period in dxf?
(2) when importing a file( dwg or dxf file), if the decimal separator is comma, what we should do for this case? need we do some special things for it? now when the decimal separator is comma, it cann't import correctly, some data in oddb2dpolyline are wrong, but these data are right when using odreadex to read.( the decimal separator also is comma).
regards.
in dxf file decimal separator is always point (.)
dwgdirect uses atof() and sprintf() to convert between string and double. these functions take into consideration current locale. as a result they work incorrectly for dxf if computer has locale with comma as decimal separator.
windows application can temporary alter separator in current locale while loading/writing dxf (only separator and only for this instance of application)
sergey slezkin
my code is right?
hi,
thanks for your reply.
in my code i always have changed the decimal separator to period(.) before importing a dxf file. i use the following function to do this:
tchar* g_pdecimalsep = null;
bool begindxfimportexportspecific()
{
char name[128];
cstring csenglish = _t("english");
int rtn = getlocaleinfo(locale_user_default, locale_senglanguage, name,128);
if( rtn > 0 )
{
int numchars = 0;
numchars = getlocaleinfo(locale_user_default, locale_sdecimal, g_pdecimalsep, 0);
if(numchars > 0)
{
g_pdecimalsep = new tchar[numchars];
if (g_pdecimalsep != null)
{
rtn = getlocaleinfo(locale_user_default, locale_sdecimal, g_pdecimalsep, numchars);
assert( rtn > 0 );
// decimal seperator is always a period in dxf
cstring csdecimalsep = _t(".");
rtn = setlocaleinfo( locale_user_default, locale_sdecimal, csdecimalsep );
assert( rtn > 0 );
}
else
{
assert(0);
return false;
}
}
}
return true;
} fff">
is this function right?
now even if calling this function before importing a dxf file, there still have some errors: the vertex of a oddb2dpolyline have the same position. there still have somethings else need to be attentions, for example, need add some macros into the importing project or call some functions?
quote:
originally posted by sergey slezkin
in dxf file decimal separator is always point (.)
dwgdirect uses atof() and sprintf() to convert between string and double. these functions take into consideration current locale. as a result they work incorrectly for dxf if computer has locale with comma as decimal separator.
windows application can temporary alter separator in current locale while loading/writing dxf (only separator and only for this instance of application)
does the dxf file you experimenting with has correct decimal separators (.)?
what do you mean by "the vertex of a oddb2dpolyline have the same position"?
sergey slezkin
a probleme about decimal separator
hi,
i found some files have no decimal separator and some files have the right decimal separator(.). for the files which have no decimal separator, even if i call the function begindxfimportexportspecific() mentioned in my last post to change the locale decimal separator to period before importing, the data read from these dxf files are still wrong. for the files which have the correct decimal separator(.), the importing results some are right and some are wrong.
as to "the vertex of a oddb2dpolyline have the same position", i mean that:
before running my application, i set the local decimal separator to comma, then i run my application and my application will call the begindxfimportexportspecific() function to change the locale decimal separator to period(.) before reading dxf file, and do something like this:
oddb2dpolyline ppolyline;
oddb2dvertexptr pvertex, pvertex1;
if pvertex and pvertex1 are the vertex of the ppolyline, then we will get pvertex->position() == pvertex1->position(). a case occured here is that: the right positions of pvertex and pvertex1 read by odreadex are (1.689,6.11,0) and (1.581,6.11,0), but in my application they all change to (1.0,6.0,0).fff"> i don't know what cause this error( this error occurs in the e667032x_7.dxf file contained in e667032x_7.zip). i attach these dxf files here.(becasue the "dxf" is the invalid file extension, so i change "dxf" to "txt". if you test these files, please change the "txt" file extension to "dxf". )
and if i use odamfcapp to read these dxf files, even if the decimal separator is comma, the results are still good.
quote:
originally posted by sergey slezkin
does the dxf file you experimenting with has correct decimal separators (.)?
what do you mean by "the vertex of a oddb2dpolyline have the same position"?
attached files (71.1 kb, 5 views)
(28.0 kb, 4 views)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】olerances and decimal places yang686526 American standards 0 2009-05-04 10:52 AM
【转帖】decimal dimensioningfractional equivalents yang686526 American standards 0 2009-04-29 07:28 PM
【转帖】vista and addin dll problem yang686526 SolidWorks二次开发 0 2009-04-13 03:19 PM
【转帖】pdm problem yang686526 SolidWorks二次开发 0 2009-04-13 01:20 PM


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


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