.NET

.NET

Reply
Mentor
256 Posts
4 Kudos
Registered: ‎04-15-2011
Post 1 of 22

ObjectClass is not a member of ObjectID (AutoCAD 2008)

325 Views, 21 Replies
03-25-2013 11:54 AM

Hi,

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.Database
        ' 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.ModelSpace), 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

 

*Expert Elite*
1,084 Posts
215 Kudos
Registered: ‎04-27-2009
Post 2 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:22 PM in reply to: SRSDS

ObjectId.ObjectClass property was only made available since AutoCAD 2009.

 

*Expert Elite*
9,793 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 3 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:25 PM in reply to: SRSDS

Hi,

 

if gettype(trans.getobject(SubEntId,OpenMode.ForRead, False, False).Equals(gettype(DatabaseServices.AttributeReference)) then

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
256 Posts
4 Kudos
Registered: ‎04-15-2011
Post 4 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:38 PM in reply to: Alfred.NESWADBA

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.

*Expert Elite*
9,793 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 5 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:43 PM in reply to: SRSDS

Hi,

 

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
9,793 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 6 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:47 PM in reply to: SRSDS

Oh, oh, oh, one bracket missing! It should be:

 

if gettype(trans.getobject(SubEntId,OpenMode.ForRead, False, False)).Equals(gettype(DatabaseServices.AttributeDefinition)) then

 

(I know I should have tried it, sorry!)

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
256 Posts
4 Kudos
Registered: ‎04-15-2011
Post 7 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 12:51 PM in reply to: Alfred.NESWADBA

Hi,

I'm not sure what's happened to  the trans variable. It doesn't register within the gettype function for some reason.

Screenshot attached.

*Expert Elite*
9,793 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 8 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 01:01 PM in reply to: SRSDS

Hi,

 

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,False)

if tDbObj.Gettype.Equals(Gettype(DatabaseServices.AttributeDefinition)) then

    'now you can use your attribute-defintion

    AtDef = ctype(tDbObj, DatabaseServices.AttributeDefinition)

 

Hoping not to have additional typos!

 


- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
256 Posts
4 Kudos
Registered: ‎04-15-2011
Post 9 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 01:01 PM in reply to: SRSDS

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

 

 

*Expert Elite*
9,793 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 10 of 22

Re: ObjectClass is not a member of ObjectID (AutoCAD 2008)

03-25-2013 01:25 PM in reply to: SRSDS

our posts crossed again! :smileywink:

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post