From moritz.muehlbauer at fsd.tu-berlin.de Tue Sep 10 07:25:28 2019 From: moritz.muehlbauer at fsd.tu-berlin.de (=?iso-8859-1?Q?M=FChlbauer=2C_Paul_Moritz?=) Date: Tue, 10 Sep 2019 11:25:28 +0000 Subject: [python-win32] Solidworks win32com AttributeError Message-ID: <7e6be255d6004e11b9507372de420bbb@EX-MBX-03.tubit.win.tu-berlin.de> Dear Juha-Pekka, import sldworks, swcommands, swconst, cosworks sw = sldworks.SldWorks() # open new part Teil = sw.NewDocument(r'C:\ProgramData\SolidWorks\SOLIDWORKS 2018\templates\Teil.prtdot',\ 6,1,1) # start managers model = sw.ActiveDoc modelExt = model.Extension selMgr = model.SelectionManager featureMgr = model.FeatureManager sketchMgr = model.SketchManager title=model.GetTitle print(title) works for me. >Hello, > >I'm sending question to this list regarding Solidworks and win32com >AttributeError. >I have created a modules from Solidworks tlb-files and am trying to get >basic functions to work. >One such is a GetTitle from IModelDoc2. >On the generated module, it's defined as: >def GetTitle(self): > 'Get design table title' > # Result is a Unicode object > return self._oleobj_.InvokeTypes(8, LCID, 1, (8, 0), (),) >Traceback (most recent call last): >sw = 0x1736352623976> > File "C:/Users/Juha-Pekka >Ahto/Desktop/CustomPropertyManager/CustomPropertyManager.py", line 24, in > > uniString = swModel.GetTitle() >swModel = at 0x1736369300424> > File >"C:\Users\JUHA-P~1\AppData\Local\Temp\gen_py\3.7\83A33D31-27C5-11CE-BFD4-00400513BB57x0x24x0.py", >line 34657, in GetTitle > return self._oleobj_.InvokeTypes(65607, LCID, 1, (8, 0), (),) > File "C:\Python37\lib\site-packages\win32com\client\dynamic.py", line >527, in __getattr__ > raise AttributeError("%s.%s" % (self._username_, attr)) >AttributeError: SldWorks.Application.24.InvokeTypes -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Sun Sep 15 01:52:05 2019 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 15 Sep 2019 15:52:05 +1000 Subject: [python-win32] [ANN] pywin32 build 225 released Message-ID: Hi all, I'm happy to announce the release of pywin32 build 225. Downloads are available at: https://github.com/mhammond/pywin32/releases/tag/b225 and via pypi. For initial support (eg, to ask questions about the release etc), please contact this mailing-list (python-win32 at python.org). If you want to report a bug, please do so at https://github.com/mhammond/pywin32/issues As always, thanks to everyone who contributed to this release, both in terms of code and reporting bugs. Cheers, Mark. Changes: * Huge shout-out to @thopiekar for helping with github triage, getting CI working and sane, and other general help and patches! * Significant work by @joankaradimov in porting pywin32 so that it works in a MingGW/msys2 environment. * ntsecuritycon.FILE_ALL_ACCESS had an incorrect value (#1354) * SetSecurityDescriptorGroup now accepts None as group value (#1382) * Fix an issue where win32gui.EnumChildWindows may throw a spurious exception. (#1350) * Better support for numpy objects in COM methods (#1388, @panikc and @SReicheltPTV) * PythonWin is now able to start with non-English active keyboard layout. * Corrected wMilliseconds truncation in PyTime::getattro (Dorian Bivolaru) * Implement PdhGetFormattedCounterArray (#1306, konserw) From mgrady at enthought.com Tue Sep 17 17:56:29 2019 From: mgrady at enthought.com (Maxwell Grady) Date: Tue, 17 Sep 2019 16:56:29 -0500 Subject: [python-win32] Set service to auto restart Message-ID: I have a python windows service defined as a subclass of win32serviceutil.ServiceFramework. I can install the service via the command line via `python -m myservice --interactive --startup auto install` Doing so, I can set some of the service configuration such as to run in interactive mode and to automatically start the service on system start. Is it also possible to pass in configuration for how the service should handle failure? specifically I want to set the service to always restart on failure. If not via the command line, is there a programmatic way to do this? I know it can be set manually by opening services.msc and adjusting the service configuration but was hoping it was also exposed via pywin32. Thanks for any tips _______________ Maxwell Grady, PhD Scientific Software Developer | Enthought T +1 512 536 1058 x155 M +1 314 814 5471 m grady at enthought.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.merl at nxp.com Thu Sep 19 07:11:53 2019 From: andreas.merl at nxp.com (Andreas Merl) Date: Thu, 19 Sep 2019 11:11:53 +0000 Subject: [python-win32] Calling Methods of an object returned by an COMObject method Message-ID: Hello, I am trying to automate CST Studio. First part is straight forward: Call cst = win32com.client.gencache.EnsureDispatch("CSTSTudio.Application") and get the CST Studio next step open a new microwave studio project mws = cst.NewMWS() now there comes the problem: mws has couple of methods. As example "Quit()" When I try to call this method nothing happens mws.Quit() It should quit the project. What happens: Nothing But when I try to get a property Example: mws.Pi Result: 3.141592653589793 For me it looks as the methods of mws are never called. What am I missing? Thanks for your Help Best regards Andreas Merl -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.merl at nxp.com Thu Sep 19 13:51:13 2019 From: andreas.merl at nxp.com (Andreas Merl) Date: Thu, 19 Sep 2019 17:51:13 +0000 Subject: [python-win32] Calling Methods of an object returned by an COMObject method Message-ID: Hello, I am trying to automate CST Studio. First part is straight forward: Call cst = win32com.client.gencache.EnsureDispatch("CSTSTudio.Application") and get the CST Studio next step open a new microwave studio project mws = cst.NewMWS() now there comes the problem: mws has couple of methods. As example ?Quit()? When I try to call this method nothing happens mws.Quit() It should quit the project. What happens: Nothing But when I try to get a property Example: mws.Pi Result: 3.141592653589793 For me it looks as the methods of mws are never called. What am I missing? Thanks for your Help Best regards Andreas Merl -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Sep 20 02:29:41 2019 From: timr at probo.com (Tim Roberts) Date: Thu, 19 Sep 2019 23:29:41 -0700 Subject: [python-win32] Calling Methods of an object returned by an COMObject method In-Reply-To: References: Message-ID: On Sep 19, 2019, at 10:51 AM, Andreas Merl wrote: > > I am trying to automate CST Studio. > ... > As example ?Quit()? > When I try to call this method nothing happens > mws.Quit() > It should quit the project. > What happens: > Nothing > > For me it looks as the methods of mws are never called. Have you tried the other methods, or are you basing that conclusion on exactly 1 sample? How can you tell it didn?t quite the project? Does the app open a new instance when you call EnsureDispatch? Excel, for example, is perfectly happy to run in the background as a COM server, so there?s no visible change when you quiet. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hauptmech at gmail.com Sat Sep 21 05:11:16 2019 From: hauptmech at gmail.com (hauptmech) Date: Sat, 21 Sep 2019 21:11:16 +1200 Subject: [python-win32] Cast CDispatch to DispatchBaseClass? Message-ID: I have a makepy generated class that returns an untyped object which needs to be cast into one of a couple other makepy generated classes. My code starts with: import win32com.client as client mod = client.gencache.EnsureModule('{83A33D31-27C5-11CE-BFD4-00400513BB57}',0,SWAV,0) swApp = client.GetActiveObject("SldWorks.Application") model = swApp.ActiveDoc #Meant to be cast by the user to one of two interfaces. Returns a win32com.client.CDispatch CastTo (and the constructor for the generated class I need to cast to) fail to set _oleobj_ correctly. After poking around I got things to work with: swModel = mod.IModelDoc2(model) swModel.__dict__["_oleobj_"] = model._oleobj_.QueryInterface(mod.IModelDoc2.CLSID, pythoncom.IID_IDispatch) This feels like I'm doing something wrong. Is there a better way to do this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From libbkmz.dev at gmail.com Mon Sep 23 14:50:11 2019 From: libbkmz.dev at gmail.com (Ilya Plenne) Date: Mon, 23 Sep 2019 21:50:11 +0300 Subject: [python-win32] How to convert VisualStudio DTE to DTE2 Message-ID: Hi. I'm new to the pywin32 and COM interfaces. I have a simple task. I want to attach my VisualStudio to current Python process with specific debug engine, to eliminate Python debugging and use only Native C++ code debugging. Using pywin32 I get DTE object by this: import win32com.client dte = win32com.client.GetActiveObject("VisualStudio.DTE.15.0") Then I look through existing processes and find PID of the current Python process. I want to make something like this: for proc in dte.Debugger.LocalProcesses: if proc.ProcessID == os.getpid(): proc.Attach2("native") break But Attach2 exists only on Process2: https://docs.microsoft.com/en-us/dotnet/api/envdte80.process2.attach2?view=visualstudiosdk-2017 How can I convert/cast Process object to Process2 object? Or in general, how can I convert DTE object to DTE2 object? https://docs.microsoft.com/en-us/dotnet/api/envdte80.dte2?view=visualstudiosdk-2017 Because, when I do win32.CastTo(dte.Debugger, "Debugger2") or win32.CastTo(dte, "DTE2") every time I'm getting this error: ValueError: The interface name 'Debugger2' does not appear in the same library as object '' -------------- next part -------------- An HTML attachment was scrubbed... URL: