-
Re: Problem opening an asm driven by a design table
Peter Brinkhuis Sep 30, 2015 10:50 AM (in response to Simon Dubois)What lines cause the design table to be opened and closed? I use the following code to test for the existence of a design table, it opens and closes it immediately.
Set swDesTable = swModel.GetDesignTable
bRet = swDesTable.Attach
If bRet Then
swDesTable.Detach
end if
According to https://support.microsoft.com/en-en/kb/118468 the command "doevent" causes the program to continue instead of wait. I think it will run more smoothly if those lines are removed, although it may take longer.
-
Re: Problem opening an asm driven by a design table
Simon Dubois Oct 1, 2015 1:50 AM (in response to Peter Brinkhuis)Thanks Peter,
Peter Brinkhuis:
What lines cause the design table to be opened and closed?
No one. It's solidworks which, at the opening of the file, opens the various design table and closes it to check if there is update to do on the part.
Actually, this action don't mind me. I want Solidworks updating part at their opening. But I was wondering if it has a way to do it hidden.
Maybe what I can try is : Disable the automatic opening of the design table at the opening of the part or asm. Open the 3 elements, and when they are opened, updating them (open/close their design table) one by one.
But I don't really know what is the VBA code for this.
Peter Brinkhuis:
According to https://support.microsoft.com/en-en/kb/118468 the command "doevent" causes the program to continue instead of wait. I think it will run more smoothly if those lines are removed, although it may take longer.
Oh. I knew I hadn't totally understund how this command was running. I just tried it before posting here. It don't matter if I write it or not, crashes are still there.:x
-
Re: Problem opening an asm driven by a design table
Peter Brinkhuis Oct 1, 2015 4:21 AM (in response to Simon Dubois)I thought maybe the OpenDoc6 command was outdated, but it's the most recent version. Some more info here. There is no mention at all about design tables, but the following lines may help:
You may want to set the current working directory before calling ISldWorks::OpenDoc6. This can be done using the ISldWorks::SetCurrentWorkingDirectory method.
-
Re: Problem opening an asm driven by a design table
Simon Dubois Oct 5, 2015 7:44 AM (in response to Peter Brinkhuis)Thank you Peter,
But unfortunatey, it didn't solve the problem. The crash occurs exactly when solidworks try to open the first design table.
Sub lancer_solidworks()
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2Set swApp = New SldWorks.SldWorks
swApp.Visible = True
swApp.SetCurrentWorkingDirectory ("My path")Part = swApp.OpenDoc6("My Path\My file.SLDDRW", 3, 0, 0, 0, 0)
End Sub
-
-
-
-
Re: Problem opening an asm driven by a design table
Simon Dubois Oct 7, 2015 9:56 AM (in response to Simon Dubois)Ok, after a few test I know exactly what happens :
If a macro is running (in excel) while solidworks checks the design table : excel crashes. Even if it's just a Sleep.
The problem is : My macro open solidworks, open a drawing (drawing of the asm and the parts), and interact with it.
I know I can open soldiworks and the drawing thanks to a macro, then interact with it thanks to another, but I would like both being done in just one.
EDIT : It's a bit more complicated actually... or maybe not :
The excel file is my interface for setting the three design table. It has vaious sub.
When I just open the excel file and open solidworks (thanks to a macro), excel doesn't crash.
When I open the excel file, I run some more sub (without running sub which edit the design table), and I open solidworks (always with the same macro) excel crashes.
I don't know much about memory process, but it seems that the problem is link to this.
Does anyone know about it ?
Thank you,
EDIT 2 : Ok, with excel in safe mode, and my interface already filled (so, I havn't run any macro before running the one which open solidworks and intreact with the drawing), it hadn't crash.
So there is no problem in my code, which is a very good news !
But it really seems to be a memory problem (all my pointers already are set to nothing, I don't know what I can do more )