几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 09:57 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】cosmosworks object is returning null 9c==0

cosmosworks object is returning null (c++)
hello all,
i am currently working on a project that runs a macro for cosmosworks in c++. however, for some reason, when i run my code my cosmosworks object is equal to null. i have supplied a section of my code to explain exactly how i am working it, could someone possibly steer me in the right direction, or inform me of any steps that i am missing.
void foo()
{
//pre: m_isldworks is a pointer to the sldworks object
ccombstr cwbstr = (_t("cosmosworks.cosmosworks));
ccomptr [icosmosworks] m_icosworks;
ccomptr[idispatch] swdispatch;
ccomptr[icwmodeldoc] cwmodel;
hresult hres;
if(m_isldworks->getaddinobject(cwbstr, &swdispatch) == s_ok)
{
checkpt
if(swdispatch)
{
hres = swdispatch->queryinterface(__uuidof(icosmosworks), (void **)&m_icosworks);
if(hres == s_false)
{
checkpt
return s_false;
}
if(m_icosworks)
{
hres = m_icosworks->get_activedoc(&cwmodel);
}
}
}
...
any help would be greatly appreciated.
brendan l
edited: 08/11/2008 at 01:26 pm by brendan l
is the cosmosworks add-in already loaded into solidworks before running this code? if not you need to call sldwors::loadaddin
i thought that might have been an issue and have actually tried that as well. both with cw already loaded.. and using the loadaddin function.
brendan leahy
so are you saying this line passes:
m_isldworks->getaddinobject(cwbstr, &swdispatch) == s_ok
and then this line does not evaluate true so is skipped:
if(swdispatch)
? also, not all code paths return a value (if the above if statement is not satisfied the function ends with no return, and on top of that the function specifies not to return any value anyway (void) yet you do inside the if statement.
and finally, can you clarify what checkpt is doing in this code? (my c++ brain is a bit sleepy today)
or is it that the query interface fails here:
hres = swdispatch->queryinterface(__uuidof(icosmosworks), (void **)&m_icosworks);
returning s_false?
oh, about checkpt, its a macro i wrote that tells me if it got to that line - i use it to debug the program. i thought i had taken them out. the problem is at the line
hres = swdispatch->queryinterface(__uuidof(icosmosworks),(void **)&m_icosworks);
when i am connected to a license of cosmosworks, and cw is loaded, this line sets m_icosworks == null. when i am not connected to a license (license on server)... this line returns a valid pointer to the m_icosworks. (which is something i just figured out).
this is a small tidbit of the code... there is a return s_ok at the very end of the function call that catchs anything that fails.
edited: 08/12/2008 at 10:33 am by brendan l
answer alright, so i figured it out. with the call:
if(m_isldworks->getaddinobject(cwbstr, &swdispatch) == s_ok),
the dispatch pointer is one to a cwaddincallback object instead of a cosmosworks object. changing the queryinterface to read:
if(swdispatch->queryinterface(iid_icwaddincallback, (void **) &cwaddincallback) == s_ok)
and then calling the
cwaddincallback->get_cosmosworks( &m_icosworks);
does the trick. i just am putting it up here for other people who might be interested in it.
thank you again for your help.
brendan l
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
编程修养 huangyhg 运行效率 1 2008-11-27 08:39 PM
深入探讨mfc消息泵 huangyhg vc编程 2 2007-10-29 04:14 PM


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


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