I am trying to automate Maxsurf using Python. My code in Python is as follows-
import win32com.client as win32
msApp = win32.Dispatch("BentleyModeler.Application")
FileName = "MonoHull.msd"
While executing, I get the following error. What is the remedy here? And why do I get the list of objects (as en excel vba) in python?
C:\Users\USER\PycharmProjects\VBA\venv\Scripts\python.exe C:/Users/USER/PycharmProjects/VBA/main.py File "C:\Users\USER\PycharmProjects\VBA\main.py", line 4 msApp.Design.Open FileName,False,False ^^^^^^^^SyntaxError: invalid syntax
I don't support python unfortunately. Only VBA. So any advice I can give you, you'll need to translate to python.
I suspect that your filename here needs to include the filepath ("C:\ . . . " etc.). It would in VBA.
The best trick for something like this is to prove that you have connection to MAXSURF. Getting the version number doesn't need a design open or anything like that. So its a really good test to check that we can talk to MAXSURF.
Use a line like:
a = msApp.version
Yes, I get response from Maxsirf with this line of code.
Okay - thats a good sign that you have python talking to MAXSURF.
Now you need to investigate getting that filename right. I think you need the full file path ("C:\" etc). You can even try putting it into a simpler filepath to see if you're having a syntax issue with spaces or special characters.
probably the FileName is incorrect -- its best to give the full path