Hi.
I am trying to create a code based on this (Provided in another thread by Curtis Waguespac)
oName = InputBox("Enter a Name", "iLogic", "FrameWork") ' set a reference to the assembly component definintion. ' This assumes an assembly document is open. Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition i=0 'Iterate through all of the occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences i=i+1 oOccurrence.Name = oName & ":" & i Next
It works great, but I need it to change the name but not the occurrence number.
Kinda like this:
Names of part files:
One type name:1
One type name:2
One type name:3
One type name:4
Another type name:1
Another type name:2
Another type name:3
Yet another type name:1
Yet another type name:2
Yet another type name:3
to
Framework:1
Framework:2
Framework:3
Framework:4
Framework:1
Framework:2
Framework:3
Framework:1
Framework:2
Framework:3
I found some codes that can separate the name from the number, but can figure out how to make it work properly,
Any help would really be appreciated 🙂
Solved! Go to Solution.
Solved by bshbsh. Go to Solution.
Ops, sorry.
I see I must have been a bit in a rush and a bit tired when writing the examples.
Let me show with real part name scenario
Names of part files:
300_001:1
300_001:2
300_001:3
300_001:4
100_001:1
100_001:2
100_001:3
300_002:1
300_002:2
300_002:3
to
Framework_001:1
Framework_001:2
Framework_001:3
Framework_001:4
Framework_002:1
Framework_002:2
Framework_002:3
Framework_003:1
Framework_003:2
Framework_003:3
I ultimately would like to be able to rename what is in front of the underscore, and keep in.ex _001:1 & _001:2 etc.
I have seen some solutions on this forum but not quite what I have had in mind, this is the closest I have seen:
I believe the solution is mentioned in that thread (?), but I can't see anyone actually posting a full code, just parts of the code.
I am unfortunately not as advanced in iLogic coding that I have managed to edit the scripts to suit my needs...yet 🙂
Ultimately a script that could do something similar to this function, just with browser occurrences:
you could use the InStr() function in occurrence names (strings) to find if it contains any substring. You could also use the Replace() string function to replace any part of a string if it mathces a given pattern or substring you specify.
But in your case it seems like you always replace something in the beginning of the name, the part to the left of the first underscore, so I used the Left function instead.
Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences If InStr(oOccurrence.Name, "_") > 0 Then oOccurrence.Name = Replace(oOccurrence.Name, Left(oOccurrence.Name, InStr(oOccurrence.Name, "_")), "Framework_") End If Next
hope that helps.
Can't find what you're looking for? Ask the community or share your knowledge.