.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Field not found

2 REPLIES 2
Reply
Message 1 of 3
John
260 Views, 2 Replies

Field not found

System.MissingFieldException: Field not found: 'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace'.

What wrong with this code? It work in 2006.


Private Sub ADDPlotstyle(ByVal PS As String)
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim btr As BlockTableRecord


Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btrId As ObjectId = bt(btr.ModelSpace)
btr = trans.GetObject(btrId, OpenMode.ForWrite)

Try
Dim center As New Point3d(10, 10, 0)
Dim text As New MText
text.Contents = "Plot Style"
text.Location = center
btr.AppendEntity(text)

text.PlotStyleName = PS

trans.AddNewlyCreatedDBObject(text, True)
text.Erase()

Catch ex As Exception
End Try

docLock.Dispose()
trans.Commit()
trans.Dispose()
2 REPLIES 2
Message 2 of 3
flongsworth
in reply to: John

Have you been able to figure out what is causing this? I am having exactly the same problem. It appears that the model space block it not recognized in the .net wrappers?!
Message 3 of 3
Dakuan
in reply to: John

anyone else managed to solve this? its driving me crackers.

my code works fine in 2007+ but wont work in 2006

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost