Running Ilogic Assembly Level step file generator code I found, how do I stop it from saving factory and member parts?

Running Ilogic Assembly Level step file generator code I found, how do I stop it from saving factory and member parts?

smeyer
Participant Participant
333 Views
1 Reply
Message 1 of 2

Running Ilogic Assembly Level step file generator code I found, how do I stop it from saving factory and member parts?

smeyer
Participant
Participant

Hello,

 

I'm experimenting with the code from this website, http://blog.ads-sol.com/2016/01/batch-assembly-export.html

 

Is there a way to make it only spit out the member files, not member and factory? Any insight is appreciated. I do have some VB.net and ilogic exposure. My Internet searches have yielded nada. I've found other adaptions of this code but not addressing the saving of factory and member files. 

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = ThisDoc.FileName(False) 'without extension

If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
    MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
    Exit Sub
End If
'get user input
RUsure = MessageBox.Show ( _
"This will create a STEP file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create STEP Drawings for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output STEPs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
    Return
Else
End If
'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
oPath = ThisDoc.Path
'get STEP target folder path
oFolder = oPath & "\" & oAsmName & " STEP Files"

'get the document revision to use in the new filename
oRevNumAsm = iProperties.Value("Project", "Revision Number")

'Check for the step folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If


'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -
ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName & "_Rev" & oRevNumAsm &(".stp") , True)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'work the referenced models
For Each oRefDoc In oRefDocs
    Dim oCurFile As Document
    oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
    oCurFileName = oCurFile.FullFileName

   
    'defines backslash As the subdirectory separator
    Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar
   
    'find the postion of the last backslash in the path
    FNamePos = InStrRev(oCurFileName, "\", -1)  
    'get the file name with the file extension
    Name = Right(oCurFileName, Len(oCurFileName) - FNamePos)
    'get the file name (without extension)
    ShortName = Left(Name, Len(Name) - 4)
    oRevDoc = iProperties.Value(Name, "Project", "Revision Number")


    Try
        oCurFile.SaveAs(oFolder & "\" & ShortName & "_Rev" & oRevDoc & (".stp") , True)
    Catch
        MessageBox.Show("Error processing " & oCurFileName, "ilogic")
    End Try
    oCurFile.Close
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
'open the folder where the new files are saved
Shell("explorer.exe " & oFolder,vbNormalFocus)

 

0 Likes
334 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

You can check if referenced document is iPartFactory document

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

'...

Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'work the referenced models
For Each oRefDoc In oRefDocs
	Dim oCurFile As Document
	oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
	
	Dim oCurPart As PartDocument = TryCast(oCurFile, PartDocument)
	If oCurPart IsNot Nothing AndAlso oCurPart.ComponentDefinition.IsiPartFactory Then
		'This is iPart factory
		Logger.Info("This is iPart factory")
		continue for
	End If
	
	'...
		
Next
0 Likes