Running external rule in sub assemblies and parts.

Running external rule in sub assemblies and parts.

luke.scottWYFAG
Contributor Contributor
1,065 Views
3 Replies
Message 1 of 4

Running external rule in sub assemblies and parts.

luke.scottWYFAG
Contributor
Contributor

Hi all,

I have a simple bit of ilogic code that sets the Author within the summary tab of the  iProperties of a top level model to myself.

 

I would like to have this external rule run on all of the parts and sub assemblies that are within my top level file.

Im sure this is possible but after an afternoon of googling and reading this forum i have succeeded in confusing myself with the only thing to show for me efforts being a headache.

If anyone could help it would be most appreciated.

0 Likes
Accepted solutions (1)
1,066 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

If you have your external rule, you can run them on all documents at the first level of assembly via this code

Dim ruleName As String = "MyExternalRule"

Dim asm As AssemblyDocument = ThisDoc.Document
For Each doc As Document In asm.ReferencedDocuments
	iLogicVb.Automation.RunExternalRule(doc, ruleName)
Next
Message 3 of 4

A.Acheson
Mentor
Mentor

One question there. Are all these files going to be specifically modified by you and not in use in other projects where someone else might do the same thing on the same files? 

 

In this article All Referenced Documents would be the shortest bit of code needed to loop through the documents in your assembly. Written in vba so remove the lines starting with sub and end sub. Remove the word Set and change Debug.Print to Logger.Info to convert to ilogic. 

 

Then for the iproperty look at this article and piece together the iproperty you need. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 4

luke.scottWYFAG
Contributor
Contributor

great thank you Michael that was just what i was after.

 

Acheson, in this case its just going to be me doing the work on the parts (a few 100 at the moment so didn't want to do them all at once.

If it was a situation where we had multiple people working on the same file set then yes as you mentioned it wouldn't be the best solution. I will have a read through the link you posted as hopefully it will aid with things in the future.

 
0 Likes