I have solved problem with this code:
Const progID As String = "AutoCAD.Application.17"
Dim acApp As AcadApplication = Nothing
' Intentar obtener la instancia activa
acApp = DirectCast(Marshal.GetActiveObject(progID), _
' Si se produce un error
' Crear una instancia
Dim acType As Type = Type.GetTypeFromProgID(progID)
acApp = DirectCast(Activator.CreateInstance(acType, True), _
' Error ¿Esta Acad instalado?
If acApp IsNot Nothing Then
acApp.ActiveDocument.SendCommand("(command " & Chr(34) & "NETLOAD" & Chr(34) & " " & Chr(34) & "C:/Program Files/AutoCAD 2009/AcDx.dll" & Chr(34) & ") ")
But now how i can change the value of attribute through my .exe application? Please help me? ^^ thank alots.
You can place your function in a new class project that has an interface exposing your function, compile the DLL yourdll.DLL and register it with COM. Once ready you can create a new project for your exe, add your dll as a reference and you can get the COM interface with GetInterfaceObject() or with GetActiveObject() just as you did above. Then you can either netload yourdll.DLL (not ac*.dll as you did above!) manually from ACAD or programatically via COM API using your interface object and then call your function. That's the easiest.
You can also create an in proc WCF server runnning inside autocad and talk to it from a WCF client running anywhere in the world as described in this video:
If you have problems let me know I might have some time this weekend to code up a simple example or find something on the web.
Thank for your help!
I would like to use solution 1, but not clear understand. Cuold you help me to make a code example.
for more google: acad progID
or: acad Marshal.GetActiveObject
Thereare other ways too, for instance you could use acCtrl.dll:
Now i know how to make it.
I will inform if my programe can work fullly.
If one day you come to VietNam, please contact me! ^^
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register