Hi there,
I am trying to change the table column properties of a content center family.
With the code below I can change most of the properties;
foreach (ContentTableColumn tableColumn in contentFamily.TableColumns)
{
if (tableColumn.DisplayHeading.Equals("File Name"))
{
tableColumn.Expression = "{SIZE}";
}
But I need to set the "Map to Inventor property" , but I can't find that property.
tableColumn.MapToInventor isn't available.
I can see a tableColumn.SetPropertyMap() but it needs a propertyID and property indentifier. I guess this is the one I need, but I can't find any examples on the net how to use this.
I want to set it to Project.Description.
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Solved by adam.nagy. Go to Solution.
Hi Remy,
Here is my answer:
I hope this helps.
Cheers,
SUPER ADAM, that's exactly what I need 🙂
It works like a charm. Do you by any change, know how I can do as "Save copy as" of a content center family with c# ?
As you found in the meantime there only seems to be some hidden/unsupported API to do it and I don't know how to use it either.
Will check with others and answer in the other thread: http://forums.autodesk.com/t5/inventor-customization/copy-family/m-p/6438068#M65482
I'm just bringing this back from the dead to contribute, because literally the only google result when you search for "ContentTableColumn.SetPropertyMap" is this thread, and i struggled a bit to figure out how to use it still.
For my use, I wanted to use the API and a VBA macro to add a new property column to a content center family, set its value to something specific, and map it to an inventor property.
Unfortunately, you have to update the family template to have the new property you want separately, and "replace family template" on it manually in the content center editor.
Here's the chunk that adds the property to the family table and creates the link to the inventor custom property:
Public Sub CCAddPropsToFam() ' Get the node in the content browser based on the names of the nodes in the hierarchy. Dim CCNode As ContentTreeViewNode Set CCNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("SAMPLE CATEGORY") ' Find a specific family. In this case it's using the display name, but any family ' characteristic could be searched for. Dim family As ContentFamily Dim checkFamily As ContentFamily For Each checkFamily In CCNode.Families If checkFamily.DisplayName = "SAMPLE FAMILY" Then Set family = checkFamily Exit For End If Next Dim oContentTableColumns As ContentTableColumns Set oContentTableColumns = family.TableColumns 'add one column Dim oNewCol As ContentTableColumn Set oNewCol = oContentTableColumns.Add("Sample", "Sample Property", kStringType, Expression:="Sample Value") 'set up property map (assumes that property exists in family template as a custom property called "Sample Property") Call oNewCol.SetPropertyMap("Inventor User Defined Properties", "Sample Property") 'save change Call family.Save End Sub
And here's the other one that creates a custom version of the file, adds the property and saves it to a folder:
Public Sub CCCreateFamReplaceParts() ' Get the node in the content browser based on the names of the nodes in the hierarchy. Dim CCNode As ContentTreeViewNode Set CCNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("SAMPLE CATEGORY") ' Find a specific family. In this case it's using the display name, but any family ' characteristic could be searched for. Dim family As ContentFamily Dim checkFamily As ContentFamily For Each checkFamily In CCNode.Families If checkFamily.DisplayName = "SAMPLE FAMILY" Then Set family = checkFamily Exit For End If Next Dim failureReason As MemberManagerErrorsEnum Dim failureMessage As String Dim memberfilepath As String Dim memberFilename As String memberfilepath = "C:\Users\Desktop\CCFamReplaceParts\" & family.DisplayName & ".ipt" memberFilename = family.CreateMember(family.TableRows(1), failureReason, failureMessage, kRefreshOutOfDateParts, True, memberfilepath) Dim partDoc As PartDocument Set partDoc = ThisApplication.Documents.Open(memberFilename, False) Dim customPropSet As PropertySet Set customPropSet = partDoc.PropertySets("Inventor User Defined Properties") Dim checkProp As Property Dim partClassProp As Property Set partClassProp = Nothing For Each checkProp In customPropSet If checkProp.name = "Sample Property" Then Set partClassProp = checkProp Exit For End If Next ' Set property if it doesnt exist, check value if it does. If partClassProp Is Nothing Then Set partClassProp = customPropSet.Add("Sample Value", "Sample Property") Else partClassProp.Value = "Sample Value" End If End Sub
Can't find what you're looking for? Ask the community or share your knowledge.