How to reference the AutoCAD COM API in an iLogic rule

<?xml encoding=”UTF-8″>By Wayne Brill

You can use AddReference to reference the AutoCAD COM Interops. Below is an iLogic rule to test this. (It just Dims a couple of types) iLogic needs to be able to find the AutoCAD Interop dlls. The path where it looks for the interop dlls is set in the Advanced iLogic Configuration. (tools tab Options). You can copy Autodesk.AutoCAD.Interop.dll and Autodesk.AutoCAD.Interop.Common.dll to the “iLogic AddIn DLLs directory” to avoid the error with the AddReference line of code. This screenshot shows the path where iLogic will look for the interop DLLs. 

iLogic_Configuration_WB

 

Here is the iLogic rule that references the AutoCAD Interops. It shows declaring types from the AutoCAD COM API. AcadBlockReference and AcadCircle. It also creates or gets a running session of AutoCAD.

AddReference "Autodesk.AutoCAD.Interop"
AddReference "Autodesk.AutoCAD.Interop.Common"
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.Interop
Sub Main
Dim oAcadApp As AcadApplication
oAcadApp = CreateObject("AutoCAD.Application")
'If AutoCAD is already running use GetObject
'oAcadApp = GetObject(,"AutoCAD.Application")
oAcadApp.Visible = True
Dim myBlockRef As AcadBlockReference
Dim oAcadCircl as AcadCircle
MessageBox.Show(oAcadApp.Caption, "Title")
End Sub

Comments

3 responses to “How to reference the AutoCAD COM API in an iLogic rule”

  1. I wonder where it stores the Path ?
    In registry or in some XML?
    I as CADmanager would like to force it to be equal to some corporate value…

  2. Silvestre Salles Junior Avatar
    Silvestre Salles Junior

    i have a factory Asset and, for to make the configurations i make a form with iLogic in Autodesk Inventor. how can I use this form in autocad?

Leave a Reply to MaxU77Cancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading