Run rule based on file name

Run rule based on file name

josephcooley
Advocate Advocate
295 Views
2 Replies
Message 1 of 3

Run rule based on file name

josephcooley
Advocate
Advocate

I have a rule that reminds people to update the material when they save the file:

 

materialName = ThisDoc.Document.ComponentDefinition.Material.Name
If materialName = "Generic" Then
	Dim msg = String.Format("Please update material in {0}", ThisDoc.Document.DisplayName)
	MessageBox.Show(msg, "Generic Material")
End If
iLogicVb.UpdateWhenDone = True

 I would like to have this rule not run when it is using tube and pipe and frame generator parts, that dont have a material.  For example when it detects "route", or "skeleton" in the file name.

0 Likes
Accepted solutions (1)
296 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @josephcooley.  If you want to do this by checking file name, you can try this:

oDoc = ThisDoc.Document
oFileName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
If oFileName.Contains("route") Or oFileName.Contains("skeleton") Then Return
materialName = oDoc.ComponentDefinition.Material.Name
If materialName = "Generic" Then
	Dim msg = String.Format("Please update material in {0}", oDoc.DisplayName)
	MessageBox.Show(msg, "Generic Material")
End If
oDoc.Update

...Otherwise it is more complicated to tell if a part was generated from tube & pipe add-in.  There is a property of the document called DocumentInterests that I believe will contain a reference to the tube & pipe add-in's ClientId or name, if it was involved.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

josephcooley
Advocate
Advocate

thanks that worked great!

0 Likes