"Set iLogicAuto = GetiLogicAddin(ThisApplication)" throws an error

"Set iLogicAuto = GetiLogicAddin(ThisApplication)" throws an error

mrattray
Advisor Advisor
1,736 Views
2 Replies
Message 1 of 3

"Set iLogicAuto = GetiLogicAddin(ThisApplication)" throws an error

mrattray
Advisor
Advisor

For some reason I can never get this line to work for me. I've tried using it in a couple of different API routines and it never cooperates. It throws a "Sub or Function not defined" error.  I copy/pasted it from a sample.  Here's the sub I'm working on at the moment that calls it:

 

Option Explicit

Private Sub CommandButton1_Click()

Dim iLogicAuto As Object
Dim curDoc As Document
Dim curVal As String
Dim box As Boolean
Dim TA As Single
Dim TB As Single
Dim TC As Single
Dim TD As Single
Dim TE As Single
Dim TF As Single
Dim BA As Single
Dim BB As Single
Dim BC As Single
Dim BD As Single
Dim BE As Single
Dim BF As Single

Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then
box = MsgBox("GetiLogicAddin failed!", vbCritical, "Critical Error!")
Exit Sub
End If

TA = boxTA.Value
TB = boxTB.Value
TC = boxTC.Value
TD = boxTD.Value
TE = boxTE.Value
TF = boxTF.Value
If botEqTop = True Then
BA = TA
BB = TB
BC = TC
BD = TD
BE = TE
BF = TF
Else
BA = boxBA.Value
BB = boxBB.Value
BC = boxBC.Value
BD = boxBD.Value
BE = boxBE.Value
BF = boxBF.Value
End If

Set curDoc = ThisApplication.ActiveDocument

iLogicAuto.ParamValue(curDoc, "topPlateWidth") = TA
iLogicAuto.ParamValue(curDoc, "topPlateLength") = TB
iLogicAuto.ParamValue(curDoc, "holeHorzOff") = TC
iLogicAuto.ParamValue(curDoc, "holeVertOff") = TD
iLogicAuto.ParamValue(curDoc, "squareHoleLength") = TE
iLogicAuto.ParamValue(curDoc, "squareHoleWidth") = TF

iLogicAuto.ParamValue(curDoc, "botPlateWidth") = BA
iLogicAuto.ParamValue(curDoc, "botPlateLength") = BB
iLogicAuto.ParamValue(curDoc, "botHoleOffsetX") = BC
iLogicAuto.ParamValue(curDoc, "botHoleOffsetZ") = BD
iLogicAuto.ParamValue(curDoc, "botSquareHoleLength") = BE
iLogicAuto.ParamValue(curDoc, "botSquareHoleWidth") = BF

flangesShole.Hide

End Sub

 

Thanks in advance for any suggestions,

Mike

Mike (not Matt) Rattray

0 Likes
1,737 Views
2 Replies
Replies (2)
Message 2 of 3

xiaoyan.qi
Alumni
Alumni

Hi, Mike

 

The function GetiLogicAddin need be defined in VBA code to Access iLogic.

 

here is the sample code in iLogic Sample

============================

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Set addIns = oApplication.ApplicationAddIns

'Find the add-in you are looking for
Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

If (addIn Is Nothing) Then Exit Function

addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function

===============================

 

Let me know if it works

Thanks

Mick

 

 

Here is some information in the help, just for your reference:

    A sample VBA macro to access iLogic can be found at the following location:

  • Windows XP

    Program Files\Autodesk\Inventor [version]\Samples\iLogic Samples\API\iLogicAutoTest.ivb

  • Windows Vista or (probably) Windows 7

    Users\Public\Documents\Autodesk\Inventor [version]\Samples\ iLogic Samples\API\iLogicAutoTest.ivb

0 Likes
Message 3 of 3

mrattray
Advisor
Advisor

Thanks Mick,

I probably should have mentioned that I did have that function in another module.  It turns out that I had it set to private for some reason.  *FacePalm*

 I set it to public but now I get some odd behavior.  When I use your version of the function I get a VB compile error: "Invalid use of property" for this line: Set addIns = oApplication.ApplicationAddIns

I solved the error dimming addIns: Dim addIns As ApplicationAddIns

Maybe because I use Option Explicit?

 

Regardless, it works great for me now.

 

Thanks for the help,

Mike

 

Mike (not Matt) Rattray

0 Likes