Skip to content

Instantly share code, notes, and snippets.

@autokludge
Created August 25, 2021 08:28
Show Gist options
  • Save autokludge/47ac76270956bf1cb00190c21ec8c5da to your computer and use it in GitHub Desktop.
Save autokludge/47ac76270956bf1cb00190c21ec8c5da to your computer and use it in GitHub Desktop.
set length user parameter (untested)
Sub Main
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
'Iterate through all of the referenced documents
For Each doc As Document In asmDoc.AllReferencedDocuments
'update the components
If doc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
AddLengthParameter(doc)
End If
Next
End Sub
Sub AddLengthParameter(oDoc As PartDocument)
'Get the user parameters collection.
Dim userParams As UserParameters = oDoc.ComponentDefinition.Parameters.UserParameters
Dim param As Parameter
'Set/create parameter
Try
param = userParams.Item("Length")
param.Expression = "B_L"
Catch
'The parameter doesn't exist so add it.
param = userParams.AddByExpression("Length", "B_L", UnitsTypeEnum.kDefaultDisplayLengthUnits)
End Try
param.ExposedAsProperty = true
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment