[python-win32] Strange issues when using pywin32 to develop solidworks

Tim Roberts timr at probo.com
Wed Oct 7 02:44:19 EDT 2020


On Oct 5, 2020, at 5:45 PM, nicolas jacky <skrapp at hotmail.com> 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, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20201006/f281e372/attachment.html>


More information about the python-win32 mailing list