.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 1
Chumplybum
299 Views, 0 Replies

ObjectDBX

hey, i'm just starting to write / convert code from vb6 to vb.net and i'm having some difficulty with ObjectDBX... i've had a look thru this discussion group and found an example, however, it didn't fit in with what i had already... i'm hoping someone can steer me in the right direction

Ok, first off... here is the code for a drawing open in the drawing editor, which seems to work fine:

Public Function Exists(ByVal sName As String) As Boolean

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead)
Dim ReturnValue As Boolean

If lt.Has(sName) Then
ReturnValue = True
Else
ReturnValue = False
End If

trans.Commit()
trans.Dispose()

Return ReturnValue

End Function


what i'm after is something that will handle both: drawings that are open in the editor and also via object dbx... so heres my attempt

Public Function Exists(ByVal sName As String, Optional ByVal bUseObjectDBX As Boolean = False, Optional ByVal sDrawingFilePathDBX As String = "") As Boolean

Dim ReturnValue As Boolean

If File.Exists(bUseObjectDBX) = False Then
Dim db As Database = HostApplicationServices.WorkingDatabase
Else
'check file exists
Dim db As Database = HostApplicationServices.WorkingDatabase
db.ReadDwgFile(HostApplicationServices.Current.FindFile(sDrawingFilePathDBX, Database.FromAcadDatabase(Application.DocumentManager.MdiActiveDocument), FindFileHint.Default), IO.FileShare.Read, True, "")
End If

Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead)

If lt.Has(sName) Then
ReturnValue = True
Else
ReturnValue = False
End If

trans.Commit()
trans.Dispose()

Return ReturnValue

End Function


the trouble i'm having is withing declaring / setting / assigning the database. Any help would be great

cheers

Mark
0 REPLIES 0

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