Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
lmc.engineering
in reply to: amarcoc

You can do pretty much what ever you can imagine up.. just a case of finding what you need to make it happen.

 

Here's something I've knocked up. Run it as an external rule. 

 

Version:1.0 StartHTML:00000145 EndHTML:00005278 StartFragment:00000294 EndFragment:00005246 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet

Sub Main()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oPart As ComponentOccurrence
Dim sRuleName As String = "My rule Name"
Line1 :
'''Pick part occurrence
oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Part")
	If oPart Is Nothing Then
		Exit Sub
	Else
		Dim oFileName As String = oPart.Definition.Document.FullFileName
		Dim oDoc As PartDocument = ThisApplication.Documents.Open(oFileName)
		auto = iLogicVb.Automation
			Try
			auto.RunRule(oDoc, sRuleName)
			Catch
				MessageBox.Show("Cannot find a rule with the name " & sRuleName & "." & vbLf & "Please try again.", "Open and run")
			End Try
		'''Close the document with SAVE (as False), without SAVE (As True)
		oDoc.Close(False)
	
		Question = MessageBox.Show("Repeat Command?", "Open and run", MessageBoxButtons.OKCancel)
		If Question = vbOK Then
			''Repeat command
			GoTo Line1
		Else
			Exit Sub
		End If
	End If
End Sub