.NET

Reply
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 1 of 22 (296 Views)

ObjectClass is not a member of ObjectID (AutoCAD 2008)

296 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: 946
Registered: ‎04-27-2009
Message 2 of 22 (290 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: 8,867
Registered: ‎06-29-2007
Message 3 of 22 (286 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
-------------------------------------------------------------------------
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 4 of 22 (281 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: 8,867
Registered: ‎06-29-2007
Message 5 of 22 (278 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: 8,867
Registered: ‎06-29-2007
Message 6 of 22 (273 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
-------------------------------------------------------------------------
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 7 of 22 (268 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: 8,867
Registered: ‎06-29-2007
Message 8 of 22 (262 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
-------------------------------------------------------------------------
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 9 of 22 (262 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: 8,867
Registered: ‎06-29-2007
Message 10 of 22 (248 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
-------------------------------------------------------------------------

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community