Hi janos.buczko,
Welcome to the forum.
Just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
As cbenner mentioned, the likely cause of this is that the browser name is overridden, when working with ilogic or other programming customization, we often "stabalize" the browser names in an assembly, so that the code is sure to find the expected component.
However, if you're looking to reset the browser name from the override, back to the default you can just clear it by setting it to be nothing. Do do so via code you can just add this line:
ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name = ""
So in the example you'd add this line similar to this:
'get component name
My_Variable2 = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name
'replace component based on condition
If NUMBER_OF_FANS = 1 And SIZE = "S" And CS_or_LS = "Triangolare" Then
'true replaces all instances of the component
'False replaced only the one specified
Component.Replace(My_Variable2, "C:\TEMP\30084127.ipt", True)
'reset browser name
ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name = ""
End If
If you're looking to rename or reestablish the name, then you'd do something like this:
'get component name
My_Variable2 = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name
'replace component based on condition
If NUMBER_OF_FANS = 1 And SIZE = "S" And CS_or_LS = "Triangolare" Then
'true replaces all instances of the component
'False replaced only the one specified
Component.Replace(My_Variable2, "C:\TEMP\30084127.ipt", True)
'reset browser name
ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name = "MyWidget"
End If
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com