Ilogic - run external run from assembly in each newly created idw

Ilogic - run external run from assembly in each newly created idw

Anonymous
Not applicable
558 Views
3 Replies
Message 1 of 4

Ilogic - run external run from assembly in each newly created idw

Anonymous
Not applicable

Hi

 

I have an ilogic rule that creates an idw of all files beginning with the same 3 numbers as the assembly.

 

I want to run another external rule in all of these newly created idw's from within the same rule.

 

Below is my rule:-

 

 SyntaxEditor Code Snippet

'Define the open document
Dim oDoc As Document
oDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document

ModelName = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
'MessageBox.Show(ModelName)

DP= Left(ModelName,3)
'MessageBox.Show(DP)


If Not ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then 
    Return
End If

For Each docFile In oDoc.AllReferencedDocuments

    Dim FileNameTemp As String = (Left (docFile.DisplayName, 3))
    If FileNameTemp.ToUpper = DP Then

    'open the indexed file
    'true opens the file normaly
    'false opens the file programatically without generating the graphics
    ThisApplication.Documents.Open(docFile.FullFileName, False)

    'zoom to front view all    
    iLogicVb.RunExternalRule("Apply front view")

    auto = iLogicVb.Automation
    
    auto.RunExternalRule(docFile,"Draw all from assembly1")            'run external rule on opened docFile
    'auto.RunExternalRule(docFile,"Draw all - Drawing rules2017")    'run external rule on opened docFile
    'you may also save And close this drawing document
    docFile.Save
    docFile.Close
    End If    
    
Next



iLogicVb.UpdateWhenDone = True

 

I want to run the rule "Draw all - Drawing rules 2017" in all the new idw's,(commented out) I think is is something to do with "docfile" maybe needs something with "ThisDrawing" in in?

0 Likes
559 Views
3 Replies
Replies (3)
Message 2 of 4

HermJan.Otterman
Advisor
Advisor

can't you put an "before save" trigger in you template to run the second extrenal rule?

so when the drawing document is saved, it will execute?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi 

 

Yes, but I was trying to avoid using event triggers.

 

 

0 Likes
Message 4 of 4

JoAntt
Enthusiast
Enthusiast

 

Sub Main
	
' Assembly
	Dim oAsmDoc As AssemblyDocument 
	oAsmDoc = ThisApplication.ActiveDocument 

' References
	Dim oRefDocs As DocumentsEnumerator 
	oRefDocs = oAsmDoc.AllReferencedDocuments 
	Dim rdoc as document
	For Each oRefDoc In oRefDocs
		
		If oRefDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then 
			
			rdoc = ThisApplication.Documents.Open(oRefDoc.FullFileName,True)
			maker(oRefDoc)
			rdoc.Close(True)

		End If
		
	Next 
	
	
End Sub


Public Function maker(odocc)
	
	Dim oDoc as Inventor.Document
	oDoc = odocc
	auto = iLogicVb.Automation
	
	auto.RunRule(oDoc,"RuleFileName")
	
End Function

 

0 Likes