Click to See Complete Forum and Search --> : early binding
badgers
Dec 30th, 1999, 04:26 AM
I have autocad open with a drawing loaded. I want my program to get the path of the drawing. This code starts a new session of autocad. I am guessing it has to do with the set statement and the use of the new keyword. Is there a different key word. Every text I have uses the new key word.
Option Explicit
Private Sub Command1_Click()
Dim x, y
Dim AC As AutoCAD.AcadApplication
Set AC = New AutoCAD.AcadApplication
x = AC.ActiveDocument.Path
MsgBox (x)
End Sub
Thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
badgers
Dec 30th, 1999, 05:13 AM
here is my problem.
if I use the line
Set AC = AutoCAD.AcadApplication
I have two problems
1. intellisense wont even give me the .AcadApplication I have to copy/paste
2 when it runs I get an error. method not found.
is this an example of why not to use early binding?
It seems that if I use early binding I have to create a NEW instance of AutoCAD.
I am trying to replace the following code which is late binding(but it works fine). This is not a major problem, I am just trying to use a higher performance method.
Dim AC, acadDoc As Object
Dim path as String
Set AC = GetObject(, "autoCad.application") 'get the current autocad session
Set acadDoc = AC.ActiveDocument
Path = acadDoc.Path 'get the autocad path
thank you for your time and have a good day
[This message has been edited by badgers (edited 12-30-1999).]
Serge
Dec 30th, 1999, 10:50 AM
If you're not adding a reference to ACAD library, then you won't see tbe intellisence dropdowns, also you would have to use CreateObject to get it working.
Dim objACAD As Object
Set objACAD = CreateObject("AutoCAD.AcadApplication")
This will give you the ability to work with AutoCAD.ACADApplication object.
But if you add a reference to AutoCAD library, then you can see all properties and methods by using object browser (or intellisence will show you them in a dropdown list)
------------------
Serge
Software Developer
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Clunietp
Dec 30th, 1999, 12:08 PM
Badgers:
Instead of declaring AC as object (actually, you have it declared as a variant), declare it as AutoCad.AcadApplication with the Autocad library referenced.
You should then be able to return an instance of the active autocad session back to your AC object using the GETOBJECT function. You will then have early binding on your object when you invoke the properties and methods.
NOTE: do not use the NEW keyword, because you are returning an existing instance of autocad and you do not want to create a new instance.
badgers
Jan 2nd, 2000, 10:10 PM
thank you for your replies.
Here is my problem.
Serge. What you have is not, to my understanding, early binding. declaring it as an object is late binding.
Clunietp
Instead of declaring AC as object (actually, you have it declared as a variant), declare it as AutoCad.AcadApplication with the Autocad library referenced.
this is what I have done. The autocad library is referenced. The intellisence gives me the .AcadApplication only If I use the NEW keyword.
how is the
Dim AC As AutoCAD.AcadApplication
declaring it as a variant? I can't see how that is true.
Does anyone have autocad? Maybe this is a bug with autocad and early binding
thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
badgers
Jan 2nd, 2000, 10:54 PM
both of the following do not work.
Private Sub Command1_Click()
Dim AC As AutoCAD.AcadApplication
Set AC = GetObject(, "AutoCAD.AcadApplication")
End Sub
Private Sub Command2_Click()
Dim ACC As AutoCAD.AcadApplication
Set ACC = AutoCAD.AcadApplication
End Sub
first one give an ActiveX error
the second gives an error, method not found.
THE AUTOCAD LIBRARY IS REFERENCED!!
this works but is late binding(as I understand Late binding)
Private Sub Command3_Click()
Dim Auto As Object
Set Auto = GetObject(, "AutoCAD.application")
MsgBox Auto.Path
End Sub
------------------
I am so skeptacle, I can hardly believe it!
badgers
Jan 3rd, 2000, 12:04 AM
thank you all for your input and time.
I have found that AutoCAD R14.0 has a bug
which does not allow early binding.
sorry to have bothered you all.
------------------
I am so skeptacle, I can hardly believe it!
Crazy D
Jan 3rd, 2000, 11:10 AM
AFAIK, early binding is declaring an object as the real type,
Dim c As ADODB.Recordset
Late binding is
Dim c As Object
c = CreateObject/GetObject....
The New keyword you use when you want a new object (huh.. hmmm.. i dont know how else to explain), to set a reference it shouldbe enough to declare something as the object you want.
I don't know why early binding doesn't work, maybe you can find something on the Autodesk site about it, I've never worked with Autocad (neither with GetObject...) but if Command3 is the only way it works, it looks to me like early binding is not possible.
Clunietp
Jan 3rd, 2000, 11:44 AM
Sorry, badgers, I was referring to your second post, where you had put: Dim AC, acadDoc As Object
when you use DIM X, Y as long
X is a variant
Y is a long
But that does not matter now....
I guess you'll just have to use late binding..
Anyone else?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.