Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic rule - Add Description value after file name for Member display Name only

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
mbodnar
2062 Views, 8 Replies

iLogic rule - Add Description value after file name for Member display Name only

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

8 REPLIES 8
Message 2 of 9
Curtis_Waguespack
in reply to: mbodnar

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

 

Message 3 of 9
mbodnar
in reply to: Curtis_Waguespack

Hi Chris

 

Thank you very much, exactly what I was after. Smiley Happy

 

Max B

Message 4 of 9
mbodnar
in reply to: Curtis_Waguespack

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

Message 5 of 9
Curtis_Waguespack
in reply to: mbodnar

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

 

Message 6 of 9
mbodnar
in reply to: Curtis_Waguespack

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

Message 7 of 9
Curtis_Waguespack
in reply to: mbodnar

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

 

Message 8 of 9

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?? 

Message 9 of 9
dberrie
in reply to: Curtis_Waguespack

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report