Hello
Being unfortunately very disappointed with the stability/reliability of the MyCADtools tools in a PDM environment on large assemblies with + a lot of external references,
I'm currently developing a Python application supported by a lot of VBA macros that uses the solidworks API.
So I'm coming to you today to get the programmers' feelings on the stability and reliability of these tools.
By this I mean: Does it tend to crash/freeze SW? Does this often cause standalone apps to crash?
When you start a treatment on a large package of parts, is there a chance that some of them will not be taken into account?
Indeed, I don't know how MyCAD tools are programmed, but it is clear that they rarely complete their task, and that when they have reached the end without crashing, some of the parts are often lost.
So I started to code a simple marco excel that opens the files one by one whose PATH is in a column.
I notice that I get random behavior there too.
Do you think this is due to a programming problem with my own code, or the SW API is natively unreliable at all??
I'm new to VB and API sw but I already program in many different languages...
Thank you for your answer
The code below:
Sub Ouvrir_un_par_un()
'Déclaration des variables :
Dim nb_de_ligne As Integer 'nombre de lignes du document
Dim increment As Integer 'incrément de 1 pour effectuer la boucle de recherche ligne par ligne
Dim myCell As String 'variable pointant sur la cellule en cours
Dim path_complete As String 'chemin complet de la pièce
Dim myBool As Boolean
Dim swApp As ISldWorks
Dim swModel As ModelDoc2
Dim nDocType As Integer
Dim myErrors As Long
Dim myWarnings As Long
'Initialisation de certaines variables:
nb_de_ligne = Range("A1").End(xlDown).Row - 1
If MsgBox("Vous vous apprêtez à ouvrir : " & nb_de_ligne & " fichiers à la chaine !" & Chr(13) & "Commencer ?", vbYesNo, "Demande de confirmation") = vbYes Then
'Déduction du type de fichier avec l'exension:
If swApp Is Nothing Then
Set swApp = CreateObject("SLDWORKS.application")
swApp.Visible = True
MsgBox ("Solidworks n'était pas ouvert, on vient de le lancer, appuyer sur OK quand il à l'air d'être prêt")
Else
Set swApp = Application.SldWorks
End If
'Boucle sur toutes les pièces:
For increment = 1 To nb_de_ligne
Set swModel = Nothing
nDocType = 0
myCell = "A" & (increment + 1)
path_complete = Range(myCell).value
If MsgBox("Voullez vous vérifier le fichier : " & Chr(13) & path_complete, vbYesNo, "Ouvrir ce fichier dans SW ?") = vbYes Then
' Determine type of SOLIDWORKS file based on file extension
If InStr(LCase(path_complete), "sldprt") > 0 Then
nDocType = swDocPART
ElseIf InStr(LCase(path_complete), "sldasm") > 0 Then
nDocType = swDocASSEMBLY
ElseIf InStr(LCase(path_complete), "slddrw") > 0 Then
nDocType = swDocDRAWING
Else
' Probably not a SOLIDWORKS file
nDocType = swDocNONE
' So cannot open the file
Exit Sub
End If
Set swModel = swApp.OpenDoc6(path_complete, nDocType, 1, "", myErrors, myWarnings)
' Comment utiliser OpenDoc7 ??
'swModel.ViewZoomtofit2 ' Bug souvent, pourquoi ?
End If
Next increment
End If
'Set swApp = Nothing
End Sub