Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change table column properties

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
817 Views, 5 Replies

Change table column properties

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.

 

 

5 REPLIES 5
Message 2 of 6
adam.nagy
in reply to: Anonymous

Hi Remy,

 

Here is my answer:

http://adndevblog.typepad.com/manufacturing/2016/07/map-familys-table-column-to-inventor-property.ht...

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 6
Anonymous
in reply to: adam.nagy

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# ? 

Message 4 of 6
adam.nagy
in reply to: Anonymous

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  



Adam Nagy
Autodesk Platform Services
Message 5 of 6
Anonymous
in reply to: adam.nagy

Yes, this hidden feature is exactly what I need. Works like a charm, thanks a lot Adam.
Message 6 of 6
BrandonW9
in reply to: Anonymous

 

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report