Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add new custom property to existing models

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
sbromley
761 Views, 9 Replies

Add new custom property to existing models

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
9 REPLIES 9
Message 2 of 10
gcoombridge
in reply to: sbromley

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 10
gcoombridge
in reply to: sbromley

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 10
johan.degreef
in reply to: sbromley

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
Message 5 of 10
A.Acheson
in reply to: gcoombridge

@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
Message 6 of 10
gcoombridge
in reply to: sbromley

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
Message 7 of 10
sbromley
in reply to: sbromley

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
Message 8 of 10
sbromley
in reply to: sbromley

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
Message 9 of 10
gcoombridge
in reply to: sbromley

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 10
johnsonshiue
in reply to: sbromley

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

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

Post to forums  

Autodesk Design & Make Report