ObjectDBX - OLE Hangs with VBA?

ObjectDBX - OLE Hangs with VBA?

Anonymous
Not applicable
627 Views
7 Replies
Message 1 of 8

ObjectDBX - OLE Hangs with VBA?

Anonymous
Not applicable
Hi Guys,

Firstly thanks for reading. I have a small problem trying to test that ObjectDBX works on my system.

I am using excel, and have loaded the following Libraries:

AutoCAD 2007 Type Library
AutoCAD/ObjectDBX Common 17.0 Type Library

My Code is below. It simply hangs and excel sends a message every few mins that it is waiting for an OLE application. Any ideas?
I do not have Autocad installed but have DWG TrueView 2007, i have tried the code on the draftsmans PC who have autoCAD but to no avail.

Sub Test()
Dim DbxDoc As AxDbDocument
'Set DbxDoc = GetInterfaceObject("ObjectDBX.AxDbDocument.17")
Set DbxDoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument.17")

MsgBox "Test"

Set DbxDoc = Nothing
End Sub
0 Likes
628 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Hi documentcontroller,


Forget wasting your time attempting this without AutoCAD installed.

Secondly you will find it far easier to develop from inside AutoCAD
where there are vast number of sample code items for linking with Excel.


Regards,


Laurie Comerford


documentcontroller wrote:
> Hi Guys,
>
> Firstly thanks for reading. I have a small problem trying to test that ObjectDBX works on my system.
>
> I am using excel, and have loaded the following Libraries:
>
> AutoCAD 2007 Type Library
> AutoCAD/ObjectDBX Common 17.0 Type Library
>
> My Code is below. It simply hangs and excel sends a message every few mins that it is waiting for an OLE application. Any ideas?
> I do not have Autocad installed but have DWG TrueView 2007, i have tried the code on the draftsmans PC who have autoCAD but to no avail.
>
> Sub Test()
> Dim DbxDoc As AxDbDocument
> 'Set DbxDoc = GetInterfaceObject("ObjectDBX.AxDbDocument.17")
> Set DbxDoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument.17")
>
> MsgBox "Test"
>
> Set DbxDoc = Nothing
> End Sub
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanks. I am now using the draftspersons computer. I was wondering if someone could tell me a method (or show me code sample) for how to extract table data from a reference table/material list.

I tried the below code, but i think it omits any tables.

For Each elem In objDbx.ModelSpace

With elem
If elem.ObjectName = "AcDbMText" Then
Range("A" & I).Value = elem.TextString
Else
End If



End With
Set elem = Nothing
I = I + 1
Next elem
0 Likes
Message 4 of 8

Anonymous
Not applicable
Nevermind. Just found the world of objectdbx.paperspace!

;-) thanks
0 Likes
Message 5 of 8

Anonymous
Not applicable
be aware that you can have more than one paperspace layout
imho .Paperspace itself is fairly useless...
For Each oLayout in oDoc.Layouts
If Not oLayout.Name = "Model" then 'if you only want pspace
Set oBlock = oLayout.Block
For Each oEntitiy in oBlock
... here are your paperspace objects for this layout
If TypeOf oEntity Is ....whatever you're looking for
... etc

Next oEntity

End If
Next

hth
mark

wrote in message
news:6209710@discussion.autodesk.com...
Nevermind. Just found the world of objectdbx.paperspace!

;-) thanks
0 Likes
Message 6 of 8

Anonymous
Not applicable
Thanks for that, i really appreciate it.

very new to all this
0 Likes
Message 7 of 8

Anonymous
Not applicable
glad to help
if you're just starting with coding to acad have you looked at dotnet? I'm
sad that it seems to be the only future direction for autodesk
I'm not anxious to throw away the last 10 yrs of learning vb and rewrite
everything in a whole new language (which some say is slow and bloated)
but if you're just starting you may want to review some of the topics via
the archives here re: dot net


wrote in message
news:6209785@discussion.autodesk.com...
Thanks for that, i really appreciate it.

very new to all this
0 Likes
Message 8 of 8

Anonymous
Not applicable
It might be something to consider, but for now i'm just after very basic functions like checking tables for materials, reference drawings etc.

The reason i started with the vba API is because i'm already working out of excel, it's easier just to have a macro setup in vba.

Whenever we get returned workshop drawings we have a long list of Main drawings. We then have to manually find the associated drawings in our drawing folder. So with this script that i'm working on, it will simply take each main drawing (which is pasted into excel) grab the associated drawings from the reference table within the paperspace, and then filecopy ALL drawings to a temporary folder so that they can be worked on.

This will save a lot of time in the office and the drafts people were very happy to hear that i was working on something like this.
0 Likes