Message 1 of 2
Adding UserParameter out of Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I want to add a user parameter with a multi value list to every part in an assembly. My code adds the parameter but doesn't add the list. I've tried some things but did not find a solution for this.
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) Dim oTester As String Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document For Each oRefDoc In oRefDocs oDocPathName = oRefDoc.FullDocumentName If oDocPathName.StartsWith("U:\Paletti Norm") Else oPartDoc = ThisApplication.Documents.Open(oDocPathName, True) oPartDoc.Activate oPartDoc = ThisApplication.ActiveDocument oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters Try oTester = oMyParameter.Item("Bauteiltyp") oPartDoc.Close(True) Catch oParameter = oMyParameter.AddByValue("Bauteiltyp", "Standard", UnitsTypeEnum.kTextUnits) MultiValue.SetList("Bauteiltyp", "Standard", "ZUKAUF", "ROHSTOFF", "FORMKÖRPER D", "FORMKÖRPER F", "FORMKÖRPER P") Dim userParams As UserParameters Dim param As Parameter userParams = oPartDoc.ComponentDefinition.Parameters.UserParameters For Each oPara As Parameter In userParams Dim oName As String = oPara.Name If oName = "Bauteiltyp_1" Then oPara.Delete End If Next oPartDoc.Close(True) End Try End If Next
This is the code I am using so far.