Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
asmenut
in reply to: asmenut

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