Hi All
Does anyone know if possible to write the following rule using iLogic
If default Description field has a value for example "PLATE"
make the MemberDisplayName = Filename_Description (ie. 1234_PLATE)
If default Description field has empty value
Do nothing
I dont want to change the file name from whatever file name is assigned by user (ie. 1234.ipt) but simply change the MemberDiplayName to append Description value
If possible, can you share example code of how this could be achieved
Thanks
Max B
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi mbodnar,
Here is a quick iLogic rule that should work for you.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
doc = ThisDoc.Document Filename_Description = iProperties.Value("Project", "Part Number") _ & "_" & iProperties.Value("Project", "Description") 'check for a description iProperty value 'Trim removes spaces in case the description is just a space If Trim(iProperties.Value("Project", "Description")) <> "" Then 'set the display name doc.DisplayName = Filename_Description Else 'reset the display name doc.DisplayName = "" End If
Hi Curtis
I was wondering if you could provide some additional syntax to the original iLogic rule below
This runs fine at the part level but looking at a way to run all rules at the part level from the assembly level
We have a scenario where we use Vault copy design to copy assemblies and parts, then rename
On open, the old file names are displayed and each part needs to be opend individually to run the rule to update the display name to contain new file name
Would this be possibel to run once thru a rule from the assembly level?
Thanks
Max Bodnar
Hi mbodnar,
Here is a variation of this that can be run from the assembly to udpate all of the components. I didn't have a chance to test it well, so post back if you run into issues, but it seemed to work well in the limited testing I did.
I would recomend making this an external rule:
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document iLogicVb.UpdateWhenDone = True 'Look at all of the files referenced in the open document Dim docFile As Document For Each docFile In openDoc.AllReferencedDocuments 'format file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) Filename_Description = iProperties.Value(docFName, "Project", "Part Number") _ & "_" & iProperties.Value(docFName, "Project", "Description") 'check for a description iProperty value 'Trim removes spaces in case the description is just a space If Trim(iProperties.Value(docFName, "Project", "Description")) <> "" Then 'set the display name docFile.DisplayName = Filename_Description Else 'reset the display name docFile.DisplayName = "" End If Next
Hi Curtis
Thanks very much that works great!!
Do you know if it is possible to exclude certain components from running this rule on, for example Content Center Files?
Currently it flags all files and I have a workaround, but if the rule can exclude CC parts, that would be mcuh better
Cheers
Max Bodnar
Hi mbodnar,
Here is a quick example rule that looks at the parts (and only the parts) in the assembly and determines if it is a content center part.
'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document 'Look at all of the files referenced in the open document Dim docFile As Document For Each docFile In openDoc.AllReferencedDocuments 'format file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'check for part files only If docFile.DocumentType = kPartDocumentObject Then 'check for Conent Center Part If docFile.ComponentDefinition.IsContentMember = True Then MessageBox.Show("This is a Content Center part. ", docFName ) Else MessageBox.Show("This is NOT a Content Center part. ", docFName ) End If Else End If Next
Hi Curtis,
Just came across this post and your rule does exactly what I need it too in terms of renaming all the parts in an assembly. What would be amazing is to go one step further and for the rule to be able to do sub assemblies as well. At the moment if you run the rule in a top level assembly with sub-assemblies it successfully goes through and renames all the parts in the sub-assemblies but doesn't rename the sub-assemblies themselves. Is that an easy extra step to take??
Hi
Would it be possible to have a code that shows the File Name(as the part is saved) and the Description displayed in brackets in the model tree.
Thanks