External rule to delete all rules in active directory

External rule to delete all rules in active directory

klemen.brezavscek
Contributor Contributor
435 Views
3 Replies
Message 1 of 4

External rule to delete all rules in active directory

klemen.brezavscek
Contributor
Contributor

Hello!

 

I'm looking for an external rule that I can run.

It would look for all parts and assemblies in active directory and run a command similar to 

iLogicVb.Automation.DeleteAllRulesInDocument()

Can someone please help me?

Thanks a lot!

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @klemen.brezavscek.  Here is an iLogic rule you can use for that task.

This rule lets you select a folder to process.  It also contains an option of whether to just process the files in that folder, or to process files in all levels of sub folders too.  I have it set to just process the top directory right now.

 

AddReference "System.IO"
Imports System.Windows.Forms
Imports System.Drawing
Imports System.IO
Dim oSFolder As String
Dim oFDialog As New FolderBrowserDialog
oFDialog.Description = "SELECT DIRECTORY TO PROCESS."
oFDialog.RootFolder = System.Environment.SpecialFolder.MyComputer
oResult = oFDialog.ShowDialog
If oResult = DialogResult.OK And
	oFDialog.SelectedPath <> "" Then
	oSFolder = oFDialog.SelectedPath
Else
	Exit Sub
End If
'MsgBox(oSFolder)
oFiles = System.IO.Directory.EnumerateFiles(oSFolder, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where(Function(s) _
s.ToLower.EndsWith(".ipt") Or s.ToLower.EndsWith(".iam"))
For Each oFile In oFiles
'	MsgBox("oFile = " & oFile,,"")
	Dim oDoc As Document = Nothing
	oDoc = ThisApplication.Documents.Open(oFile, False)
	iLogicVb.Automation.DeleteAllRulesInDocument(oDoc)
	oDoc.Save2(False)
	oDoc.ReleaseReference
Next
ThisApplication.Documents.CloseAll(True) 'True = unreferenced documents only

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

klemen.brezavscek
Contributor
Contributor

In order to also include all subfolders, i need to change this line, right:

System.IO.SearchOption.TopDirectoryOnly

to this:

System.IO.SearchOption.AllDirectories

 

Message 4 of 4

klemen.brezavscek
Contributor
Contributor

It worked great!! Thanks!

0 Likes