2020: ObjectDBX test

2020: ObjectDBX test

Anonymous
Not applicable
3,696 Views
14 Replies
Message 1 of 15

2020: ObjectDBX test

Anonymous
Not applicable

Hello Everyone,

Two days I'm diving into ObjectARX/ObjectDBX areas to create little prove of concept for my project.

My goal is to iterate 9000 dwg files and to extract some data from them.

My environment:

1. Windows 10 Pro 64bit

2. AutoCAD 2019 - commercial license

3. Installed ObjectARX 2020 Wizards (Autodesk_ObjectARX_2019_Win_64_and_32_Bit)

4. Visual Studio 2017 Community edition

5. AutoCAD 2020 .NET Wizards (not necessary but installed)

I created Visual Basic Console App (.NET Framework) project (just try ot open DWG file) with dll refs only for ObjectDBX  from ObjectARX(acdb23.lib,acge23.lib,acgiapi.lib,axdb.lib,rxapi.lib,acismobj23.lib) with just one executable source as following :

 
Imports Autodesk.AutoCAD.DatabaseServices
Module Module1

    Sub Main()
        Try
            Dim db As Database
            db = New Database(False, True)
            db.ReadDwgFile("C:\WORK\Tests\20200129\dobrich.dwg", System.IO.FileShare.ReadWrite, False, "")
            db.CloseInput(True)
            HostApplicationServices.WorkingDatabase = db
            Using tr As Transaction = db.TransactionManager.StartTransaction()

            End Using

            Debug.Write("End")
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        End Try
        Debug.WriteLine("End")
    End Sub

End Module

But I have always such error:

Exception thrown: 'System.InvalidProgramException' in ConsoleApp5.exe
Common Language Runtime detected an invalid program.

I know that such error is common if I use ObjectARX dll ourside of ObjectDBX because I will need AutoCAD app, but this is not the case in my code. 

I cannot understand why I have such error in case of exploanation in Autodesk documentations that must be working fine. 

Any suggestion for fix of that error ?

Regards

 
 

 

0 Likes
Accepted solutions (2)
3,697 Views
14 Replies
Replies (14)
Message 2 of 15

artc2
Autodesk
Autodesk
Accepted solution
Perhaps I've misunderstood what you are trying to do, but the ObjectARX SDK can only be used to create C++ or .NET dlls that can be loaded into AutoCAD and run from within AutoCAD. It can't be used to create a standalone exe that does not need AutoCAD.

If you want to create a standalone console application that does not require AutoCAD, then you will need to use the RealDWG SDK which is a licensed SDK that is not free.
Message 3 of 15

Anonymous
Not applicable

According official sources you are not right because ObjectARX is a plugin SDK, but contains ObjectDBX (for standalone apps just few dll (see below), RealDWG is the license version ofObjectDBX  )

Official info from techsoft3d (Autodesk)

To test and trial RealDWG, please follow these steps:

  • Download and read about system requirements for the ObjectARX SDK here. These libraries are actually the API for AutoCAD (So you can see how well integrated RealDWG is!)
  • If you don’t have AutoCAD, you can download a 30-day trial version here.
  • If you’re not familiar with ObjectARX programming, you can get started here. Also have a look at the sample projects that come with the SDK.
  • RealDWG uses the ObjectDBX part of the Object ARX libraries. (Please be aware that any UI or draw functions are NOT included in RealDWG. However, all file reading, file writing and geometry functions are.)

Using the ObjectARX SDK, it is possible to do a “proof-of-concept” to validate the intended behavior. As RealDWG is a subset of ObjectARX you need to make sure critical features are kept within the RealDWG parts of the API.

 

See below for specific instructions about how to test if you are using Managed (.NET) code or Native (C++) code.

 

Managed code (.NET)

 

You’ll be using the managed API of ObjectARX. The ObjectARX features that are specific to RealDWG only, can be found in the namespaces of the AcDbMgd.dll:

 

However, you need to make sure no critical calls are made to the AcCoreMgd.dll, which contains overlapping namespaces ‘GraphicsSystem’ and ‘Runtime’ (this dll is not part of RealDWG):

 

Additional dll’s in ObjectARX that are also available in RealDWG:

  • acdbmgdbrep.dll
  • AcAxDb23res.dll
  1. Native code (C++)

The ObjectARX functionality that is also available in RealDWG is restricted to these libraries:

  • ac1st23.lib
  • acdb23.lib
  • acdbmgd.lib
  • AcDbPointCloudObj.lib
  • acge23.lib
  • AcGeolocationObj.lib
  • acgiapi.lib
  • acismobj23.lib
  • acModelDocObj.lib
  • AcMPolygonObj.lib
  • AcPal.lib
  • AcSceneOE.lib
  • axdb.lib
  • rxapi.lib

from the utils folders

  • AecModeler.lib
  • AdImaging.lib
  • AdIntImgServices.lib
  • acbr23.lib
  • acgex23.lib
  • AsdkHlrApi23.lib
Message 4 of 15

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:

According official sources you are not right because ObjectARX is a plugin SDK, but contains ObjectDBX (for standalone apps just few dll (see below), RealDWG is the license version ofObjectDBX  )

@artc2 better than anyone on this forum know how to use ObjectARX and ObjectDBX (RealDWG)

Without RealDWG you can not create exe-file for reading/writing dwg-file.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 15

Anonymous
Not applicable

Interesting how to buy RealDWG without way for understand what is possible to do by testing of ObjectDBX in standalone mode.

Thank you for both answers!

0 Likes
Message 6 of 15

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:

Interesting how to buy RealDWG without way for understand what is possible to do by testing of ObjectDBX in standalone mode.

Thank you for both answers!


Ask this question in techsoft3d.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 7 of 15

Anonymous
Not applicable

Can you confirm that testing of ObjectDBX (dwg open/read)  is possible only by plugin for AutoCAD?

0 Likes
Message 8 of 15

tbrammer
Advisor
Advisor
Accepted solution

@Anonymous wrote:

Can you confirm that testing of ObjectDBX (dwg open/read)  is possible only by plugin for AutoCAD?


You will need an appropriate host application to load and test a DBX module. This could also be RealDWG based app like Autodesk Trueview that allows to load DBX modules.

 

Anyway I would recomment AutoCAD because it might be tricky to test your functions if you are not using AutoCAD.

The usual way is to to write a command in an ARX module that calls your functions. If you use another host app you have to figure out a way to make it call your function.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 9 of 15

Anonymous
Not applicable

Thank you!

0 Likes
Message 10 of 15

veli_vaisanen
Enthusiast
Enthusiast

Hi,

have you try these?

https://blog.jtbworld.com/2007/09/objectdbxrealdwg-using-vbnet.html 

Private Function StartAutoCAD() As Object
  On Error Resume Next
  Dim AcadApp As Object
  ' Get the active session of AutoCAD using late binding
  AcadApp = GetObject(, "AutoCAD.Application.17.1")
  If Err.Number <> 0 Then
    Err.Clear()
    Shell("c:\Program Files\Common Files\Autodesk Shared\WSCommCntr1.exe", AppWinStyle.NormalFocus)
    ' Create a new session of AutoCAD using late binding
    AcadApp = CreateObject("AutoCAD.Application.17.1")
  End If
  Return AcadApp
End Function

Private Sub Test()
    Dim AcadApp As Object
    Dim dbxDoc As Object
    AcadApp = StartAutoCAD()
    If AcadApp Then
        AcadApp.Visible = True
        objDbx = AcadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.17")
        objDbx.Open("D:\test\block1.dwg")
        Dim ms As Object
        ms = objDbx.ModelSpace
        MsgBox(ms.Count.ToString + " objects in in model space")
        objDbx = Nothing
        AcadApp.Application.Quit()
        AcadApp = Nothing
    End If
End Sub

 

https://blog.jtbworld.com/2007/07/objectdbx-sample-using-vba-and-autocad.html 

Option Explicit
Dim objDbx As AxDbDocument
' 2007-06-08
' By Jimmy Bergmark
' Copyright (C) 2007 JTB World, All Rights Reserved
' Website: www.jtbworld.com
' E-mail: info@jtbworld.com
' Runs in AutoCAD 2008 with axdb17enu.tlb (must be referenced) AutoCAD/ObjectDBX Common 17.0 Type Library
' Example of batch for listing all block names on all drawings in a directory.

Private Sub ListBlockNames()
Set objDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.17")
Dim inDir As String
Dim elem As Object
Dim filenom As String
Dim WholeFile As String
Dim newHeight As Double
inDir = "c:\program files\autocad 2008\sample"
filenom = Dir$(inDir & "\*.dwg")
Do While filenom <> ""
    ThisDrawing.Utility.Prompt vbCrLf & "File: " & filenom
    ThisDrawing.Utility.Prompt vbCrLf & "-----------------"
    WholeFile = inDir & "\" & filenom
    objDbx.Open WholeFile
    For Each elem In objDbx.Blocks
        If elem.IsXRef = False And Left(elem.Name, 1) <> "*" Then
            ThisDrawing.Utility.Prompt vbCrLf & elem.Name
        End If
    Next
    Set elem = Nothing
    filenom = Dir$
    ThisDrawing.Utility.Prompt vbCrLf
Loop
Set objDbx = Nothing
End Sub

Br. Veli

0 Likes
Message 11 of 15

Alexander.Rivilis
Mentor
Mentor

@veli_vaisanen wrote:

Hi,

have you try these?

https://blog.jtbworld.com/2007/09/objectdbxrealdwg-using-vbnet.html 

https://blog.jtbworld.com/2007/07/objectdbx-sample-using-vba-and-autocad.html 

Br. Veli


Sorry but this code has nothing similar with RealDWG and ObjectDBX

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 12 of 15

veli_vaisanen
Enthusiast
Enthusiast

@Alexander.Rivilis wrote:

@veli_vaisanen wrote:

Hi,

have you try these?

https://blog.jtbworld.com/2007/09/objectdbxrealdwg-using-vbnet.html 

https://blog.jtbworld.com/2007/07/objectdbx-sample-using-vba-and-autocad.html 

Br. Veli


Sorry but this code has nothing similar with RealDWG and ObjectDBX


Ok. I understand that. Just reply to original problem:

"My goal is to iterate 9000 dwg files and to extract some data from them."

Br. Veli

0 Likes
Message 13 of 15

Alexander.Rivilis
Mentor
Mentor

@veli_vaisanen wrote:

@Alexander.Rivilis wrote:

@veli_vaisanen wrote:

Hi,

have you try these?

https://blog.jtbworld.com/2007/09/objectdbxrealdwg-using-vbnet.html 

https://blog.jtbworld.com/2007/07/objectdbx-sample-using-vba-and-autocad.html 

Br. Veli


Sorry but this code has nothing similar with RealDWG and ObjectDBX


Ok. I understand that. Just reply to original problem:

"My goal is to iterate 9000 dwg files and to extract some data from them."

Br. Veli


Original problem can be easy solved with ObjectARX or AutoCAD .NET API, AcCoreConsole and bat-file.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 14 of 15

veli_vaisanen
Enthusiast
Enthusiast

@Alexander.Rivilis wrote:

@veli_vaisanen wrote:

@Alexander.Rivilis wrote:

@veli_vaisanen wrote:

Hi,

have you try these?

https://blog.jtbworld.com/2007/09/objectdbxrealdwg-using-vbnet.html 

https://blog.jtbworld.com/2007/07/objectdbx-sample-using-vba-and-autocad.html 

Br. Veli


Sorry but this code has nothing similar with RealDWG and ObjectDBX


Ok. I understand that. Just reply to original problem:

"My goal is to iterate 9000 dwg files and to extract some data from them."

Br. Veli


Original problem can be easy solved with ObjectARX or AutoCAD .NET API, AcCoreConsole and bat-file.


Thanks Alex,

my mistake that I don´t read first message properly. Should I remove my posts?

Br. Veli

0 Likes
Message 15 of 15

Alexander.Rivilis
Mentor
Mentor

@veli_vaisanen wrote:


Thanks Alex,

my mistake that I don´t read first message properly. Should I remove my posts?

Br. Veli


No you should not remove posts. By the way, you can not remove your post - it is possible only with help of forum moderators.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes