From 2022huaweisudani at gmail.com Wed Feb 2 02:00:31 2022 From: 2022huaweisudani at gmail.com (HUAWEI HUAWEI) Date: Wed, 2 Feb 2022 09:00:31 +0200 Subject: [python-win32] Help me using python setup.py bdist In-Reply-To: References: Message-ID: > I'm Mohammed from Sudan, > Diploma in Computer science. > > Sudanese love using : > 1- windows ( 32bit & 64bit ) > 2 - Linux ( Deb, rpm ) > 3- android ( apk ) > 4- iPhone (ios ) > > I design simple python application to enter two numbers and calculate it > > > Help me using python setup.py bdist to export it into one file like : > > python setup . py ( bdist_rpm, bdist_win32bit, bdist_win64, bdist_deb, > bdist_apk, bdist_ios) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sm5126 at columbia.edu Wed Feb 9 19:36:32 2022 From: sm5126 at columbia.edu (Sanaa Mouzahir) Date: Wed, 9 Feb 2022 19:36:32 -0500 Subject: [python-win32] Run solidworks macro from python. Message-ID: Hello. I have started a project in which I have to link both solidworks and python. I want to use Pywin32 to run a macro from python. here is my code: app=win32com.client.Dispatch("SldWorks.Application") app.OpenDoc("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT", 1) app.Run("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT!ForceRebuild.swp") I basically want to use the same run function as for excel. But it does not work. Is there a way to run a macro from python using Pywin32? Thank you so much already. Cheers, Sanaa -- *Sanaa Mouzahir* *Columbia University in the city of New York* *M.S Computational and data-driven engineering mechanics* *+19173614172* www.linkedin.com/in/sanaamouzahir -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Feb 10 12:25:46 2022 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Feb 2022 09:25:46 -0800 Subject: [python-win32] Run solidworks macro from python. In-Reply-To: References: Message-ID: Sanaa Mouzahir wrote: > Hello. I have started a project in which I have to link both > solidworks and python. I want to use Pywin32 to run a macro from > python. here is my code: > > app=win32com.client.Dispatch("SldWorks.Application") > app.OpenDoc("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT", 1) > app.Run("C:/Users/sm5126/Downloads/Python/Python/Part1.SLDPRT!ForceRebuild.swp") > > I basically want to use the same run function as for excel. But it > does not work. Is there a way to run a macro from python using Pywin32? What do you mean by "it does not work"?? Do you get an error? Does it crash? Have you read the documentation for the SolidWorks API?? As I read the documentation, the API for running a script is called RunScript, not Run. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From moritz_muehlbauer at web.de Thu Feb 10 04:50:59 2022 From: moritz_muehlbauer at web.de (=?UTF-8?Q?Moritz_M=c3=bchlbauer?=) Date: Thu, 10 Feb 2022 10:50:59 +0100 Subject: [python-win32] Run solidworks macro from python. Message-ID: <3ac68d8e-fa6d-a165-bfa9-b9081f8e3128@web.de> Hello Sanaa, I used makepy.py to generate swcommands.py, swbindings.py, swconst.py and cosworks.py and placed them in the same directory as the python file I ran (at least I think it worked that way). Then, import swbindings, swcommands, swconst, cosworks import win32com.client import pythoncom sw=swbindings.SldWorks() arg1 = win32com.client.VARIANT(pythoncom.VT_DISPATCH, None) mdsl=sw.NewDocument(r'C:\ProgramData\SolidWorks\SOLIDWORKS 2018\templates\MBD\part 0251mm to 1000mm.prtdot',6,1,1) model = sw.ActiveDoc modelExt = model.Extension selMgr = model.SelectionManager featureMgr = model.FeatureManager sketchMgr = model.SketchManager sketchMgr.InsertSketch(True) etc. worked fine. It should work similarly with your code. Inspecting swbindings.py, I found a RunMacro function, which might be what you need. Are there any error messages? An other way would be to run the macro from excel using xlwings, if it is a excel macro. Best regards Moritz -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Feb 10 21:41:49 2022 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Feb 2022 18:41:49 -0800 Subject: [python-win32] Run solidworks macro from python. In-Reply-To: <969FDA5B-C55A-4E8C-B959-3B98849D0C3C@columbia.edu> References: <969FDA5B-C55A-4E8C-B959-3B98849D0C3C@columbia.edu> Message-ID: On Feb 10, 2022, at 9:39 AM, Sanaa Mouzahir wrote: > > Or maybe After importing the packages I can just use the same command as the VBA? I know that for excel the function Application.run(macroname) works, but not for solidworks.. Right, because every application defines their own object model. There?s no ?general rule? that applies to all COM servers. You HAVE to go through the documentation for THAT product, or at least look at some examples. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Feb 15 12:31:26 2022 From: timr at probo.com (Tim Roberts) Date: Tue, 15 Feb 2022 09:31:26 -0800 Subject: [python-win32] Run solidworks macro from python. In-Reply-To: References: <969FDA5B-C55A-4E8C-B959-3B98849D0C3C@columbia.edu> Message-ID: Sanaa Mouzahir wrote: > > Apologies for the late reply, I had to go through a lot of > documentation regarding SolidWorks itself. Unfortunately, the > available documentation that I find is regarding creating a SW COM > object, however, nothing about running a macro already written in > SolidWorks VB. More specifically, when I look up 'swbindings.py' I do > not get any output, and if I try to import it, I get the error message > 'no module named swbindings'. Anything you can do from VBA can be done from Python, and it's usually a one-for-one translation.? Somewhere in the SolidWorks object model documentation, there has to be a command to run a named VBA script.? That's what you need to find.? The key is that this is not Python related.? You're just controlling their COM server, so you need to find the right method in the right interface in their object model. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From sakarin14184 at gmail.com Tue Feb 15 23:48:21 2022 From: sakarin14184 at gmail.com (nakarin samon) Date: Wed, 16 Feb 2022 11:48:21 +0700 Subject: [python-win32] WM_MOUSEWHEEL It only works in one window. Message-ID: Is there any python that works like pywin32 SendMessage PostMessage. doesn't move the mouse? I want to move the mouse scroll or click the mouse without moving the mouse, I have used WM_MOUSEWHEEL. but not successful. It only works in one window. Will there be another one or it only works on the left side of the screen I tried moving the window to another section but it didn't work when I moved it back to the same place in the top left it works. this is an example: https://drive.google.com/file/d/137ouHgJR3eRZTUOFkHjPGO2eoMfQelCz/view?usp=sharing -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Feb 16 12:35:22 2022 From: timr at probo.com (Tim Roberts) Date: Wed, 16 Feb 2022 09:35:22 -0800 Subject: [python-win32] WM_MOUSEWHEEL It only works in one window. In-Reply-To: References: Message-ID: <64a202e7-a727-28a1-7151-0dab5a0edc87@probo.com> nakarin samon wrote: > > Is there any python that works like pywin32 SendMessage PostMessage. doesn't move the mouse? There are a couple of problems here. SendMessage and PostMessage are not Python things.? Those are fundamental Win32 APIs.? pywin32 just gives you access to them. Second, those routines do not, of course, move the mouse. > I want to move the mouse scroll or click the mouse without moving the mouse, I have used WM_MOUSEWHEEL. but not successful. It only works in one window. Will there > be another one or it only works on the left side of the screen I tried moving the window to another section but it didn't work when I moved it back to the same place > in the top left it works. I can't tell what you're asking or what you're expecting, and your video no longer works.? Mouse messages are delivered to the window with focus.? Background windows do not get them unless they have captured the mouse. So, please tells us what you are trying to achieve (not how you are trying to do it), and perhaps someone can advise you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: