Create custom iproperty on bolted part

Create custom iproperty on bolted part

LeoAlatorre
Collaborator Collaborator
399 Views
1 Reply
Message 1 of 2

Create custom iproperty on bolted part

LeoAlatorre
Collaborator
Collaborator

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:

 error.pngerror2.png

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.

Leonardo Alatorre Zavala
¿Te resultó útil esta publicación? No dudes en darle Me gusta a esta publicación.
¿Tu pregunta fue respondida exitosamente? Luego haga clic en el botón ACEPTAR SOLUCIÓN.

EESignature

YouTube | LinkedIn
0 Likes
400 Views
1 Reply
Reply (1)
Message 2 of 2

clutsa
Collaborator
Collaborator

Is "203-021-01.iam" set to "read only" or was it created from a content center? 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes