Hello folks, I have a problem that may be of interest to quite a few others. The problem is that when you place an iLogic Assembly –the program appends all of the file names with a dash and a number –which solves the duplicate file name problem, but will destroy any code used at the assembly level to configure the parts and subassemblies contained within.
What I am looking for is code that will return the names of the components in an assembly so that I can assign them to variables. For instance, a part named Bottom.ipt would be assigned a variable name of Bottom, and any part name that starts with “Bottom” –no matter what is appended to it, would be assigned to the variable in that particular instance of the assembly i.e. Bottom = “Bottom-08.ipt”. This way the code would never brake as it does now due to the auto renaming.
I am also looking for a way to mark some of the parts and sub assemblies as purchased components that are not renamed, but just instanced as normally placed parts are, but that can wait.
Any help would be greatly appreciated.
Thanks much theo. bot! I had come up with renaming the browser nodes via iLogic code upon placement. It does the same thing but in a very round-about way! It never even crossed my mind that it was as simple as changing the nodes right from the get-go.
Thanks again theo.bot!
Mark Randa
Hi MRanda
How did you solve this problem.Do I need to write a code for it? .Could you please tell in detail?
Kind regards,
@MRanda wrote:Hello folks, I have a problem that may be of interest to quite a few others. The problem is that when you place an iLogic Assembly –the program appends all of the file names with a dash and a number –which solves the duplicate file name problem, but will destroy any code used at the assembly level to configure the parts and subassemblies contained within.
What I am looking for is code that will return the names of the components in an assembly so that I can assign them to variables. For instance, a part named Bottom.ipt would be assigned a variable name of Bottom, and any part name that starts with “Bottom” –no matter what is appended to it, would be assigned to the variable in that particular instance of the assembly i.e. Bottom = “Bottom-08.ipt”. This way the code would never brake as it does now due to the auto renaming.
I am also looking for a way to mark some of the parts and sub assemblies as purchased components that are not renamed, but just instanced as normally placed parts are, but that can wait.
Any help would be greatly appreciated.
Hi MRanda
Please find the attached code which renames the Browser nodes, i use this on every iLogic assembly i create.
The credit for the original rule needs to go to Cadline.
'Start of iLogic code ' This rule will 'Stabilise' the first level assembly browser nodes by renaming them and then ' renaming back to the previous node name. It can be run at any point in the design process, ' before any copying of assemblies is done, and the post-copied assembly browser nodes will remain ' unchanged - (allowing iLogic rules to function) ' Check this file is an assembly Checkdoc = ThisDoc.ModelDocument If Checkdoc.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule can only be run in an assembly file!", "iLogic") Return End If Dim doc As Document Dim oDef As AssemblyComponentDefinition = Checkdoc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence Count = 1 For Each oCompOcc In oDef.Occurrences If oCompOcc.Suppressed = False Then doc = oCompOcc.Definition.Document ' Store current component name CurrentName = oCompOcc.Name ' Set a random name for occurence oCompOcc.Name = Count & "Pauls_iLogic" ' Update InventorVb.DocumentUpdate() ' Reset component name to previous name oCompOcc.Name = CurrentName End If Count = Count + 1 Next