The component name is the same after replacement

The component name is the same after replacement

Anonymous
Not applicable
605 Views
3 Replies
Message 1 of 4

The component name is the same after replacement

Anonymous
Not applicable

Hello,

 

I have a really strange problem. I use a rule for replacing.

 

Exactly that:

 

My_Variable2 = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name

 

If NUMBER_OF_FANS = 1 And SIZE = "S" And CS_or_LS = "Triangolare" Then
Component.Replace(My_Variable2, "30084127.ipt", True)

 

The first component will be replaced but the component name doesn`t change.

 

Do you have any idea, what could be the problem? 

 

Many Thanks

Janos

0 Likes
606 Views
3 Replies
Replies (3)
Message 2 of 4

cbenner
Mentor
Mentor

@Anonymous wrote:

Hello,

 

I have a really strange problem. I use a rule for replacing.

 

Exactly that:

 

My_Variable2 = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name

 

If NUMBER_OF_FANS = 1 And SIZE = "S" And CS_or_LS = "Triangolare" Then
Component.Replace(My_Variable2, "30084127.ipt", True)

 

The first component will be replaced but the component name doesn`t change.

 

Do you have any idea, what could be the problem? 

 

Many Thanks

Janos


@Anonymous

 

It may be just the browser "instance" name that is not changing.  Look at the iProperties of the component and verify that it is indeed the correct part (file name, path location etc).  If the part is correct, it is just the browser name that did not change, you can manually rename that to whatever you need without affecting the filename of the part.  Do a "slow" double click on the instance name like you would in Windows Explorer if you were renaming a file.

0 Likes
Message 3 of 4

Curtis_Waguespack
Consultant
Consultant

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

EESignature

Message 4 of 4

dankle43
Enthusiast
Enthusiast

If it is just your browser names and there are multiply of them inventor has a feature to rename all of them at once.  See attached.

0 Likes