几何尺寸与公差论坛------致力于产品几何量公差标准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, 01:09 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】not able to get active document using api in case of assemblies

not able to get "active document" using api in case of assemblies
hi
i have made an application in vc++. in this application you can choose a part or assembly in a browse dialog and then it will launch solidworks(using shellexecute) with the part or assembly chosen.
then i get an instance pointer of solidworks using "cocreateinstance".
then i get the active document using "get_iactivedoc2".
now here is where the issue comes in case i loaded an assembly.
if it is a part then i am able to get the active document pointer instantly. but incase it was a large assembly that requires time loading all the parts that comprise it; then i get a null in the active document pointer.
on the other hand if i introduce some "delay" using sleep, it gives solidworks enough time to load the assembly; and then i can get the active document using get_iactivedoc2.
this is fixed only because i entered some delay. is there any cleaner or more efficient way to get the active document from solidworks only when it is fully loaded and not before? or is there any event by which i can know that the active document is fully loaded in solidworks? or that solidworks is ready for using the api on it to get information ?
hi,
i am not a vc++ programmer but you might want to look this up in api help:
fileopennotify2 - sldworks event
(specifically as it pertains to c++)
~t
no no no... do not use shellexecute that will create an out-of-thread worker. you want to do it through com. by calling cocreateinstance to get a handle to a sldworks object your code should be synchronous and wait for the solidworks to fully initialise before returning execution to your code. so after that line you can then call the sldworks variables opendoc function to open the required document, and then use activedoc to get the active document. doing it in-thread and through com eliminates any issues of returning before completion and the likes.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】displaying the details of hard drives huangyhg vc编程 2 2008-05-03 01:47 PM
【转帖】外挂开发中的封包技术 huangyhg vc编程 0 2007-12-03 04:41 PM
如何用用程序模拟键盘来控制 Media Player 7? huangyhg vc编程 9 2007-11-14 09:18 AM
【转帖】对于hook函数的一点认识 huangyhg vc编程 0 2007-03-27 11:53 AM


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


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