| | | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte |
Autor
|
Thema: Dimension Styles ändern -> Dimensions verschwinden, BlockAttribute ändern (880 mal gelesen)
|
veydan Mitglied
Beiträge: 252 Registriert: 29.05.2008 AutoCAD/Mechanical 2009, Inventor 2009
|
erstellt am: 09. Feb. 2010 08:10 <-- editieren / zitieren --> Unities abgeben:
Hallo! Ich Suche einen Block und möchte dort 2 Attributwerte ändern. Er findet die Attribute, aber es wird nicht gespeichert/angezeigt. Die Messages werden ausgegeben, also ich komme definitiv da hin. Ist wahrscheinlich eine Kleinigkeit, aber ich find sie nicht...
Code:
Dim myDB As DatabaseServices.Database = Nothing Dim myTransMan As DatabaseServices.TransactionManager = Nothing Dim myTrans As DatabaseServices.Transaction = Nothing Dim mydwg As ApplicationServices.Document = Nothing Dim tAcadDocLock As DocumentLock = Nothing Dim myBT As DatabaseServices.BlockTable = Nothing Dim myBTRE As DatabaseServices.SymbolTableEnumerator = Nothing Try mydwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument tAcadDocLock = mydwg.LockDocument() myDB = mydwg.Database myTransMan = mydwg.TransactionManager myTrans = myTransMan.StartTransaction myBT = CType(myDB.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead), DatabaseServices.BlockTable) myBTRE = myBT.GetEnumerator Using myTrans Dim myBlockRef As DatabaseServices.BlockReference myBlockRef = CType(myTrans.GetObject(BlockId, DatabaseServices.OpenMode.ForWrite, True, True), DatabaseServices.BlockReference) Dim mySKDef As BlockTableRecord = myBT(myBlockRef.Name).GetObject(OpenMode.ForWrite) Dim myAttColl As DatabaseServices.AttributeCollection = Nothing Dim myEnt As DatabaseServices.Entity = Nothing Dim myBTREnum As BlockTableRecordEnumerator = Nothing myAttColl = myBlockRef.AttributeCollection myBTREnum = mySKDef.GetEnumerator While myBTREnum.MoveNext myEnt = myBTREnum.Current.GetObject(OpenMode.ForWrite) If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt If myAttDef.Tag = "Attribut1" Then myAttDef.TextString = "Text1" MsgBox("Attribut1") ElseIf myAttDef.Tag = "Attribut2" Then myAttDef.TextString = Text2 MsgBox("Attribut2") End If End If End While myTrans.Commit() myTrans.Dispose() End Using Catch ex As Exception MsgBox(ex.Message & vbNewLine & ex.StackTrace) Finally If tAcadDocLock IsNot Nothing Then tAcadDocLock.Dispose() : tAcadDocLock = Nothing End Try
edit: Dimstyle Problem entfernt [Diese Nachricht wurde von veydan am 09. Feb. 2010 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Ex-Mitglied
|
erstellt am: 09. Feb. 2010 09:40 <-- editieren / zitieren -->
Hi, Du änderst in der Blockdefinition den Inhalt der Attributdefinition Die Blockreference hast Du zwar geöffnet, aber nicht bearbeitet. - alfred - ------------------ www.hollaus.at |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|