ich versuche gerade für meine Bachelorarbeit eine Schnittstelle zwischen Python und Solidworks zu programmieren. Ich habe bereits einen Wrapper (pySW) dafür gefunden, aber wird leider bei einer Stelle immer die folgende Fehlermeldung gezeigt: 'commSW' object has no attribute 'getGlobalVariables' obwohl die Funktion 'getGlobalVariables' in commSW existiert.
pySW: https://github.com/kalyanpi4/pySW
Code: Alles auswählen
import os
from pySW import SW
from pyDOE import *
import psutil, time, shutil
partName = '\Box.SLDPRT' # Name of the part
thisDir = os.getcwd() # Python method getcwd() returns current working directory of a process.
directory = thisDir + partName # Directory of the part
print(directory) #test to indicate the file location (thisDir)
os.startfile("C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe") # os.startfile() opens any program, text or office document
time.sleep(15) # The sleep() function suspends (waits) execution of the current thread for a given number of seconds."""
SW.connectToSW() # Function to establish a connection to Solidworks from Python
#SW.openPrt(directory) # Function to open an part document in Solidworks from Python.
globVars = SW.getGlobalVars() # Gives a dictionary of the global variables
variables = []; # An empty list for the lobal variable names
for key in globVars:
variables.append(key); # Adds the names imported from SW global viariables list
print(globVars)
print(variables)
newValues = [70, 120, 45]
unitList = ['mm']*len(variables)
print(unitList)
SW.modifyGlobalVar(variables, newValues, unitList)
Weiß jemand wie ich diesen Fehler beheben kann? Danke im Voraus.