我正在使用Python语言和comtypes库处理AutoCAD绘图。这是我的代码片段:
from comtypes.client import *
from comtypes.automation import *
def connect_acad(self):
self.acad = GetActiveObject("AutoCAD.Application")
self.dwg = self.acad.ActiveDocument
self.mspace = self.dwg.ModelSpace
def mark_point(self, xy, num, lay):
def point(*args):
lst = [0.]*3
if len(args) < 3:
lst[0:2] = [float(x) for x in args[0:2]]
else:
lst = [float(x) for x in args[0:3]]
return VARIANT(array("d",lst))
def variant(data):
return VARIANT(VT_VARIANT, data)
def vararr(*data):
if ( len(data) == 1 and
isinstance(data, collections.Iterable) ):
data = data[0]
return map(variant, data)
p1 = point(xy[0], xy[1])
ent = self.mspace.AddCircle(p1, 0.3)
htch = self.mspace.AddHatch(0, 'SOLID', False)
htch.appendOuterLoop(vararr([ent,]))
htch.Evaluate()
如果有人感兴趣,请在此输入完整代码:https://github.com/nsedenkov/py_acadcoord/blob/master/acadcoord.py
任何事情都是正确的,除了命令附件.htoop引发异常“ComTypeError”。也许有人知道AutoCAD的数组是不是有人知道?谢谢您!在
预期类型为:
我还建议再次检查一下情况:
请参阅http://knowledge.autodesk.com/support/autocad-mechanical/getting-started/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-4CA06494-CDFF-46FA-9E1D-A0E8220F69F4-htm.html上的完整文档
相关问题 更多 >
编程相关推荐