- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a way (ilogic or VBA) to loop through user parameters and rename each with a prefix (see example)
"Belt_Width" >> "RD722_Belt_Width"
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Let's re-write this to make it more understandable:
I have a number of parameters (over 100) that I import to my designs. In this particular design, I have multiple variations of the same design being created in the same multi body solid. I need to be able to differentiate between the design parameters so it will be easier to debug and modify if required. What I am trying to do is to loop through a set of parameters (imported from xml) and give a prefix to them (i.e. try/catch to ensure previous prefixes aren't renamed).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I fingered it out. Thanks for the views. The following code will ask for a prefix string then loop through the existing user parameters and rename them. I will work on the if existed at a later time
Dim i As Integer Dim oTempString As String Dim oDoc As PartDocument = ThisDoc.Document Dim InputPrefix As String Dim myparam As String Dim NewName As String If oDoc.DocumentType = kPartDocumentObject Then Dim oPartCompDef As PartComponentDefinition = oDoc.ComponentDefinition myparam = InputBox("Enter Prefix", "Prefix", InputPrefix) Try For i = 1 To oPartCompDef.Parameters.UserParameters.Count oTempString = oPartCompDef.Parameters.UserParameters(i).Name NewName =myparam & "-" & oTempString oPartCompDef.Parameters.UserParameters(i).Name = NewName MsgBox(NewName) Next i Catch MsgBox("Parameter " & oPartCompDef.Parameters.UserParameters(i).Name & " could not be renamed to " & myparam & oTempString & vbCrLf & "Please check results.", MsgBoxStyle.Critical,"Rename User Parameters") End Try End If