Here is some code for an external iLogic rule that will look at all Model Parameters, all User Parameters, and all Custom iProperties, no matter which type of document it is. For each Parameter, it checks to see if there is a Custom iProperty with the same name. If it finds one, it copies the Parameter's value to the value of the Property. If it doesn't find the Property, it creates it, with the same name and value as the Parameter. For Model Parameters, I put an additional check in there, to see if it has been renamed. Most people don't use Model Parameters for automation & programming purposes, but if they do, they usually at least rename it, and when they rename it, they usually avoid starting its name with "d", because that's how Inventor names them by default. So if the Model Parameter's name doesn't start with "d" it is then processed the same as the User Parameters.
You should be able to use this to process older files. If you use this code in it's own Sub, as part of a larger code to process files in bulk, you may have to change from ActiveDocument to a different specified oDoc type variable.
Dim oDocType As DocumentTypeEnum = ThisApplication.ActiveDocumentType
Dim oPDoc As PartDocument
Dim oPDef As PartComponentDefinition
Dim oADoc As AssemblyDocument
Dim oADef As AssemblyComponentDefinition
Dim oParams As Parameters
Dim oDDoc As DrawingDocument
Dim oCProps As PropertySet
Dim oProp As [Property]
Dim oExists As Boolean
If oDocType = DocumentTypeEnum.kPartDocumentObject Then
oPDoc = ThisApplication.ActiveDocument
oPDef = oPDoc.ComponentDefinition
oParams = oPDef.Parameters
oCProps = oPDoc.PropertySets.Item("Inventor User Defined Properties")
ElseIf oDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
oADoc = ThisApplication.ActiveDocument
oADef = oADoc.ComponentDefinition
oParams = oADef.Parameters
oCProps = oADoc.PropertySets.Item("Inventor User Defined Properties")
ElseIf oDocType = DocumentTypeEnum.kDrawingDocumentObject Then
oDDoc = ThisDrawing.Document
oParams = oDDoc.Parameters
oCProps = oDDoc.PropertySets.Item("Inventor User Defined Properties")
End If
Dim oMParams As ModelParameters = oParams.ModelParameters
Dim oMParam As ModelParameter
Dim oUParams As UserParameters = oParams.UserParameters
Dim oUParam As UserParameter
For Each oUParam In oUParams
'Check if matching Custom iProperty exists. If not create it.
oExists = False
For Each oProp In oCProps
If oProp.Name = oUParam.Name Then
oProp.Value = oUParam.Value
oExists = True
End If
Next
If oExists = False Then
oCProps.Add(oUParam.Value, oUParam.Name)
End If
Next
For Each oMParam In oMParams
'Checks to see if it has been renamed (Model Params always start with "d" then a number)
'If it has been renamed, it is probably important
If Left(oMParam.Name, 1) <> "d" Then
'Check if matching Custom iProperty exists. If not create it.
oExists = False
For Each oProp In oCProps
If oProp.Name = oMParam.Name Then
oProp.Value = oMParam.Value
oExists = True
End If
Next
If oExists = False Then
oCProps.Add(oMParam.Value, oMParam.Name)
End If
End If
Next
Also, here is a fairly helpful link to another post that shows creating different Types or iProperties.
https://forums.autodesk.com/t5/inventor-customization/need-to-retrieve-type-data-of-custom-iproperti...
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
- MessageBox, InputBox, and InputListBox Size & Format Options Click Here
- Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
- Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
- Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
- Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
- SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
- Create DocumentSubTypeEnum Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)