Create iProperties for all parts in Content Center

Create iProperties for all parts in Content Center

dusan.naus.trz
Advisor Advisor
3,558 Views
19 Replies
Message 1 of 20

Create iProperties for all parts in Content Center

dusan.naus.trz
Advisor
Advisor

Hi,

How can I create iProperties on all Components in Content Center automatically? Is there any code? VBA or iLogic? 

I've been working in Inventor since version 6 (2002), now I have Inventor 2020. I need to change all of the components in Content Center. Do you want to tell me it's not going to happen now?

Please is it possible? Thank you.

0 Likes
Accepted solutions (3)
3,559 Views
19 Replies
Replies (19)
Message 2 of 20

Mark.Lancaster
Consultant
Consultant

@dusan.naus.trz 

 

You will need to create your own custom read/write content center and copy over the provided families in order to change the properties.   Once copied over you add columns and mappings in the family table to your required properties.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 3 of 20

dusan.naus.trz
Advisor
Advisor

Hi,

I have my library for writing. I want to 50 families at once create the same iProperty. I have to create iProperties for every family? And then save. I do not want it. Is it automatic? Is it possible to automate this process?

0 Likes
Message 4 of 20

Frederick_Law
Mentor
Mentor

Content Center came installed with Inventor?

Or your custom CC?

What iProperties are you trying to add?

 

Stock CC get update and overwritten with Inventor install.

You could lose all the changes.

0 Likes
Message 5 of 20

dusan.naus.trz
Advisor
Advisor

Hi,

I want Add iProperties for Custom CC

0 Likes
Message 6 of 20

dusan.naus.trz
Advisor
Advisor

I would like to add all components 001_COLOR and 002_AREA. Please see the picture. Maybe in the future? Is there any code?

Create iProperties for all parts in Content Center.png

0 Likes
Message 7 of 20

jan_priban
Alumni
Alumni
Accepted solution

Hi Dusan,

 

I will try to improve following with simple UI (Form), but basically code bellows iterates through all families in/bellow Structural Shapes (recursively) and adds new column MyCol mapped to Custom.iPropAhoj. So every instance from Structure Shapes will have text custum iProperty iPropAhoj with value strAhoj. Main row is green.

 

1. Modify Inventor project to have only user read/write library reconfigured (by this we ensure all families are read/write)

2. In VBA environment create new module

3. Into module paste code bellow - AddColumnMAcro.jpg 

4. Run it

 

Also you can add reference to another property like reference to <mass>

Family.TableColumns.Add "HRUBAHMOTNOST", "HRUBAHMOTNOST", kStringType, , "=<mass>", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", "HrubaHmotnost"

 

Regards

Jan Priban

 

Dim iFamilyDone As Integer

Sub ListFamilies(CurrentNode As ContentTreeViewNode)

    Dim Family As ContentFamily     

    For Each Family In CurrentNode.Families

     Debug.Print Family.DisplayName

     Family.TableColumns.Add "MyCol", "MyCol", kStringType, , "strAhoj", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", "iPropAhoj"

     Family.Save

     iFamilyDone = iFamilyDone + 1

    Next

    Dim checkNode As ContentTreeViewNode

    For Each checkNode In CurrentNode.ChildNodes

     Call ListFamilies(checkNode)

    Next

End Sub

 

Sub AddCustomPropertyEverywhere()

iFamilyDone = 0

Call ListFamilies(ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes("Structural Shapes"))

MsgBox "Families Updated: " & iFamilyDone

End Sub

 

AddColumnMAcro.jpg

Message 8 of 20

dusan.naus.trz
Advisor
Advisor

Hi,
very thank you, everything works, it's great. I believe it will help everyone very much. This will speed up the process change. A lot of success to you. Good luck.

0 Likes
Message 9 of 20

dusan.naus.trz
Advisor
Advisor

Hi,
please i have another question. Thank you very much if you have time to answer.

change unit iProperties mass.png

Next Question

Insert_update_parts.png

0 Likes
Message 10 of 20

jan_priban
Alumni
Alumni
Accepted solution

Hi Dusan

 

see please my much better version

- it has UI (form)  where you can simply select category where you want to operate

- UI filters only write-able families (families from read/write user library)

- It has some checking/validation for not allowed characters

- it detects if column already exists in family

 

Import BAS file + Form file and run StartForm subroutine

 

Video "how to" attached

 

Regards

 

Jan Priban

 

 

Message 11 of 20

jan_priban
Alumni
Alumni
Accepted solution

Hi Dusan,

talking to people and reading forum/help I think we have no way how to modify (for example make it 1000x bigger) referenced parameter/iProperty. Means:

If formula =<mass> returns 3.14 we have no way how to modify/get 3140. So the technique of adding CC column is good for strings, when we want to merge strings together (e.g. partNumber + Enginner) . Not in case of "numerical strings".

 

Following your basic need/idea, you want to add modified mass as new custom.iProperty to all parts in assembly. Why not to use iLogic. iLogic code i made and verified iterates through all parts in assembly and adds custom mass. iLogic code can be placed into assembly template or be external rule - to make it available in all assemblies. Can be run Before assembly save or manually by iTrigger event - I used iTrigger.

 

I think it could be improved to iterate only through all frames under Frame Generator assembly, just need to detect Frame subassembly and operate there. Let me know please if iLogic could help you here.

 

Regards

Jan Priban

 

trigger = iTrigger0
' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument
    oAsmDoc = ThisApplication.ActiveDocument

    ' Get the assembly component definition.
    Dim oAsmDef As AssemblyComponentDefinition
    oAsmDef = oAsmDoc.ComponentDefinition

    ' Get all of the leaf occurrences of the assembly.
    Dim oLeafOccs As ComponentOccurrencesEnumerator
    oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences

    ' Iterate through the occurrences and print the name.
    Dim oOcc As ComponentOccurrence
    For Each oOcc In oLeafOccs
     MsgBox(oOcc.ReferencedDocumentDescriptor.FullDocumentName)
     iProperties.Value(oOcc.Name,"Custom", "MojeHmotnost") = Round(oOcc.MassProperties.Mass,2) & " [kg]"
    Next

MyMassiLogic.png

 

Message 12 of 20

dusan.naus.trz
Advisor
Advisor

Hi Jan,

04-26-2019 01:53 AM

I tried to use a boolean and it doesn't work? Please, what am I doing wrong?

Family.TableColumns.Add "MyCol", "MyCol", kBooleanType, , 1, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", "iPropAhoj"
'Family.TableColumns.Add "MyCol", "MyCol", kStringType, , "strAhoj", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", "iPropAhoj"

0 Likes
Message 13 of 20

jan_priban
Alumni
Alumni

Hi Dusan,

 

it seems VBA does not allow to add new columns of Boolean type (even UI does) - kBooleanType not listed.

 

AddColumnEnum.png

 

So if it is possible, use a workaround / alternative, add new column as type of Integer and use cell values 1 / 0 for True / False

 

Family.TableColumns.Add "MyCol", "MyCol", kIntegerType, "ul", "1"

 

Regards

 

Jan Priban

Message 14 of 20

dusan.naus.trz
Advisor
Advisor

Hi,
thank you very much for your answer. I tried your procedure and it works. It does not solve, but our process.
It's a pity the boolean type doesn't work.
Why did I ask that?
Here is the use:
We have Spare Parts ("NAHRADNI_DIL"), it's something like a table.
Only the components they have should enter the table. : Value = True
Fortunately, we are not procedurally far. So I'll adjust the process.
I will leave the value in the Content Center to the String.
I will create an iLogic that converts Boolean Value True to String "a" for normal components.
I'll use your string code. Colleagues really like your table in VBA.
If True then "a", if False is "n".
I will enter this as a String in the Content Center
Possibility of extension by Boolean type I will give Ideastation.
Thank you very much for your help.

2022-05-06_14h09_35.png

0 Likes
Message 16 of 20

dusan.naus.trz
Advisor
Advisor

IDEASTATION = Possibility change iProperties for all Content center

https://forums.autodesk.com/t5/inventor-ideas/possibility-change-iproperties-for-all-content-center/...

0 Likes
Message 17 of 20

niels.debaets
Contributor
Contributor

Hi Jan, thank you for this!
I want to fill in the "Vendor" property for the whole CC family. The rule now creates a custom iProperty "Custom.(column name)", which is most of the time perfect, but I want to modify the "Project.Vendor" iProperty. I assume I can change something in the VBA code in order to change this?  Maybe you can point me in the right direction?
I also assume this page may help to retrieve the correct Enumerator for the code? Inventor 2025 Help | PropertiesForDesignTrackingPropertiesEnum Enumerator | Autodesk

nielsdebaets_0-1755084042250.png

 

0 Likes
Message 18 of 20

WCrihfield
Mentor
Mentor

Hi @niels.debaets.  What do you mean by the terms 'fill in' and 'modify' used in your last reply?  Do you need to add a 'column' for that standard iProperty, or modify an existing column by changing it from something else to that standard iProperty?  It kind of sounds like you may want to change the 'value' of that standard iProperty within existing content center member model files.  I am honestly not that well versed in doing things to/within the Content Center by code right now, but I do understand how to do what the previous code example(s) in this forum topic are doing, and may be able to help create something similar using iLogic rules instead of the outdated VBA system, once I understand what you are trying to do.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 19 of 20

niels.debaets
Contributor
Contributor

Hi @WCrihfield, thank you for having a look! I want to fill in the standard "Vendor" property for a whole family, for example all bearings need to have "SKF" as a Vendor. When using the VBA workflow as posted here, I create a new custom property called "Vendor" (Custom.Vendor property in drop down list in my screenshot). I don't want to make a custom property, but fill in the existing "Vendor" property (Project.Vendor property in drop down list in my screenshot). Hope this is clear.

0 Likes
Message 20 of 20

WCrihfield
Mentor
Mentor

OK.  In that case, I assume we would first need to find the family, then make sure it has a column for the 'Vendor' iProperty, one way or another.  If that column does not already exist, then we could just use the ContentTableColumns.Add method, which includes optional inputs for both the property, and the expression.  And if the column already exists, we would just need to know how to find it...usually by its internal name or by its column display heading (ContentTableColumns.Item).  Then, check its HasPropertyMap property value.  Then, depending on its value, use either the (GetPropertyMap method, then check which one it is, to be sure), and/or use its SetPropertyMap method.  Then, we would still need to check its ContentTableColumn.Expression property value, and if not already the value you want, set it to the value you want.

Attached is a text file containing some example iLogic rule code I threw together (not for VBA macro use, but could be converted), but it will need to be customized a bit in a couple places.  Primarily because I don't know the name/ID of your 'CC Family', nor the name/ID of the CC family table column, or what you would want the internal name of the column to be if it needed to be created.  Not my finest work, since I am admittedly not that experienced in modifying Content Center stuff by code yet, but at least it is something that may help get you to your goal(s).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes