Hi,
This part can't work:
For Each acObj As Object In acBlkTblRec
ENT = acObj
If ENT.Layer = "HTSV_P1_BEWR_VOLL_X01" Then
ent.colorindex=4
ElseIf ENT.Layer = "HTSV_P1_BEWR_RAST_X02" Then
e.clorindex=5
End If
Next ...because the BlockTableRecord is a list of ObjectIDs, not a list of Entities, so you have to change it to:
For each tObjID as ObjectID in acBlkTblRec
'check if this ObjectID is valid within the database (that's a standardcheck for me
if (tObjID.isValid) andalso (not tObjID.isErased) then
'then you wanted to check that is of type Text
if tObjID.ObjectClass.DxfName.ToUpper like "*TEXT" then
'ok, it's an object of TEXT od MTEXT
'get the object
dim tEnt as Entity = ctype(acTrans.GetObject(tObjID,openmode.forread),Entity)
select case tEnt.Layer.toupper
case "HTSV_P1_BEWR_VOLL_X01"
call changeColor(acTrans,tEnt,4)
case "HTSV_P1_BEWR_RAST_X02"
call changeColor(acTrans,tEnt,5)
end select
end if
end if
Next
... and the new function for changing the colorindex
private sub changeColorIndex(byref TrAct as transaction, byref Ent as Entity, byval newColorIndex as integer)
if Ent.ColorIndex <> newColorIndex then
if not ent.isWriteEnabled then Ent = ctype(acTrans.GetObject(tObjID,openmode.forwrite),Entity)
ent.ColorIndex = newColorIndex
end if
end sub be careful, just written in Mozilla, not tested.
- alfred -
------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ...
blog.ish-solutions.at ...
LinkedIn ...
CDay 2026------------------------------------------------------------------------------------
(not an Autodesk consultant)