[python-win32] problem AddLine AutoCAD win32com.client

Mark Hammond skippy.hammond at gmail.com
Wed Feb 1 01:10:39 CET 2012


Sadly not many people have access to autocad so it is hard to test. 
What errors do you get using win32com?

Mark

On 1/02/2012 5:11 AM, DANIEL POSE wrote:
> Hello,
>
> Recently I try to write some code to automate AutoCAD from Python. I
> have to draw lines from Python using win32com.client module, but I
> obtain error. By other hand I solved the problem using comtypes module.
> However, If I try to obtain block attributes information, comtypes
> doesn't work but win32com.client work properly.
>
> AutoCAD attributes working code (work for win32com.client but no for
> comtypes):
> [code]
> import win32com.client
> acad= win32com.client.Dispatch("AutoCAD.Application")
> doc = acad.ActiveDocument
> seleccion=doc.SelectionSets.Add('selection1')
> seleccion.SelectOnScreen()
> for objeto in seleccion:
>      if objeto.ObjectName=='AcDbBlockReference':
>          bloque=objeto.GetAttributes()
>          bloque[0].TagString='newattributename' #This change the name
> for the first attribute in the selected block
> [/code]
>
> Draw line (work for comtypes but doesn't work for win32com.client):
> [code]
> import comtypes.client
> import array
> acad = comtypes.client.GetActiveObject("AutoCAD.Application")
> doc = acad.ActiveDocument
> ms = doc.ModelSpace
> pt1 = array.array('d', [0.0,0.0,0.0])
> pt2=array.array('d',[1.0,1.0,0.0])
> line = ms.AddLine(pt1, pt2) #This draw a line in AutoCAD
> [\code]
>
> My question is: Is posible to fix the problem using win32com to draw
> autocad line in order to avoid comtypes use?
> I found on the web several coments to the problem, but no solution.
>
> Thanks for help,
> Daniel Pose.
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list