Hi Dave,
now you got the big guns on your thread I'll back off - they're Waaaayyyyy
better than me at this stuff.
I'm just a fellow beginner who can sympathize with how hard some of this is
to understand when you're starting out.
You might want to do some general reading on Object oriented programming,
lots of resources out there that help with the basics.
"Dave F" wrote in message
news:53769E3B05D842B4395BE5E6A6493479@in.WebX.maYIadrTaRb...
> I know, which is why I said XLS.
I knew you knew that, but since you said.."first having to load that drawing
into the editor." i just threw that in for clarification.
> It didn't visibly display it on the screen. Is that what you mean by
> 'instance'?
James explained why it didn't display.
what i meant by "instance" goes back to the general background of object
oriented programming.
All objects are derived from classes(which in the context of vb would be in
a .cls file in your project.)
The .cls file contains the definition of the class, it's name, methods and
properties.
When you want to use a class(object) in your program, you create an instance
of the class.
That instance is assigned to the variable name you gave it, and then the
methods and properties are available to you through your variable name.
for example in acad you can
Dim oLine as AcadLine 'define the type of oLine variable as being of class
AcadLine
Set oLine = doc.AddLine blah blah 'create an instance of class AcadLine via
Autocad's interface
'now you can use the properties of that instance of that class
oLine.Layer = xxx
In the context of the GetObject function - as I understand it, that's a
special way to create an instance of a class which happens to be an
application object or a document object contained in an application object.
If the class type passed to GetObject function is an Application object, vb
will look for a running instance of that application class object and if it
exists in the running object table, it will return the first instance found
to your variable name and most likely cause it to become visible (depending
on other conditions in your codes). If it doesn't find a running instance,
it will return an error and you can trap that error, then use CreateObject
to creat a running instance (assuming that class is registered on your
machine etc).
If the class object type passed to GetObject is a document name, GetObject
will find the application associated with the extension of the filename, and
if it is registered, look for a running instance of that application and if
found, return it with the document opened in that instance of the
application class, or if not found, will create an instance of the
application and open the file in it. So that way is a shortcut to the first
way of trying to GetObject an app, trap the error, CreateObject, then open
the file.
I think that description (however inaccurate) applies generally to any
Activex application accessed through vb. ObjectDBX, on the other hand, is
specifically an AutoCAD interface, having nothing to do with excel or any
other application. And, since it's not an application object, rather an
interface, you don't create an instance of it with GetObject, instead you
use GetInterfaceObject.
Dim objdbx As AxDbDocument
Set objdbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
>So, using ObjectDBX is faster?
yes, in general, since you can manipulate things without waiting for it to
come up in the editor, regens, etc. There are some things you can't do with
dbx though so it depends entirely on what you're trying to accomplish
hth
Mark
(if I botched the explanation of GetObject (which is entirely possible)
hopefully someone who actually knows what they're talking about will fix it)