Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello together,
i created a code that tooks an virtual component from an excel file. The problem that i have is, if the component allready exists, i get an error. How can i fix that problem? If compnent exist, delete it and place an new one in... but i dont know, how.
Thank you in advance
Regards
Martin
Dim retVal Dim Menge As String = "Menge" GoExcel.Open("c:\iproperties\iproperties.xlsx", "data") Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix Dim oOcc As ComponentOccurrence 'oOcc = oAsm.ComponentDefinition.Occurrences.AddVirtual("EXAMPLE", oMatrix) oOcc = oAsm.ComponentDefinition.Occurrences.AddVirtual(GoExcel.CellValue("Z2"), oMatrix) Dim oCompDefVirtual As VirtualComponentDefinition = oOcc.Definition 'CREATE AND SET THE IPROP Dim oPropertySet As PropertySet = oCompDefVirtual.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") iProperties.Value(GoExcel.CellValue("Z2") & ":1","Summary", "Title")=GoExcel.CellValue("AA2") iProperties.Value(GoExcel.CellValue("Z2") & ":1","Summary", "Subject")=GoExcel.CellValue("BB2") iProperties.Value(GoExcel.CellValue("Z2") & ":1","Summary", "Author")=GoExcel.CellValue("Z2") iProperties.Value(GoExcel.CellValue("Z2") & ":1","Summary", "Manager")=GoExcel.CellValue("AF2") iProperties.Value(GoExcel.CellValue("Z2") & ":1","Project", "Description")=GoExcel.CellValue("AA2") + " " + GoExcel.CellValue("BB2") customPropertySet = ThisDoc.Document.PropertySets.Item _ ("Inventor User Defined Properties") Try prop= customPropertySet.Item(Menge) Catch customPropertySet.Add("", Menge) End Try Menge = InputBox("Bitte die Menge eingeben, z.B. 2,5", "iLogic", iProperties.Value("Custom", "Menge"))
Solved! Go to Solution.