import System
import clr
# Add Assemblies for AutoCAD and Civil3D
#LinkDWG Core DYF by Koz Jono YEOH
#kozmosovia@hotmail.com
#Copyright(C) 1994-2020 KozMos Inc.
#Copyright(C) 2011-2020 Neila Heaven Networks
#Copyright(C) 2017-2020 Tachyon Intelligent Design Institute
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
marsh = System.Runtime.InteropServices.Marshal
app = marsh.GetActiveObject("Autocad.Application.24.1")
aDoc = app.ActiveDocument
mSp = aDoc.ModelSpace
adoc = Application.DocumentManager.MdiActiveDocument
def ptA(p,x1,y1):
return System.Array[float]([p.X,p.Y,p.Z,p.X+x1,p.Y+y1,p.Z])
x1 = 5
y1 = 5
blockItem = None
# Координаты блоков
listOfPoints = IN[0]
numbeTable= IN[1]
Coord=[]
logFile = []
import Autodesk
outList = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
# Place your code below
for i in listOfPoints:
bufferOut = []
locOrigin = i.Origin
points = ptA(locOrigin,x1,y1)
lead = mSp.AddMLeader(points, 0)
bufferOut.append(lead)
leaderBlocks = aDoc.Blocks(lead.ContentBlockName) [color=red] [u]Вот эта строка повторяется тремя строками ниже[/u][/color]
if lead and hasattr(lead,"ObjectName") and lead.ObjectName=="AcDbMLeader":
blocks=lead.Document.Blocks.Item(lead.ContentBlockName) [color=red] здесь[/color]
for block in blocks: // здесь block по факту это acadEntity, то есть элементы из которых состоит определение блока
if block.ObjectName == "AcDbAttributeDefinition" and block.TagString.upper() == "НОМЕРЯРЛЫКА".upper(): [color=red] block.TagString.upper() == "НОМЕРЯРЛЫКА".upper() - вот тут скорее всего спотыкается код. Так как ентити может быть линией и у нее нет такого свойства[/color]
lead.SetBlockAttributeValue(block.ObjectId, str(numbeTable[listOfPoints.index(i)]))
blockItem = block[color=red] ну это тоже не то пальто[/color]
# Commit before end transaction
t.Commit()
#lead.TextString = str(numbeTable[listOfPoints.index(i)])
#ID_Name1 = (aDoc.Blocks("_TagCircle").ObjectID)
#lead1= mSp.SetBlockAttributeValue(lead.ObjectID,)
#lead.GetBlockAttributeValue(ID_Name1)
#coord.append(points)
outList = []
OUT = blockItem