Using COM objects and Python to Draw a Polyline
Posted: Mon Feb 06, 2023 12:37 pm
I have been trying to figure out how to use COM objects and Python to interact with IntelliCAD. I have been able to create new layers, lines and text in Intellicad with Python but I haven't been able to figure out how to draw a polyline. Here is my code:
All but the last line to draw a polyline works. The last line returns a 'Type mismatch' error. Any help with this is appreciated.
Code: Select all
import win32com.client # Create an instance of IntelliCAD icad = win32com.client.Dispatch("Icad.Application") # Make the IntelliCAD application visible icad.Visible = True # Get the current document doc = icad.ActiveDocument print(doc.Name) # Create a new layer doc.Layers.Add('New Layer') # Create points p1 = icad.Library.CreatePoint(0, 0) p2 = icad.Library.CreatePoint(10, 10) p3 = icad.Library.CreatePoint(10, 0) # Draw line line = doc.ModelSpace.AddLine(p1, p2) # Draw Text text = doc.ModelSpace.AddText('Hello World', p1, 1) # Draw Polyline pline = doc.ModelSpace.AddPolyLine([p1, p2, p3])