![]() |
【转帖】solidworks wont run invisible
solidworks won't run invisible
i am using the following code in vb 2008 to output flat sheetmetal parts as dxf files. i would like to do it without solidworks being visible. am i missing something? private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click dim swapp as sldworks.sldworks dim swmodel as sldworks.modeldoc dim stpath as string dim part as sldworks.modeldoc2 dim longwarnings as long dim boolstatus as boolean stpath = "c:\test\" swapp = createobject("sldworks.application") swapp.usercontrol = false swmodel = swapp.opendoc6(stpath & "mbc-3.sldasm", 2, 0, "default", 0, longwarnings) swmodel.forcerebuild3(true) part = swapp.opendoc6(stpath & "mbc-3-rearwall.sldprt", 1, 0, "default", 0, longwarnings) part.extension.selectbyid2("flat-pattern1", "bodyfeature", 0, 0, 0, false, 0, nothing, 0) boolstatus = part.exportflatpatternview(stpath & "dxf & pdf\" & stsize & " - mbc-3-rearwall.dxf", 0) swapp.quitdoc("mbc-3-rearwall.sldprt") swapp.quitdoc("mbc-3.sldasm") swapp.quitdoc("mbc-3-layoutsketches.sldprt") swapp.closealldocuments(false) swapp.exitapp() part = nothing swmodel = nothing swapp = nothing end sub danny brown rcs swapp.visible = false i tried swapp.visible = false. it is still visible, i also tried swapp.usercontrol = false. none of these switches seem to work. danny brown rcs i have found if i have a document open in sw's that isn't saved and it will not go to the background, or in some cases if there is anything open in sws it will not run in the background. in both cases you need the usercontrol = false visable = false to make it work correctly... this is what i have right after setting swapp.it doesn't work. i am opening an assembly and then a part. i even tried to just open the assembly and closing it without doing anything else and it still shows visible. this is frustrating and i would appreciate any help i can get. swapp = createobject("sldworks.application") swapp.usercontrol = false swapp.documentvisible(false, 1) swapp.documentvisible(false, 2) swapp.visible = false danny brown rcs danny, just a guess: could it be that you have several sw sessions running? jorn bjarning cswp cad & plm consultant sw2008 sp5 / sw2009 sp2 i thought that too, but i tried it only opening the assembly doing nothing and closing it. it still runs visible. i have a sketch layout that drives the assembly and i noticed since i change to a linked excel file that the sketch layout opens when i open the assembly. is that normal? could that be the problem? danny brown rcs danny, it does sound a little weird but without having seen it i am not able to say if it could be part of the explanation. is the sketch layout in a seperate part file or how is it organized? jorn bjarning cswp cad & plm consultant sw2008 sp5 / sw2009 sp2 the sketch layout.sldprt is the main component in the assembly and it also contains the linked design table. there are about 20 parts driven by the sketch layout (the flat parts being generated). i believe they call it a top down design. danny brown rcs i am having the same problem as danny i am not able to open the parts invisble. would somebody have an example that they would be will to share that would maybe just open a part and do something simple to it save it and close it, to compare code and hopefully see what is missing ? thanks. solidworks 2006,2007,2008,2009 (office premium.) core 2 duo e6850 @ 3.00 mhz window xp pro sp3 32 bit ati firegl v7350 danny and ben, i assume you have already studied the example for sldworks::visible? jorn bjarning cswp cad & plm consultant sw2008 sp5 / sw2009 sp2 |
所有的时间均为北京时间。 现在的时间是 01:46 PM. |