- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sure. There are lots of ways of doing these things, but there is some iLogic code you can use as a starter. It will try to find both the user parameter and the iProperty, then prepare a report about if they are found, what their values are, and if their values are equal. I also left some code commented out that will attempt to copy the value of the iProperty to the value of the user parameter if the iProperty is found. And if the user parameter does not exist yet, it creates it with the same value as the iProperty. You can un-comment that if you want.
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub
Dim oPartDoc As PartDocument = ThisDoc.Document
oUParams = oPartDoc.ComponentDefinition.Parameters.UserParameters
Dim oUParam As UserParameter
For Each oUP As UserParameter In oUParams
If oUP.Name = "t" Then oUParam = oUP
Next
oCProps = oPartDoc.PropertySets.Item("Inventor User Defined Properties")
Dim oCProp As Inventor.Property
For Each oCP As Inventor.Property In oCProps
If oCP.Name = "t" Then oCProp = oCP
Next
Dim oReport As String
Dim oUPVal, oIPVal As String
If oUParam Is Nothing Then
oReport = "Parameter = (Not Found)"
Else
oUPVal = CStr(oUParam.Value)
oReport = "Parameter = " & oUPVal
End If
If oCProp Is Nothing Then
oReport = oReport & vbCrLf & "iProperty = (Not Found)"
Else
oIPVal = CStr(oCProp.Value)
oReport = oReport & vbCrLf & "iProperty = " & oIPVal
End If
If oUPVal = oIPVal Then
oReport = oReport & vbCrLf & "They Are Equal"
Else
oReport= oReport & vbCrLf & "They Are Not Equal"
End If
MsgBox(oReport, , "")
'If oUParam IsNot Nothing And oCProp IsNot Nothing Then
' oUParam.Value = oIPVal
'ElseIf oUParam Is Nothing And oCProp IsNot Nothing Then
' oUParam = oUParams.AddByValue("t", oIPVal)
'End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)