
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I've been trying to find help on replacing Mtext in a drawing border of mine. The drawing border is a block that has constant attributes that I have a vb.net dll that can edit the constant attributes.
I'm trying to add this to that dll, I would like this to work in such a way as to not have the user involved. My thought was to have the code executed when the form was loaded to edit the values in the titleblock. The code would look to see if the Mtext existed in the border and if so replace it with the correct Mtext. If the correct Mtext is there it would exit the Sub.
I'm have a hard time figuring out how to use the Transaction concept. I've tried to modify an exisitng function in the VB.net dll to do this change.
As you can see in this example code, I'm not very good at figuring out how to modify it to my needs. I'm still not sure how some of these "BIG PICTURE" concepts work?
Do I need one function to read and another function to write? Do I need a Sub to strat to function(s)? I understand most of form code.
Any pointers in the correct direction would be appreciated....
PublicSharedFunction ReadMtextFromBTR(ByVal strName AsMText) AsMTextDim MtxtList AsList(Of Text.StringBuilder)
Dim oDwg AsDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim oDB As DatabaseServices.Database= oDwg.Database
Dim oTransMgr As DatabaseServices.TransactionManager= oDB.TransactionManager
Dim oTrans As DatabaseServices.Transaction= oTransMgr.StartTransaction
UsingoTrans
Dim oDatabaseObject AsDBObject = oDB.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
Dim oBlockTable As DatabaseServices.BlockTable = DirectCast(oDatabaseObject, BlockTable)
Dim oBTRE As DatabaseServices.SymbolTableEnumerator= oBlockTable.GetEnumerator
WhileoBTRE.MoveNext
Dim oDBObject AsDBObject = oBTRE.Current.GetObject(DatabaseServices.OpenMode.ForRead)
Dim oBTR As DatabaseServices.BlockTableRecord = DirectCast(oDBObject, BlockTableRecord)
If oBTR.Name = strName.Text ThenForEach oObjectID AsObjectIdInoBTR
Dim oEnt AsDBObject = oTrans.GetObject(oObjectID, OpenMode.ForRead)
'If oEnt.GetType.ToString = "Autodesk.AutoCAD.DatabaseServices.AttributeDefinition" ThenIfTypeOf oEnt Is Autodesk.AutoCAD.DatabaseServices.MTextThen
oEnt.UpgradeOpen()
If oEnt.ToString >= ("FirstEnergy ") ThenSelectCaseCase"FirstEnergy GENERATION CORP."ReturnstrName
Case"FirstEnergy _"
GENERATION, LLC"
Return2
Case ElseThrowNewException("The border did not match any of the defined types.")
EndSelectEndIfEndIfNextEndIfEndWhile'oTrans.Commit()EndUsing
oTrans.Dispose()
oTransMgr.Dispose()
oDB.Dispose()
Return MtxtList
Solved! Go to Solution.