How can you get cygwin to use (a component of) pywin32 library in a python program on a Win 7 Operating System? (Assume python version 2.7 is used)

StackOverflow https://stackoverflow.com/questions/23121823

  •  05-07-2023
  •  | 
  •  

Question

Here is a sample code I wish to execute using cygwin to run ion Windows 7 to do a simple search and replace for texts in an AutoCad drawing:

import sys
import win32com.client
from sys import argv
from win32com.client import Dispatch
acad = win32com.client.Dispatch("AutoCAD.Application")

doc = acad.ActiveDocument   # Document object
ms = doc.ModelSpace         # Modelspace "collection"
count = ms.Count            # Number of items in modelspace

for i in range(count):
    item = ms.Item(i)
    if 'text' in item.ObjectName.lower(): # Text objects are AcDbText
        # once we know what it is we can cast it
        text = win32com.client.CastTo(item, "IAcadText") 
        if text.TextString == "Spam":
            text.TextString = "Maps"
            text.Update()import win32com.client
acad = win32com.client.Dispatch("AutoCAD.Application")

doc = acad.ActiveDocument   # Document object
ms = doc.ModelSpace         # Modelspace "collection"
count = ms.Count            # Number of items in modelspace

for i in range(count):
    item = ms.Item(i)
    if 'text' in item.ObjectName.lower(): # Text objects are AcDbText
        # once we know what it is we can cast it
        text = win32com.client.CastTo(item, "IAcadText") 
        if text.TextString == "Spam":
             text.TextString = "Maps"
             text.Update()
Was it helpful?

Solution

I don't think you can do this because pywin32 isn't compatible with Cygwin.

See: http://sourceforge.net/p/pywin32/mailman/pywin32-bugs/thread/From_noreply@sourceforge.net_Fri_May_10_22:50:41_2013/

You can solve it by installing a non-Cygwin Python such as ActiveState, WinPython or similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top