Add new custom property to existing models

Add new custom property to existing models

sbromley
Collaborator Collaborator
1,647 Views
10 Replies
Message 1 of 11

Add new custom property to existing models

sbromley
Collaborator
Collaborator

I’ve had the need to create a custom property for all new and existing models. 
The new property has been added to the part & assembly templates.

Is there an easy way to get this new iproperty into my existing models? There’s about 250 model model files that need updating. I know I’ll have to open each file but I was hoping not to have to type in the new iproperty each time.

Autocad Mechanical 2023
0 Likes
Accepted solutions (1)
1,648 Views
10 Replies
Replies (10)
Message 2 of 11

gcoombridge
Advisor
Advisor

You need some ilogic for this. The rule below will ask you for a custom iprop name and a value. It will then create it in all sub parts/assemblies.

 

If you want to alter the values individually you are best to add it to the Bill of Materials dialogue box and change them in one place.

 

Sub Main
    
	Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument 
	
	Dim oNewiPropName As String
	oNewiPropName = InputBox("Enter new custom iProp name", "iLogic", "")
	Dim oNewiPropValue As String
	oNewiPropValue = InputBox("Enter new custom iProp default value", "iLogic", "")
	
	If oNewiPropName <> "" Then
    	SubName(oAsmDoc.ComponentDefinition.Occurrences, 1, oNewiPropName,oNewiPropValue) 
	End If
End Sub 

Private Sub SubName(Occurrences As ComponentOccurrences, Level As Integer, oNewiPropName As String, oNewiPropValue As String) 

    Dim oOcc As ComponentOccurrence 
    For Each oOcc In Occurrences 
		Dim oDoc As Document = oOcc.Definition.Document
		Dim customPropertySet As PropertySet
		customPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
		
        Try
				customPropertySet.Add(oNewiPropValue, oNewiPropName)
        Catch
                'Do Nothing
        End Try

        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then 
            SubName(oOcc.SubOccurrences, Level + 1, oNewiPropName,oNewiPropValue) 
        End If 
    Next 
End Sub

 

 

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 3 of 11

gcoombridge
Advisor
Advisor

You can just create the custom iprop in the BOM also... See screenshot. It will only populate if it gets assigned a value.

 

image.png

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 4 of 11

johan.degreef
Advisor
Advisor

Adding this to your external rules, will give you access to the rule from all existing documents, just replace my custom iproperties by yours.

 

 

 

iProperties.Value("Custom", "PTN_ARTNR") = ""
iProperties.Value("Custom", "PTN_CLIENT") = ""
iProperties.Value("Custom", "PTN_CLIENT_DRAWING") = ""
iProperties.Value("Custom", "PTN_CLIENT_TAG") = ""
iProperties.Value("Custom", "PTN_CODE") = ""
iProperties.Value("Custom", "PTN_COMMENTS") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_EN") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_NL") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_FR") = ""
iProperties.Value("Custom", "PTN_DESIGNER") = ""
iProperties.Value("Custom", "PTN_DRAWING") = ""
iProperties.Value("Custom", "PTN_LOCATION") = ""
iProperties.Value("Custom", "PTN_MANAGER") = ""
iProperties.Value("Custom", "PTN_MATERIAL") = ""
iProperties.Value("Custom", "PTN_PN") = ""
iProperties.Value("Custom", "PTN_PROJECTNR") = ""
iProperties.Value("Custom", "PTN_REVISION") = ""
iProperties.Value("Custom", "PTN_SIZE") = ""
iProperties.Value("Custom", "PTN_STATUS") = ""
iProperties.Value("Custom", "PTN_SUPPLIER") = ""
iProperties.Value("Custom", "PTN_TAG") = ""
iProperties.Value("Custom", "PTN_TITLE_EN") = ""
iProperties.Value("Custom", "PTN_TITLE_NL") = ""
iProperties.Value("Custom", "PTN_TITLE_FR") = ""
iProperties.Value("Custom", "PTN_TRADEMARK") = ""
iProperties.Value("Custom", "PTN_TRADEMARK_ARTNR") = ""
iProperties.Value("Custom", "PTN_TYPE") = ""
iProperties.Value("Custom", "PTN_WEIGHT") = ""

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 5 of 11

A.Acheson
Mentor
Mentor

@sbromley 

Are all the files in one folder or are you opening them on a case by case basis? You should be able to run a rule as above on all the files using a batch tool once you know what they are and where they are. There is a great batch tool here.

https://forums.autodesk.com/t5/inventor-forum/any-way-to-automatically-update-all-related-drawings/t...

and here. 

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/screencast/Main/Details/4ab05506-...

 

It does take a bit of testing when integrating these rules but it works really well. I will give it a go with @gcoombridge code and post it up when working. You will be sipping tea/coffee in the break room while the computer is churning true the files in know time. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 11

gcoombridge
Advisor
Advisor

I had made an assumption in the rule above that it would be run in an assembly containing all/many of the parts. If that assembly doesn't exist you could just create it.. 

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
0 Likes
Message 7 of 11

sbromley
Collaborator
Collaborator

The files are not in one assembly they are all in one folder. I've no idea were you enter this code.

Autocad Mechanical 2023
0 Likes
Message 8 of 11

sbromley
Collaborator
Collaborator

The files are not in one assembly they are all in one folder. I've no idea were you enter this code.

Autocad Mechanical 2023
0 Likes
Message 9 of 11

gcoombridge
Advisor
Advisor

You would create an assembly - add the rule in the ilogic browser. Then drag and drop all part files in there (without constraining them - just use the assembly as a container). Run the code, save and then delete the assembly.

 

That was just the idea that came to me... The batch tool @A.Acheson posted looks awesome.. 

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 10 of 11

johnsonshiue
Community Manager
Community Manager
Accepted solution

Hi! Another workflow is to use File Explorer. You can multi-select the Inventor files in File Explorer -> iProperties -> Custom -> add the value. You don't need to launch Inventor to do that.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 11 of 11

mark.vanderheijdenPFPP4
Explorer
Explorer

 

 

0 Likes