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

nls error
nls error
we use dwgdirect version 2.2.0.0 and facing an issue in all .dwg file that we generate from our application.
when the generated .dwg files are opened in autocad 200/2004/2006/2008 etc., autocad gives the below warning:
"nls files required to convert text entities and symbol table in your dwg file from code page ascii to ansi_1252 cannot be found or not installed, etc...".
if the user chooses continue, he/she can open the file.
this happens for all the dwg files (and not .dxf)that our application generates.
what can be the possible reason for this warning message from autocad?
has anyone else faced such issue ?
tia
last edited by harshv@adobe.com; 6th august 2008 at 05:01 amfff">.
hello harsha,
check codepage of your database and check your implementation oddbsystemservices :: systemcodepage().
could you attach your sample file?
note version 2.2.0.0 was released two years ago and possible this problem is resolved now. try to use latest version dwgdirect 2.6.1.
best regards,
sergey z.
hi sergey,
i will try with 2.6.1 and will update the thread.
thanks,
harsha
the message about missing nls files may appear in autocad even if the file was created by autocad on another computer with different code page.
for example you create (in autocad) a file on japanese computer. it has code page ansi_932.
you open it on american computer without installed windows support for 932 code page.
autocad gives warning that windows support for characters conversion (nls files) are not installed.
in your case the message "... required to convert ...from code page ascii to ansi_1252 ..."
means that your implementation oddbsystemservices :: systemcodepage() returns ascii code page. this is not a standard windows code page and where is no nls files for it.
actually ascii means that only standard characters with codes < 128 are used and no nls files are required because the character codes are the same in all code pages. this is autocad's bug to give such message for ascii code page.
i don't think upgrading dd version may help. you need to fix your implementation of oddbsystemservices :: systemcodepage().
hi sslezkin.
you are right, moving to newer version of library is not fixing the problem. regarding the code page i checked that i have a class defined in exsystemservices.cpp as:
class exsystemservices : public oddbsystemservices
it has a variable m_codepageid which retains the code page id. m_codepageid is initialized in the constructor of exsystemservices. and it decides that based on the retun value of win api getacp() call. currently m_codepageid is set to cp_ansi_1252.
exsystemservices::exsystemservices()
: m_codepageid(cp_undefined)
{
#ifdef _win32
switch(::getacp())
{
case 874:
m_codepageid = cp_ansi_874;
break;
case 932:
m_codepageid = cp_ansi_932;
break;
case 936:
m_codepageid = cp_ansi_936;
break;
case 949:
m_codepageid = cp_ansi_949;
break;
case 950:
m_codepageid = cp_ansi_950;
break;
case 1200:
m_codepageid = cp_ansi_1200;
break;
case 1250:
m_codepageid = cp_ansi_1250;
break;
case 1251:
m_codepageid = cp_ansi_1251;
break;
case 1252:
m_codepageid = cp_ansi_1252;
break;
case 1253:
m_codepageid = cp_ansi_1253;
break;
case 1254:
m_codepageid = cp_ansi_1254;
break;
case 1255:
m_codepageid = cp_ansi_1255;
break;
case 1256:
m_codepageid = cp_ansi_1256;
break;
case 1257:
m_codepageid = cp_ansi_1257;
break;
}
#endif
}
systemcodepage() is defined in exsystemservices and returns m_codepageid.
odcodepageid exsystemservices::systemcodepage() const
{
return m_codepageid;
}
what needs to be rectified in the above code?
this code is ok. but based on the text of message autocad gives (from your first post) i see that file is created in "ascii" code page.
if you work on windows and you have not overloaded systemcodepage() than the question is: are you creating the new drawing from scratch or you load existing file? what code page is in dxf files? - at the beginning of the file:
9
$dwgcodepage
3
ansi_1252 // or "ascii" ?
in dxf files i see
9
$dwgcodepage
3
ansi_1252
i have no idea what is happening. dxf files are saved ok with ansi_1252 code page.
autocad message you wrote about in your first post says that dwg file's code page is "ascii". are you sure that the files (dwg & dxf) were saved on the same computer by the same program without changing regional settings and from the same source database?
are you converting existing files or creating new files from scratch?
i am creating files from scratch.
if you create files from scratch than your computer's system code page is used for the newly created files.
could you run odwriteex sample on your computer to create dxf and dwg files of the same version you create by your application and see if they are ok or show the same problem (message about missing nls files for "ascii" code page)?
hi sergey,
i tried to use the sample code odwriteex, both for mac (tiger) and win (xp), with dwddirect 2.6.3 and created files for autocad 2007 on both platforms. i can see the files created on win with 2.6.3 is no more giving problem but the ones created on mac are still giving the missing nls file error. with earlier version of the library(2.6.1) we had problem on both mac & win. please find the files created(using odwriteex) on mac & win, attached. i would like to mention again that the problem is with dwg files only when we create them using dwgdirect libraries and open in autocad.
thanks,
harsha
attached files (90.4 kb, 1 views)
(91.0 kb, 0 views)

on non-windows platform you need to take care about system code page yourself. see the source code above in this thread.
you can overload oddbsystemservices :: systemcodepage().
or call exsystemservices::setsystemcodepage()
sergey slezkin
hi sergey,
i got it that it has to be taken care on mac. above code which you referred is posted by me only. can you tell me that as we have :getacp() on win, what is the corresponding api on mac to get the code page?
-harsha
hi sergey,
i am back to the thread with some observations done while making some changes in my code. observations are as follows:
i). when files are saved with codepage info as ascii. dxf files don't give any error message but dwg files do give "nls files required..." error message as stated in the first message of the thread.
ii). when files are saved with codepage info as ansi_932 then there is not error message.
i have three questions around above mentioned behavior.
1. what is codepage information?
2. why do we need to give code page info while writing files? is there a way skip mentioning the codepage info to avoid the error message. and if there is a way to do that, then is there a potential problem if we don't mention codepage information.
3. why things work fine when code page is hardcoded as ansi_932. is this a correct thing to hardcode the codepage information?
thanks,
harsha
code page defines charset of texts stored in file. only latest autocad versions stores string data (texts) in unicode. olders versions store strings in mbcs. to display national characters (with code > 127) correctly on computer with another locale (for example to view on russian computer a drawing created on japanese computer) it's important to know the code page of the drawing.
it's impossible to skip code page information because it's part of file format (some value must present).
dwgdirect starting with version 2.0 stores texts at run time in unicode. if you pass to an api function non-unicode string it's converted from mbcs to unicode assuming that the non-unicode string has encoding defined by system code page.
for example oddbsymboltable::setname(const odstring& name);
odstring has constructor accepting odchar* (pointer to wide character) - no conversion is performed.
and a contructor accepting const char*. in this case conversion is perfomed from mbcs to unicode.
among autocad's code pages where is only one macintosh - cp_macintosh - mac-roman.
i'm not mac specialist and i may be wrong but it seems that the only safe way to produce valid files containing national characters on macintosh is to use only unicode in your program while passing strings to dd api functions:
player->setname("mylayer"); // this is safe only for english characters
player->setname(l"mylayer"); // unicode string is passed to api function
if you pass only unicode strings to dd api than it's not important if drawing code page is absolutely correct or not and it can be hardcoded as "mac-roman" for example.
because latest file format versions store strings in dwg as utf16 and in dxf as utf8.
while saving to minor versions characters which can't be converted to drawing's code page will be represented as mif or cif sequences (\m+nxxxx or \u+xxxx)
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】link errors in odreadex on visual studio 2005 yang686526 DirectDWG 0 2009-05-06 05:00 PM
【转帖】error when using afx.h yang686526 DirectDWG 0 2009-05-05 09:48 AM
【转帖】error c2664 yang686526 DirectDWG 0 2009-05-05 09:34 AM
【转帖】cant compile odrx-heap-operators90 in rxobject.h yang686526 DirectDWG 0 2009-05-04 05:31 PM
【转帖】2005 link error yang686526 DirectDWG 0 2009-05-04 02:57 PM


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


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