几何尺寸与公差论坛

 找回密码
 注册
查看: 678|回复: 0

【转帖】open doc

[复制链接]
发表于 2009-4-12 21:56:24 | 显示全部楼层 |阅读模式
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!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 14:45 , Processed in 0.039298 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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