On Oct 5, 2020, at 5:45 PM, nicolas jacky <[email protected]> wrote:
>
> I test below code snippets in vscode with enviroment of python 3.8, pywin32
> build 228, solidworks 2017 API sets and created .py files by makepy, I get
> some strange errors.
> first snippet
>
> # -*- coding: utf-8 -*-
> from win32com.client import *
> from pythoncom import *
> swx = Dispatch("SldWorks.Application")
> swModel = swx.ActiveDoc
> mathUilty = swx.GetMathUtility
GetMathUtility is a method, not a property. You need to call it as a function:
mathUtility = swx.GetMathUtility()
ActiveDoc is a property, and so should not need parens.
> Running this code and vscode says:
>
> line 15, in <module>
> swModel.AddComponents3(vtName,vtTrans,vtCoordName)
> TypeError: 'NoneType' object is not callable
> If I code it like this 'swModel.AddComponents3' then it's ok.
>
What is the difference?
—
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32