![]() |
【转帖】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! |
所有的时间均为北京时间。 现在的时间是 07:53 AM. |