Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
I want to change the name to default as in the picture.
How can it be done with ilogic?
Thanks
Solved! Go to Solution.
Hi.
I want to change the name to default as in the picture.
How can it be done with ilogic?
Thanks
Solved! Go to Solution.
Here you go:
Dim oDoc As Document = ThisApplication.ActiveDocument oDoc.DisplayName = ""
How would you do this for subassemblies within an assembly and their parts??
Hey, like this:
Sub Main() Dim oDoc As Document = ThisApplication.ActiveDocument
oDoc.DisplayName = "" Dim oCD As ComponentDefinition = oDoc.ComponentDefinition NameReset(oCD.Occurrences) End Sub Sub NameReset(oOccs As ComponentOccurrences) For Each oOcc As ComponentOccurrence In oOccs Try oOcc.Name = "" NameReset(oOcc.SubOccurrences) Catch End Try Next End Sub
Thanks for the reply but that doesn't quite do it......
That does the top level assembly and the first sub assembly in the tree but none of the parts or subsequent subassemblies - see attached snapshot with Dave and Bob as example names.
Hey, this rule is for name reset only (.Name = "").
The issue you run into is that you can't have 2+ assemblies (parts, etc.) with the exact same name (it's simply not allowed by Inventor).
You'd have to add something like ":1", ":2" at the end of the name.
I understand its for resetting the name - I just "bob" and "dave" in there so you could see what the code was doing.
All the subassemblies do have unique file names and so do all their parts. Just so I understand is the code you've written only meant to look at one sub assembly or is it meant to go through all the sub assemblies within an assembly?
Thanks!
It's supposed to reset the names of all sub-assemblies, sub-parts (sub-sub-assemblies and parts etc.) aka parts and assies of all levels.
You can try it like this, to see any errors (it might fail to rename something if it's read-only or something.):
Sub Main() Dim oDoc As Document = ThisApplication.ActiveDocument
oDoc.DisplayName = "" Dim oCD As ComponentDefinition = oDoc.ComponentDefinition NameReset(oCD.Occurrences) End Sub Sub NameReset(oOccs As ComponentOccurrences) For Each oOcc As ComponentOccurrence In oOccs Try oOcc.Name = ""
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try NameReset(oOcc.SubOccurrences) Catch End Try Next End Sub
Also are these assies iAssemblies by any chance? I haven't tested it with them, so I'm not sure if it would work properly.