From 585f5403e82d1de4a1c841c01bde7ecf1a6aa562 Mon Sep 17 00:00:00 2001 From: Prashant Kumar Date: Sat, 17 Oct 2020 09:57:55 +0530 Subject: [PATCH] - added add_attribute() to add attribute to a Block --- updateBOM_ITEM.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/updateBOM_ITEM.py b/updateBOM_ITEM.py index c013c6d..172e42a 100644 --- a/updateBOM_ITEM.py +++ b/updateBOM_ITEM.py @@ -43,7 +43,20 @@ def _get_adir(): return adir +def add_attribute(): + try: + acad = GetActiveObject("AutoCAD.Application") + except: + acad = CreateObject("AutoCAD.Application", dynamic=True) + doc = acad.ActiveDocument + block = doc.Blocks.Item('BOM_ITEM') + insertion_point = array.array('d', [100.0, 100.0, 0.0]) + block.AddAttribute(2.0000, 1, 'New_Attribute_Test', + insertion_point, 'New_Attribute_Test', '1') + doc.Utility.Prompt("Adding new attribute\n") + def process(doc): + add_attribute() for entity in doc.ModelSpace: try: name = entity.EntityName @@ -97,7 +110,7 @@ def main(): acad.Documents.Close() except: pass - doc = acad.Documents.Open(afile, ReadOnly=False) + doc = acad.Documents.Open(afile) for i in range(3): try: doc = acad.ActiveDocument -- GitLab