Page 1 of 1

AutoCAD VB or VBA?

Posted: Tue Sep 09, 2003 7:58 am
by amir
Could I call a form that is designed and coded in Visual Basic in CAD
environment?
Here is a more detailed technical description of what I am planing to do:
I need to design a screen that provide a way to select a dwg CAD file from a
remote server. The user must use the custom form to select a drawing
file, and NOT the File/Open option in the main menu.
Therefore, I need to have a form that is functioning like a web application
that connect to remote server, and provides the list of the remote
drawings. Then I should download the file and programatically open it in CAD
environment. It looks that VBA does not have the API's that I need, and I have to use only VB, right?

Posted: Tue Sep 09, 2003 11:32 am
by ssc
amir,

Do not know if this is what you want:

Public objIcad As Object
Public objDrawings As IntelliCAD.Document

Private Sub chkforIcad()
If Connect Then
'Bring Icad to the top
AppActivate objIcad.Caption
'Set initial values and objects

'do stuff
End If
End Sub

Public Function Connect() As Boolean
Dim IntellicadRunning As Boolean
On Error GoTo Err_Control
IntellicadRunning = IsICADOpen()
If IntellicadRunning Then
Set objIcad = GetObject(, "ICAD.application")
Else
Set objIcad = CreateObject("ICAD.application")
End If
objIcad.Visible = True
Set objDrawing = IntelliCAD.ActiveDocument
Connect = True
Exit_Here:
Exit Function
Err_Control:
MsgBox Err.Description
Resume Exit_Here
End Function

Function IsICADOpen() As Boolean
On Error Resume Next
Set objAcad = GetObject(, "ICAD.Application")
IsAutoCADOpen = (Err.Number = 0)
Set objIcad = Nothing
Err.Clear
End Function

Public Function ConnectToDocument(strDocument As String) As Boolean
On Error Resume Next
Set objDrawing = GetObject(strDocument)
Set objIcad = objDrawing.Application
ConnectToDocument = (Err.Number = 0)
Err.Clear
End Function


A reference to IntelliCAD object model must be made.

ssc