Hi Mark,

Recently I'm working on the AutoCAD attribute extraction. When I install the 
pywin32 and write the code as follow:
Before into the code, I want to ask one question. If I wish to extract from dxf 
file can I use the same method as below?
--------------------------------------------------------------------------------------------
import win32com.client
acad = win32com.client.Dispatch("AutoCAD.Application")

ms = acad.ActiveDocument


for entity in acad.ActiveDocument.ModelSpace:
    name = entity.EntityName
    if name == 'AcDbBlockReference':
       HasAttributes = entity.HasAttributes
       if HasAttributes:
           print(entity.Name)
           print(entity.Layer)
           print(entity.ObjectID)
           for attrib in entity.GetAttributes():
               print("{}:{}".format(attrib.TagString, attrib.TextString))

               attrib.TextString='modified with python'
               arrtib.Update()

I encountered an error says :
==================== RESTART: F:\PHP\DXF_Data\Script4.py ====================
Traceback (most recent call last):
  File "E:\python3.5\lib\site-packages\win32com\client\dynamic.py", line 89, in 
_GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005,  'invalid string', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\PHP\DXF_Data\Script4.py", line 3, in <module>
    acad = win32com.client.Dispatch("__**AutoCAD.Application")
  File "E:\python3.5\lib\site-packages\win32com\client\__init__.py", line 95, 
in Dispatch
    dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "E:\python3.5\lib\site-packages\win32com\client\dynamic.py", line 114, 
in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "E:\python3.5\lib\site-packages\win32com\client\dynamic.py", line 91, in 
_GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'invalid string', None, None)
>>>

So I go back to the makeup.py to check if there is a autocad type library but  
I didn't found it.

Can I get any suggestion from you?

Best Regards,

Will

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to