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

open doc
hi!
how are u?
it´s the first message that i write in this forum so, nice to meet everybody.
sorry about my bad english but i´m learning.
my problem is that i want to open a document of the solidworks but i can´t.
i tried with:
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim longstatus as long, longwarnings as long
set swapp = createobject("sldworks.application")
set swmodel = swapp.opendoc6("c:\1.sldasm", 2, 0, "", longstatus, longwarnings) '1.sldasm is the doc that i want to open
swapp.opendoc6 "c:\1.sldasm" & a & b, 2, 0, "", longstatus, longwarnings
set swmodel = swapp.activatedoc2("1.sldasm", false, longstatus)
and with:
dim swapp as sldworks.sldworks
dim fileerror as long
dim filewarning as long
set swapp = createobject("sldworks.application")
swapp.visible = true
swapp.opendoc6 1.sldasm, swdocpart, swopendocoptions_silent, "", fileerror, filewarning
but it doesn´t work. anybody can help me?? thank you!
p.d. the doc that i want to open can be a part or an assembly.
try this code. copied from example from sw api help. you can modify the codes for opening part or assembly.
*********************
option explicit
dim swapp as sldworks.sldworks
dim fileerror as long
dim filewarning as long
sub main()
set swapp = application.sldworks
swapp.visible = true
swapp.opendoc6 "c:\1.sldprt", swdocpart, swopendocoptions_silent, "", fileerror, filewarning
end sub
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
thanks!
i have tried your code but it doesn´t works. it says that i have to defind swdocpart and swopendocoptions_silent. swdocpart is a long but what about the swopendocoptions_silent? what type is it?
i tried with this code but nothing!
option explicit
sub botón1_alhacerclic()
dim swapp as sldworks.sldworks
dim fileerror as long
dim filewarning as long
dim swdocassembly as long, swopendocoptions_silent as long
set swapp = createobject("sldworks.application")
swapp.visible = true
swapp.opendoc6 "c:\documents and settings\pfc5\escritorio\h.sldasm", swdocassembly, swopendocoptions_silent, "", fileerror, filewarning
' i have put swdocassembly cause my doc is an assembly
end sub
try this one. copied and modified sw api help example.
********
dim swselmgr as sldworks.selectionmgr
dim swdocspecification as sldworks.documentspecification
dim scomponents(0) as string ' list of components to select
dim components as variant
dim swcomponent as sldworks.component2
dim sname as string
dim longstatus as long, longwarnings as long
sub main()
set swapp = application.sldworks
set swdocspecification = swapp.getopendocspec("c:\program files\solidworks (2)\solidworks\samples\tutorial\advdrawings\bowl and chute.sldasm") 'change you file path here
scomponents(0) = "food bowl-1@bowl and chute" 'change component name here
components = scomponents
swdocspecification.componentlist = components
swdocspecification.selective = true
sname = swdocspecification.filename
swdocspecification.documenttype = swdocassembly
swdocspecification.displaystate = "default_display state-1"
swdocspecification.uselightweightdefault = false ' ignore the system default and use swdocspecification::lightweight value
swdocspecification.lightweight = true
swdocspecification.silent = true
swdocspecification.ignorehiddencomponents = true
set swmodel = swapp.opendoc7(swdocspecification)
longstatus = swdocspecification.error
longwarnings = swdocspecification.warning
end sub
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
marian,
i checked the other code (that i have posted for opening part file) and they are working fine in my machine. i have tested that in sw2008. which version of solidworks you are running.
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
originally posted by: marian ruiz
thanks!
i have tried your code but it doesn´t works. it says that i have to defind swdocpart and swopendocoptions_silent. swdocpart is a long but what about the swopendocoptions_silent? what type is it?
i tried with this code but nothing!
option explicit
sub botón1_alhacerclic()
dim swapp as sldworks.sldworks
dim fileerror as long
dim filewarning as long
dim swdocassembly as long, swopendocoptions_silent as long
set swapp = createobject("sldworks.application")
swapp.visible = true
swapp.opendoc6 "c:\documents and settings\pfc5\escritorio\h.sldasm", swdocassembly, swopendocoptions_silent, "", fileerror, filewarning
' i have put swdocassembly cause my doc is an assembly
end sub
change you codes to this:
option explicit
sub botón1_alhacerclic()
dim swapp as sldworks.sldworks
dim fileerror as long
dim filewarning as long
set swapp = application.sldworks
swapp.visible = true
swapp.opendoc6 "c:\documents and settings\pfc5\escritorio\h.sldasm", swdocassembly, swopendocoptions_silent, "", fileerror, filewarning
end sub
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
the sw08 also
i have tried the last code and it said that i have to defind swdocassembly and swopendocoptions_silent.
edited: 02/04/2009 at 05:50 am by marian ruiz
do a search for opendoc6 in the api help and copy the codes from there and check.
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
you must set reference to solidworks 200x constant type library
tools -> references .....
edited: 02/04/2009 at 06:23 am by ivana kolin
i had done it and i have the same problem so i have wrote in this forum if anybody knows the answer to my problem!
but thank you anyway!
where are you writing your code? in a solidworks macro? excel macro?
i'll get you eh steve, if it's the last thing i dooooo!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【发布】IGES参数格式.doc version 1.0 huangyhg CAD文件存储格式 7 2009-04-14 03:28 PM
【转帖】doc manager api requires presence of solidworks explorer yang686526 SolidWorks二次开发 0 2009-04-12 08:41 PM
【转帖】doc manager api requires presence of solidworks explorer yang686526 SolidWorks二次开发 0 2009-04-12 06:00 PM
【发布】商业计划书.doc huangyhg 总体规划 2 2007-02-02 04:20 PM


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


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