open all levelidw assembly and Run an ilogic code on them. How do i do that ?

open all levelidw assembly and Run an ilogic code on them. How do i do that ?

Darkforce_the_ilogic_guy
Advisor Advisor
974 Views
2 Replies
Message 1 of 3

open all levelidw assembly and Run an ilogic code on them. How do i do that ?

Darkforce_the_ilogic_guy
Advisor
Advisor

is there a way to open all Drawing(.idw) one by one and  run an external rules on them and close without saving ?

I have this code that open the top drawing, but need to open them all

NewFileName = ThisDoc.ChangeExtension(".idw")

 

 

'open the indexed file, false opens the file without generating the graphics

ThisApplication.Documents.Open(NewFileName, True) 

 

And then I need to run

iLogicVB.RunExternalRule("SavePDF")

 

on each of the IDW

 

this will make an PDF of the Drawing and save it in an folder

 

 

 

 

 

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

WCrihfield
Mentor
Mentor

So, you want an External iLogic rule that you can run while you have the top level Assembly document open, that will search for the IDW files associated with this top level assembly document, every sub-assembly, every part, & every sub-assembly part, then run your other external rule for each instance found?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Darkforce_the_ilogic_guy
Advisor
Advisor
Accepted solution

 

Yes I ende up with this code

 

Sub PDFAssambly()
' Check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
    MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
    Exit Sub
End If

' Define the active document As an Assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)

'- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -
' Look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document

' Work the the drawing files for the referenced models
' This expects that the model has a drawing of the same path and name
For Each oRefDoc In oRefDocs
	
    idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -3) & "idw"
	
	'MessageBox.Show(idwPathName.ToString, "Title")

    ' Check to see that the model has a drawing of the same path and name
    If (System.IO.File.Exists(idwPathName)) Then
		'Dim atts As System.IO.FileAttributes = System.IO.File.GetAttributes(idwPathName)
		 'Dim ReadOnlyNow =atts.ReadOnly
		'MessageBox.Show(ReadOnlyNow.ToString, "Title")
		'atts =False

		
        Dim oDrawDoc As DrawingDocument
		'False Grafik off True Grafik on
        oDrawDoc = ThisApplication.Documents.Open(idwPathName, False)
		ThisApplication.Documents.Open(idwPathName, True) 
		Dim auto = iLogicVb.Automation
		auto.RunExternalRule(oDrawDoc, "SavePDF")
		
oDrawDoc.Close


		

            End If
Next

 

 

 

0 Likes