Hello Inventor Forum
I have linked parameters in multiple documents and would like to delete the link through an iLogic rule. The imported parameters are supposed to become user defined parameters without any external references, much like when using the manual "delete folder" command in the parameters window. I do not care for the exportparameter flag in the originating file, unless the solution necessitates changing it.
Is there an easy way to do this? I can't seem to find the right function. I'm running Inventor 2016 SP1.
Solved! Go to Solution.
Solved by martin_winkler. Go to Solution.
Solved by b_sharanraj. Go to Solution.
Try the below Code 🙂
Option Explicit Sub Main() Dim Param As Parameter Dim Param_Expression As String Dim Param_Units As String Dim Usr_Params As UserParameters Dim Der_Param_Table As DerivedParameterTable Dim i As Integer i = 1 For Each Der_Param_Table In ThisApplication.ActiveDocument.ComponentDefinition.Parameters.DerivedParameterTables For Each Param In ThisApplication.ActiveDocument.ComponentDefinition.Parameters.DerivedParameterTables.Item(i).DerivedParameters Param_Expression = AlphaNumericOnly(Param.Expression) MsgBox(Param_Expression) Param_Units = Param.Units Param = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters.AddByExpression("Temp_" & Param.Name, Param_Expression, Param_Units) Next i = i + 1 Next For Each Der_Param_Table In ThisApplication.ActiveDocument.ComponentDefinition.Parameters.DerivedParameterTables ThisApplication.ActiveDocument.ComponentDefinition.Parameters.DerivedParameterTables.Item(1).Delete Next For Each Param In ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters If InStr(Param.Name, "Temp_") = 1 Then Param.Name = Right(Param.Name, Len(Param.Name) - 5) End If Next End Sub Function AlphaNumericOnly(strSource As String) As String Dim i As Integer Dim strResult As String For i = 1 To Len(strSource) Select Case Asc(Mid(strSource, i, 1)) Case 46, 48 To 57: strResult = strResult & Mid(strSource, i, 1) End Select Next AlphaNumericOnly = strResult End Function
Regards
B.Sharan Raj
Hi Chris,
if you only want to delete the derived tables try this:
Option Explicit Sub Main() Dim oPart As PartDocument oPart = ThisApplication.ActiveDocument Dim oParams As Parameters Dim oDevParam As DerivedParameter 'Get Parameter Tables oParams = oPart.ComponentDefinition.Parameters 'check id there is a derived table If oParams.DerivedParameterTables.Count > 0 Then For Each oDevTable In oParams.DerivedParameterTables
'Kopie Parameters to User Parameters '! This not necessary if the derived parameters are used in the model parameters ' then they will be copied automatically For Each oDevParam in oDevTable.DerivedParameters 'Copy Method from B.Sharan Raj Next If oDevTable.HasReferenceComponent = False Then 'delete all linked tables oDevTable.Delete End If Next End If End Sub
When derived parameters are used in model parameters inventor copies them automatically into the user parameters when the derived table is deleted.
Otherwise they are lost.
If you want to copy all of the derived parameters to user parameters look at the code from B.Sharan Raj.
Hi B.Sharan Raj, Hi Martin
I've tested both rules and they seem to do exactly what I need. In retrospect I see that my description was somewhat vague, since, I only need the parameters that are actually being used in the active document. Thus, in my current case, the second one is the one I'm going to be using. The first one however will surely come in handy at a later point in time.
Thank you very much!