Message 1 of 2
Create custom iproperty on bolted part
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I have a problem with illogic, I created a rule to add a custom iproperty on each part of my assembly, this iproperty is a “material code” depending of the material of the part.
To do this, I search for the material in an excel file and gets the row number. All works great, the iproperty is created in all my parts, except when I have a bolted connection, in this case I receive this error:
this is my code:
openDoc = ThisApplication.ActiveDocument Dim docFile As Document ' Dim Parts As New ArrayList For Each docFile In openDoc.AllReferencedDocuments ' Parts.Add(docFile.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value) ''''se busca el material en la tabla de excel y se guarda en i el numero de fila donde se encontro ''''search the material into the excel file, returns the row number i = GoExcel.FindRow("D:\OneDrive - COMPUSOLUCIONES Y ASOCIADOS S.A. DE C.V\Autodesk\Productos\Inventor\reglas ilogic\tabla materiales.xlsx", "Hoja1", "mat", "=", docFile.PropertySets.Item("Design Tracking Properties").Item("Material").Value) '''' si no se encuentra el material regresa como resultado -1, en este caso cambia el valor de i a 2, el cual corresponde a la fila de "material no esta en el catalogo" '''' if the material doesnt' exist in the excel file, the previous step return -1, here I change this for 2 where I have the message "not found" If i<1 Then i = 2 End If '''' Se busca la celda que contiene el codigo y se guarda su valor en la variable "Code" '''' save the value of the cell in the "Code" variable Dim Code As String=GoExcel.CellValue("D:\OneDrive - COMPUSOLUCIONES Y ASOCIADOS S.A. DE C.V\Autodesk\Productos\Inventor\reglas ilogic\tabla materiales.xlsx","Hoja1","B"&i) '''' Se revisa que la iproperty personalizada este creada y se asigna el valor de la variable Code, en caso de que no exista, se crea. '''' Set or create the custom iproperty for this part Dim invCustomPropertySet As PropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") Try Dim matprop As Inventor.Property = invCustomPropertySet.Item("MatCode") matprop.Value=Code Catch Call invCustomPropertySet.Add(Code, "MatCode") End Try Next
I made some test with msgbox, and the problem seems to be on the "Try - Catch" segment.
And, if is not possible to create the property , how can I ignore this parts?
I hope you can help me
P.D. sorry for my bad English.