@JhoelForshav
Thank you for Providing the code you posted. it works well and i have not found any issues with it. Though I have added to it. Now I have a Global Form that can change what external rules are ran before it runs through the drawings. Next step will to have it check for views and update bend tables. then maybe run through parts and run some functions there as well, namely DXFing the parts. Bellow is the updated Code:
Sub Main
Dim oAsm As AssemblyDocument = ThisDoc.Document
If Parameter("Option1") = "True" Then
oOption1 = "T"
Else If Parameter("Option1") = "False" Then
oOption1 = "F"
End If
If Parameter("Option2") = "True" Then
oOption2 = "T"
Else If Parameter("Option2") = "False" Then
oOption2 = "F"
End If
If Parameter("Option3") = "True" Then
oOption3 = "T"
Else If Parameter("Option3") = "False" Then
oOption3 = "F"
End If
If Parameter("Option4") = "True" Then
oOption4 = "T"
Else If Parameter("Option4") = "False" Then
oOption4 = "F"
End If
If Parameter("Option5") = "True" Then
oOption5 = "T"
Else If Parameter("Option5") = "False" Then
oOption5 = "F"
End If
If Parameter("Option6") = "True" Then
oOption6 = "T"
Else If Parameter("Option6") = "False" Then
oOption6 = "F"
End If
If Parameter("Option7") = "True" Then
oOption7 = "T"
Else If Parameter("Option7") = "False" Then
oOption7 = "F"
End If
For Each oRefDoc As Document In oAsm.AllReferencedDocuments
Dim oDrawingPath As String = FindDrawingFile(oRefDoc)
'Go to next if there is no drawing.
If oDrawingPath = "" Then Continue For
Dim oInfo As New System.IO.FileInfo(oDrawingPath)
'Go to next if drawing is readonly (checked in for example)
'Then you can't do much to it anyways.
If oInfo.IsReadOnly Then Continue For
Dim oDrawing As DrawingDocument = ThisApplication.Documents.Open(oDrawingPath, True)
For Each oSheet As Sheet In oDrawing.Sheets
oSheet.Activate
Select Case oOption1
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Center_Dimensions")
Case "F"
End Select
Select Case oOption2
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Precise_View")
Case "F"
End Select
Select Case oOption3
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Sort_and_Hide_Partlist")
Case "F"
End Select
Select Case oOption4
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Update_Balloons")
Case "F"
End Select
Select Case oOption5
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "View_Labels")
Case "F"
End Select
Select Case oOption6
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Clear_Revisions_Single")
Case "F"
End Select
Select Case oOption7
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Issued_For_Construction")
Case "F"
End Select
Select Case oOption1
Case "T"
iLogicVb.Automation.RunExternalRule(oDrawing, "Center_Dimensions")
Case "F"
End Select
Next
'Save and close the drawing
oDrawing.Save
oDrawing.Close
ThisApplication.UserInterfaceManager.DoEvents()
Next
End Sub
Function FindDrawingFile(PartOrAssemblyDoc As Document) As String
Dim fullFilename As String = PartOrAssemblyDoc.FullFileName
Dim Path As String = System.IO.Path.GetFullPath(fullFilename)
Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(fullFilename)
Dim drawingFilename As String
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(Path, filename & ".dwg")
If drawingFilename = ""
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(Path, filename & ".idw")
If drawingFilename <> "" Then
Return drawingFilename
Else
Return ""
End If
Else
Return drawingFilename
End If
End Function
this is the code that creates the user parameters
Sub Main
Dim varAssDoc As AssemblyDocument
If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then
varAssDoc = ThisDoc.Document
oMyParameter = varAssDoc.ComponentDefinition.Parameters.UserParameters
'add parameters if they doesn't exist
Try
oParameter = oMyParameter("Option1")
Catch
oParameter = oMyParameter.AddByValue("Option1", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option2")
Catch
oParameter = oMyParameter.AddByValue("Option2", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option3")
Catch
oParameter = oMyParameter.AddByValue("Option3", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option4")
Catch
oParameter = oMyParameter.AddByValue("Option4", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option5")
Catch
oParameter = oMyParameter.AddByValue("Option5", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option6")
Catch
oParameter = oMyParameter.AddByValue("Option6", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option7")
Catch
oParameter = oMyParameter.AddByValue("Option7", True, "BOOLEAN")
End Try
Try
oParameter = oMyParameter("Option8")
Catch
oParameter = oMyParameter.AddByValue("Option8", True, "BOOLEAN")
End Try
Else:
MsgBox("Wrong Document Type", vbOKOnly, "Incorrect Document type")
End If
End Sub