Using .AddCustomContentCenterPart or .AddContentCenterPart in Visual Studio

Using .AddCustomContentCenterPart or .AddContentCenterPart in Visual Studio

clive.w66LR9
Contributor Contributor
490 Views
1 Reply
Message 1 of 2

Using .AddCustomContentCenterPart or .AddContentCenterPart in Visual Studio

clive.w66LR9
Contributor
Contributor

I’m trying to use the .AddCustomContentCenterPart method in Visual Studio with the following libraries:

Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
Imports Autodesk.iLogic.Interfaces
Imports Inventor
Imports Autodesk.iLogic.Core

I’ve declared acomponents as IManagedComponents, but I’m unsure how to assign a value to it.

Here’s the function I’m using to create a component:

Private Function createComponent(ByVal name As String, ByVal length As Integer) As Object
    Return acomponents.AddCustomContentCenterPart(name,
    "Structural Shapes",
    "Frametek Tracks",
    {"PARTNUMBER", "PRC9019"}, {"Length", length},
    partFolder:="",
    partFilename:=name + ".ipt",
    position:=Nothing, grounded:=False,
    visible:=True, appearance:=Nothing)
End Function

In iLogic (within inventor), I can achieve this simply with:

Dim componentA = Components.AddCustomContentCenterPart("Test123", 
    "Structural Shapes", 
    "Frametek Tracks",
    {"PARTNUMBER","PRC9019"},{"Length", 500}, 
    partFolder := saveAsPath, 
    partFilename:= "Test123.ipt", 
    position := Nothing, grounded := False, 
    visible := True, appearance := Nothing)

How can I correctly assign a value to acomponents and use it in the createComponent function in Visual Studio?

 

@JelteDeJong 

0 Likes
Accepted solutions (1)
491 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @clive.w66LR9.  I do not have the answer you are looking for, but maybe I can offer some helpful advise/information instead.  It is usually not a good idea to attempt to use resources that are unique to the iLogic ApplicationAddIn within external tools, because we simply do not have access to all the needed resources.  When we create a new iLogic rule using the built-in rule editor dialog, there is a bunch of stuff done for us automatically in the background that we never see, to make our task simpler.  Part of what is done that we do not see if the automatic creation of the 'ThisRule' Class, multiple references added and inclusions made, and declarations of a bunch of variables, better known as 'Rule Objects', which represent Interfaces.  Since those Rule Objects get declared in the background, and we never see how they get declared, it is difficult to replicate those declarations outside of an iLogic rule.  And that is why we loose recognition of them within other custom Class blocks of code, such as when referencing another external rule with 'AddVbFile', in which the other rule must be set to 'Straight VB Code'.  We can sometimes 'pass' the rule object to an external resource as an input parameter when we initialize it, but it is complicated, if possible at all, to both declare and initialize these rule objects entirely within our external resources without passing them in.

 

Those iLogic tools are often just a 'middle man' routine to take some of the complication out of the task, and allow different forms of 'input parameters', such as just the name of something, instead of supplying the object that the name refers to.  Pretty much all of it can be done with regular Inventor API code instead.  The API route just usually requires a bit more code and complication than the iLogic tools.  In this case, to use the API route, we need to first generate the CC model file from the CC table, then use the member model's full file name with the Add method to add it to the assembly as a component.

 

Below is a link to the API Sample (in VBA, not vb.net) for adding a content center part to an assembly as a component.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=PlaceContentCenterPart_Sample 

That sample is referred to from the ComponentOccurrences.Add method's online help page, because that is the primary Inventor API method for adding components to an assembly.  

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes