Using the Content Center though a VB.NET add-in

Using the Content Center though a VB.NET add-in

spencer
Advocate Advocate
1,003 Views
3 Replies
Message 1 of 4

Using the Content Center though a VB.NET add-in

spencer
Advocate
Advocate

Hello all, I've been working on automating design processes using a custom Inventor add-in, but I'm stumped with regards to the content center.

One of the key features is a command I have setup that inserts new assemblies composed of content center parts, but the handling of the content center is not going well.

 

So far everything seems to work aside from the way the parts are put in, and I've tried several ways with mixed results. Below is the pre-insert process

 

- User input form gives the ok, passes back a collection of parameters to the builder module

- Builder module gets the parameters and generates a filename, then checks if filename exists in the project

-- If it does, that file is inserted and the function is done

-- If not, it creates a new assembly, maps all parameters to the assembly user parameters, then inserts assembly, saves, and triggers the build process

 

- Build process does stuff, determines assembly "family" and loops through all ContentFamily's in the applicable content center tree node

- For each part, generates a filename and a NameValueMap with the needed parameters (Same names as part params) for that part

- For each part check if file already exists

-- If it does, simply insert said part

-- If not, insert part from content center

 

 

Which is where things go bad, I've tried several methods but can't seem to get any to work, and the lack of info on the details of these methods doesn't help

 

Attempt 1:

 

ContentFamily.CreateMember(1{Rows and Columns not used in these parts}, Err, FailMessage,,True, FileName, Params))

Result:

Part is inserted, Params is not passed whatsoever so the end result is a default-size part that's locked from editing

The names in params are the same as the parameter names they're supposed to map to, but there no docs on how this command works so it's up in the air if I've even got the right format

 

Attempt 2:

ContentFamily.CreateMember(1{Rows and Columns not used in these parts}, Err, FailMessage,,True, FileName))
insertPart()
oDoc as PartDocument = document of inserted part

Dim tDCT As CommandTypesEnum = oDoc.DisabledCommandTypes
Dim tDST As String = oDoc.SubType

oDoc.DisabledCommandTypes = 0
oDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}"

Loop
Assign Params values to oDoc parameters

oDoc.Update()
oDoc.Save2()

oDoc.DisabledCommandTypes = tDCT
oDoc.SubType = tDST

Result:

Part is inserted with proper name and default values, is changed to a standard part, parameters are overwritten by stored Params, part is updated, saved, and changed back to original type

This works approximately 1/3rd of the time and runtimes + crashes Inventor the other 2/3rds, and there seems to be no rhyme or reason as to when it will be ok and when it won't

 

Attempt 3:

Tried to do a setup that hijacked user commands from the command manager, not sure if it's possible but is going to take a lot of trial and error to even find out.

 

 

Any suggestions on making this work? I don't even know if I'm simply calling functions wrong or if some of these don't work as advertised/intended

 

Including a picture of my user form, since pictures are good for attracting attention and it gives a better idea of what I'm going for. Depending on the Panel Type selected, different parameters and different parts are used to make the assembly

ie. Double panels have a cover on top that other types don't, but because of that they can't have an eyebrow, but both use the same base panel in their construction, just with different flags set, etc.

 

ContentCopy.PNG

 

 

 

0 Likes
Accepted solutions (1)
1,004 Views
3 Replies
Replies (3)
Message 2 of 4

HermJan.Otterman
Advisor
Advisor
Accepted solution

hello Spencer,

 

are the parts that you create custom parts are standard parts and will they be used many times?

 

If you create standard parts, with you own parameters, location will be somewhere in a library.

the name of the part should be automaticaly created in the content center part, (combination of columns and user input)

 

If you do it that way, you don't need to check if the file exists, Inventor will do that for you.

 

 

 

I used this:

 

 

 

Dim oFamily As Inventor.ContentFamily = Nothing

 

For Each oFamily In oContentNode.Families

If oFamily.DisplayName = FamilyName Then

Exit For

End If

Next

 

Dim errorMessage As Inventor.MemberManagerErrorsEnum = Nothing

Dim strContentPartFileName As String = Nothing

Dim strErrorMessage As String = Nothing

strContentPartFileName = oFamily.CreateMember(RowNumber, errorMessage, strErrorMessage, , False, , CustomInput)

 

In my assembly there are already (dummy) parts that can be replaced

 

'Replace the existing occurrence with the newly created one.

oOcc.Replace(strContentPartFileName, False)

 

the CustomInput is the nameValueMap.

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 4

spencer
Advocate
Advocate

I was unaware it checks for duplicates on its own, I'll try inserting as a standard part once I rework my family categories to handle the file naming correctly again.

0 Likes
Message 4 of 4

spencer
Advocate
Advocate

Once I fixed up my custom content center parts a bit and tried that out it worked flawlessly, and working backwards from there allowed me to make it a custom insertion with a specific filename+location. I appreciate the help on this one