几何尺寸与公差论坛

 找回密码
 注册
查看: 2933|回复: 3

there are three terrible questions on SW translator as below

[复制链接]
发表于 2007-9-4 12:50:15 | 显示全部楼层 |阅读模式
Summary :   there are three terrible questions on SW translator as below
Description :   Hi,
I’m working on SW translator (SW DCI) efficiency for Wilcox Company, your SW partner. By the way, I maybe also need a constant technical supporter for a long time. Now, there are three terrible questions on SW translator as below.

1. If SW is running in the foreground and is visible, are there other OLE functions or ways to catch and connect SW? (My current way is that of m_pSldWorks.CreateDispatch(_T("SldWorks.Application"));) Sometimes my customers need network to connect SW with a floating license.

2. What is the operation of Release ISldWorks in OLE automation?

It maybe has some problems when I close the SolidWorks session via the following code.

My code as follows:

// code 2 start

ISldWorks m_pSldWorks;

// connects to an already running instance of SW

//?????????????

// or will start SW if not already running

m_pSldWorks.CreateDispatch(_T("SldWorks.Application"));

//…………………

// close the SolidWorks session

m_pSldWorks.ExitApp ();

m_pSldWorks.DetachDispatch();

m_pSldWorks.ReleaseDispatch();

m_pSldWorks.m_lpDispatch = NULL;

// code 2 end

3. Are there other ways to rapidly get model doc from ISldWorks? According to the below steps, it takes a long time to get model doc via the following code. I guess the reason of that m_pSldWorks open filename in SW if SW is running in the foreground and is visible. But our requirement is that SW translator reads or gets majority model data or information of SW 3D part via OLE Automation and SW 3D part doesn’t need display in SW.

My code as follows:

// code 3 start

// Get the pModelDoc - Open the SolidWorks file

dModelDoc = m_pSldWorks.OpenDoc6 (fileName, fileType, fileOptions, fileConfigs, &errors, &warnings);

dModelDoc = m_pSldWorks.ActivateDoc2 (fileName, silent, &errors);

// get the active model doc

LPDISPATCH dModelDoc = m_pSldWorks.GetActiveDoc();

// code 3 end


> Yanhua
 楼主| 发表于 2007-9-4 12:51:09 | 显示全部楼层

回复: there are three terrible questions on SW translator as below

Hello Yanhua,

To answer your questions:

1 - You should be able to use ::GetActiveObject to obtain the currently running SW session.  Once you have the IUnknown pointer, you can use the AttachDispatch to attach it to your ISldWorks object.

2 - I believe that I have responded to this item separately today.

3 - If you look at the three calls: OpenDoc6, ActivateDoc2 and GetActiveDoc all three of them are returning a document object.  Thus, you only need one of them.  It is true that the macro recorder records all three, but you do not need to make these calls when working with your code.


Regards,
Earl Hasz
 楼主| 发表于 2007-9-4 13:37:32 | 显示全部楼层

回复: there are three terrible questions on SW translator as below

Hi,

Thanks.But this is not useful for the first question.

My programming language is Visual C++7.0, and I use OLE Automation of SolidWorks 2006, not COM.

My question is that how to connect to an already running instance of SW in my following scene.

Scene:

VC7.0 & OLE Automation &SolidWorks 2006 & swdisp.h

yanhua
 楼主| 发表于 2007-9-4 13:38:09 | 显示全部楼层

回复: there are three terrible questions on SW translator as below

Hello Yanhua,
Based on my last response, you should be able to do the following:
IDispatch *pDisp;
CoGetObject(L”SldWorks.Application”, NULL, __uuidof(IDispatch), (void**)&pDisp);
ISldWorks swApp(pDisp);
Regards,

-Earl
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 00:12 , Processed in 0.039171 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表