I need to make my application compatible with 2008 and have one error saying that ObjectClass is not a member of SubEntId (As ObjectID) in my InsertBlock routine. Can anyone suggest a solution here?
Public Sub InsertBlock(ByVal blockname As String, ByVal trans As Transaction) Dim db As Database = Application.DocumentManager.MdiActiveDocument.Data
base ' Test if block exists in the block table Dim bt As BlockTable = DirectCast(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable) Dim id As ObjectId = bt(blockname) Dim btr As BlockTableRecord = trans.GetObject(id, OpenMode.ForRead, False, True) Dim br As New BlockReference(New Point3d(0, 0, 0), id) Dim MS As BlockTableRecord = DirectCast(trans.GetObject(bt(BlockTableRecord.Mod elSpace), OpenMode.ForWrite), BlockTableRecord) MS.AppendEntity(br) trans.AddNewlyCreatedDBObject(br, True) If btr.HasAttributeDefinitions Then Dim AtDef As AttributeDefinition, AttRef As AttributeReference For Each SubEntId As ObjectId In btr If SubEntId.ObjectClass.Name = "AcDbAttributeDefinition" Then AtDef = trans.GetObject(SubEntId, OpenMode.ForRead, False, True) AttRef = New AttributeReference AttRef.SetAttributeFromBlock(AtDef, br.BlockTransform) br.AttributeCollection.AppendAttribute(AttRef) trans.AddNewlyCreatedDBObject(AttRef, True) AtDef.Dispose() AttRef.Dispose() End If Next End If BlockRefID = br.ObjectId End Sub
if gettype(trans.getobject(SubEntId,OpenMode.ForRead, False, False).Equals(gettype(DatabaseServices.AttributeRe
- alfred -
Adding that now says that "trans.getobject" is not defined.
A bit strange bit intellisense doesn't register what "trans" is within the gettype() function.
in your sample-code the variable "trans" was the transaction you used, I just used it again.
But just because I reread your post, you are searching for a DatabaseServices.AttributeDefinition and not for an DatabaseServices.AttributeReference, so please correct that in my line.
But the rest should work.
- alfred -
Oh, oh, oh, one bracket missing! It should be:
if gettype(trans.getobject(SubEntId,OpenMode.ForRead, False, False)).Equals(gettype(DatabaseServices.AttributeD
(I know I should have tried it, sorry!)
- alfred -
I'm not sure what's happened to the trans variable. It doesn't register within the gettype function for some reason.
have you seen my previous message with "missing brackets"?
At leat the GetObject is used the same way as you had it one line after the if, so it has to work.
The lines can also be tried in that way (simplier then:
Dim tDbObj as DatabaseServices.DBObject = trans.GetObject(SubEntId,OpenMode.ForRead,False,Fa
'now you can use your attribute-defintion
AtDef = ctype(tDbObj, DatabaseServices.AttributeDefinition)
Hoping not to have additional typos!
- alfred -
I've added the ).
Still no dice. I may just be throwing in a useless and confusing bit of information but this version uses .NET 3.0
our posts crossed again!
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.