.NET

Reply
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 1 of 22 (311 Views)

ObjectClass is not a member of ObjectID (AutoCAD 2008)

311 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*
norman.yuan
Posts: 998
Registered: ‎04-27-2009
Message 2 of 22 (305 Views)

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*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 3 of 22 (301 Views)

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
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 4 of 22 (296 Views)

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*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 5 of 22 (293 Views)

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*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 6 of 22 (288 Views)

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
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 7 of 22 (283 Views)

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*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 8 of 22 (277 Views)

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
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 9 of 22 (277 Views)

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*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 10 of 22 (263 Views)

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
-------------------------------------------------------------------------
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.