- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an external rule (straight VB) with classes, subs and functions to call from other rules.
In this rule is the following code:
Public Class Glassteun
Public Property Category As String = "Reynaers_Glassteunen"
Public Property Name As String
Public Property Number As String
Public Property Visible As Boolean
Public Property Components As IManagedComponents
Public Property Component As ICadComponent
Public Sub New(Components As IManagedComponents, Component As ICadComponent)
Me.Components = Components
Me.Component = Component
End Sub
Public Function Place() As Inventor.ComponentOccurrence
Dim oOcc As Inventor.ComponentOccurrence
'*****This is a workaround for a bug, see this forum post: https://forums.autodesk.com/t5/inventor-programming-ilogic/place-content-center-bug/td-p/12727134*****
'****************************************************************************************************************************************************************
Try
If Name <> "" Then Component.Visible(Name) = True
Catch
End Try
'****************************************************************************************************************************************************************
'****************************************************************************************************************************************************************
If Name = "" Then Name = "TempName"
Components.AddContentCenterPart(Name, Category, Number, Number, , False, , )
Component.Visible(Name) = Visible
oOcc = Component.InventorComponent(Name)
If Name = "TempName" Then oOcc.Name = ""
Return oOcc
End Function
End Class
When I call the place function from an internal rule it works fine, but when I call it from an external rule it fails. This is the code I use to call the function:
AddVbFile "C:\Users\mathijs.stevens\Glas Ceyssens NV\Autodesk Inventor - General\Inventor Instellingen\R2024\iLogicSDK\ContentCenterReynaers.iLogicVb"
' Place/Replace Content Center Member Glassteun
Dim oGlassteun As New Glassteun(Components, Component)
oGlassteun.Name = ""
oGlassteun.Number = "073.7482.00 L"
oGlassteun.Visible = True
oGlassteun.Place
And this is the error message I get when calling from an external rule:
As far as I can tell all the arguments are passed correctly so I don't immediately see why this wouldn't work from an external rule.
@MjDeck Could this be a bug?

Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @mat_hijs ,
You might have already done this, but if you comment out all the lines of your function, and then un-comment them line by line, does this help you identify which line in the function is throwing the exception when running from the external rule?
That's the only suggestion that comes to mind. Examining the code, nothing occurred to me as to why it would not work with an external rule, but would with an internal rule.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
That's exactly what I did and the error is thrown at line 25 (of the straight VB rule).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It just occurred to me that "Components.AddContentCenterPart" is an iLogic function, and not an API function, and so maybe you would need to use the API to place the CC part in this case? Or maybe add a reference to the iLogic Add-in?
I'm just making guesses about that though, it's been a while since I've uses classes in this way with iLogic, so I forget the particulars. In any case I'm not sure I understand why the internal rule vs external rule situation would arise in this case, but maybe it's something to think about?
API example:
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-57915C88-FF59-4ED6-9A67-47E55DD62639
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I actually used to do this using the API, but the iLogic snippet is way faster than what I had because my code needed to loop through all the rows (which are usually thousands of them) to find the correct row and the code is just a lot easier to write and read.
Anyway you are correct that using iLogic snippets in straight VB code is a bit of a special situation, but because I pass the interfaces I need it works, or at least it does when called from an internal rule.
Public Sub New(Components As IManagedComponents, Component As ICadComponent)
Me.Components = Components
Me.Component = Component
End Sub
It's still possible that this causes my issue though but I don't know how to make sure...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@mat_hijs , I think I might have figured it out. If I add a line to specify the CC language in the function then it works without error in the Internal and External rules.
For me the language syntax is en-US
Public Class Glassteun Public Property Category As String = "Fasteners:Nuts:Hex" Public Property Name As String Public Property Number As String Public Property Visible As Boolean Public Property Components As IManagedComponents Public Property Component As ICadComponent Public Sub New(Components As IManagedComponents, Component As ICadComponent) Me.Components = Components Me.Component = Component End Sub Public Function Place() As Inventor.ComponentOccurrence Components.ContentCenterLanguage = "en-US" Dim oOcc As Inventor.ComponentOccurrence '*****This is a workaround for a bug, see this forum post: https://forums.autodesk.com/t5/inventor-programming-ilogic/place-content-center-bug/td-p/12727134***** '**************************************************************************************************************************************************************** Try If Name <> "" Then Component.Visible(Name) = True Catch End Try '**************************************************************************************************************************************************************** '**************************************************************************************************************************************************************** If Name = "" Then Name = "TempName" Components.AddContentCenterPart(Name, Category, Number, Number, , False, , ) Component.Visible(Name) = Visible oOcc = Component.InventorComponent(Name) If Name = "TempName" Then oOcc.Name = "" Return oOcc End Function End Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
To determine this I went into the Class rule and right clicked on a CC part in the model tree and used Capture Current State ( Components.Add) and it provided the code block as shown with the language line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hero! This seems to do the trick. I would have never found this myself because I used the capture current state, but in an internal rule, where it doesn't add that line.
Do you have any idea why this would differ between internal and external rules?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@mat_hijs wrote:
Hero! This seems to do the trick. I would have never found this myself because I used the capture current state, but in an internal rule, where it doesn't add that line.
Do you have any idea why this would differ between internal and external rules?
Yep, I just kind of got lucky when setting up my rule to match your setup, in that I did it in an external rule first.
As for what's going on between the internal and external rule, I really don't know. Maybe Mike Deck can provide some insight on that?