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

model 3d space in winforms
hello all,
i was developing windows application in usnig c#.net winforms.
i could start the solidworks from windows application, at the same time is it possible to add the 3d space [model space] of solidworks to windows application.
so that whe whole application looks totally intergated with solidworks.
thanks
ravi belkhindi
ravi belkhindi
clydeunion
automation engineer
get the process id of the model window you want to capture then call the setparent invoke method.
[dllimport("user32.dll", setlasterror=true)]
static extern intptr setparent(intptr child, intptr newparent);
intptr win = system.diagnostics.process.getprocessbyid(pidhere).mainwindowhandle;
setparent(win, yourform.handle);
where pidhere is the pid of the model space, and yourform is a form or panel or wherever you want to capture the handle too.
then to release it back:
setparent(win, new intptr(0));
thank you luke,
i experimented on the idea you have given. it worked fine
to add solidworks main frame in winform i used the below code
swapp = new sldworksclass();
swapp.visible = true;
modeldoc2 doc;
doc =(modeldoc2)swapp.opendoc("c:\\fan.sldprt", (int)swdocumenttypes_e.swdocpart);
frame myframe = (frame)swapp.frame();
int winhandle = myframe.gethwnd();
setparent((intptr)winhandle, this.handle);
similarly i tried including only the model window in winform. for this i have written the following code.
swapp = new sldworksclass();
swapp.visible = true;
modeldoc2 doc;
doc =(modeldoc2)swapp.opendoc("c:\\fan.sldprt", (int)swdocumenttypes_e.swdocpart);
frame myframe = (frame)swapp.frame();
object modwindows = myframe.modelwindows; //get array of all open documents
modelwindow modelwin = (modelwindow)((object[])(modwindows))[0]; // get first model window
intptr err = setparent((intptr)winhandle1, this.handle);
when i run the program it gives err=o and the solidworks got hanged and prompted for restart. i have attached the snap of the error.
in first case i am attaching main frame to my winform - this worked fine
in second case
model window which is the child window of main frame [solidworks] and am trying to attach the child to my winform - is that the right approach.
thanks in advance
ravi b
ravi belkhindi
clydeunion
automation engineer
edited: 03/26/2009 at 04:23 am by ravi belkhindi
click for full image
in that case it is not possible. you are taking the model away from its parent, and so the parent and model can no longer communicate in their message pumps or access modifiers. you would have to capture the entire window, or clone the handle instead, deferring all messages to the real handle pump when the user interacts with it. not exactly a 2 minute code example i am afraid.
thanks,
well, why the solidworks object model gives the option to get the handle of each models.
how can this be utilized in the programs.
greatefull of you could throw some light on this.
thanks
ravi
ravi belkhindi
clydeunion
automation engineer
answer there is a lot more you can do with handles, callbacks, message pumps, bitblts, referencing, setting styles, custom message handling... its endless. but moving its parent means communication is lost, its like taking a fish out of a pond, it dies without its required surroundings to call upon.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
Intra3D下载地址 huangyhg 图形算法 17 2010-04-16 05:32 AM
【求助】【转帖】"> 重复2d和3d距离的测量话题 huangyhg PC-DMIS 0 2009-04-08 12:57 AM
Vc下编程实现3d文字 huangyhg vc编程 0 2009-01-21 12:29 AM
3d图形名词术语大放送 huangyhg 图形算法 1 2007-10-15 06:30 PM


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


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