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: 

family.TableColumns.Add

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
capparottoQQZAF
219 Views, 4 Replies

family.TableColumns.Add

Hi experts,

could some one help me with:

 

family.TableColumns.Add("DESCRIPTION", "Des", kStringType) 

 

this code give me error in VBA; I want to add a new column in content centre.

(no problem with "family" object)

 

thanks

4 REPLIES 4
Message 2 of 5

Hi @capparottoQQZAF.  I do not really interact with the Content Center much from code, but maybe I can help some with helping you understand what is going wrong, so that we can better understand how to solve the problem you are having.  Since you are only showing that one line of code, I can only assume that the 'family' term being used is a variable that was declared as an Inventor.ContentFamily Type object, and that you have set a valid value to it.  From that point, you are accessing the ContentFamily.TableColumns property, which represents a ContentTableColumns object, then trying to use its Add method.  Can you tell us what the error message is saying, and what type of error it says it is?  Sometimes those little details can help, if you know what to look for.  The documentation says that the results of using this method will not take effect until after you have used the ContentFamily.Save method on that family.  So, if you have already used this method before, but did not see an immediate change, then tried this method again, it may throw an error, because that column may already exist in memory, but you just have not saved it yet.  Not sure what the case may be.

But there is one other detail...the family must be modifiable, or all these methods will fail.  You can check that with ContentFamily.IsModifiable property.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

Hi

this is th error: Object variable or With block variable not set

at the row: newcol = family.TableColumns.Add("DESCRIPTION", "Des", kStringType)

 

 

capparottoQQZAF_0-1704957350172.png

 

Message 4 of 5

This is the code:

 

Sub Exec(family As ContentFamily)
Dim count As Integer
Dim newcol As ContentTableColumn
Dim expression As String
count = 0

For i = 1 To family.TableColumns.count

If family.TableColumns(i).InternalName = "Description [Project]" Then

expression = family.TableColumns(i).expression


count = 1
End If

Next

If count = 1 Then
MsgBox (family.DisplayName)
newcol = family.TableColumns.Add("DESCRIPTION", "Des", kStringType)
family.Save

Dim myFile As String
myFile = "C:\Users\massimo.a\Desktop\prova\vba.txt"
Open myFile For Append As #1
Write #1, family.DisplayName
Close #1

 

End If

 

End Sub

Message 5 of 5

Sorry

my fault, I forgot "Set"

All is working now

Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report