Rule to publish the DXF from main assembly with description and part number

Rule to publish the DXF from main assembly with description and part number

Ahmed.shawkyXTZHN
Enthusiast Enthusiast
189 Views
2 Replies
Message 1 of 3

Rule to publish the DXF from main assembly with description and part number

Ahmed.shawkyXTZHN
Enthusiast
Enthusiast

Hi All , 

the below rule is generating step files through main assembly is there way to modify it to generate DXF for sheet metal parts, thanks.

 

'check that the active document is an assembly file
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
    MessageBox.Show("This Rule " & iLogicVb.RuleName & " only works on Assembly Files.", "WRONG DOCUMENT TYPE", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return
End If

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmName As String = ThisDoc.FileName(False) 'without extension


'get user input
Dim 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 - - - - - - - - - - - -
Dim oPath = ThisDoc.Path
'get STEP target folder path
' original => oFolder = oPath & "\" & oAsmName & " STEP Files"
Dim oFolder = oPath & "\STEP Files"
'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 & (".stp"), True)

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

    Dim oPropSets As PropertySets = oCurFile.PropertySets
    Dim oPropSet As PropertySet = oPropSets.Item("Design Tracking Properties")
    Dim oDescriptionValue As [Property] = oPropSet.Item("Description")


    Try
        oCurFile.SaveAs(oFolder & "\" & oDescriptionValue.Value & (".stp"), True)
    Catch
        MessageBox.Show("Error processing " & oCurFileName, "ilogic")
    End Try
    oCurFile.Close()
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
  

 

0 Likes
190 Views
2 Replies
Replies (2)
Message 2 of 3

Ahmed.shawkyXTZHN
Enthusiast
Enthusiast
Is it possible to publish the DXF with other code
0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Hi @Ahmed.shawkyXTZHN.  Yes, it is possible to run an iLogic rule that starts from an assembly and exports the DXF of the FlatPattern of every Sheet Metal part in the assembly.  There are lots of example of that type of codes here within this Inventor iLogic and VB.net Forum, if you just search around within it at other similar sounding posts.  There are lots of variations among them though, because everyone seems to want the resulting DXF files to be stored in different places, and everyone seems to want to use different settings in the actual export process, to achieve different outcomes.  If you export a sheet metal flat pattern DXF manually, how do you decide where the DXF file should be saved to?  And what options do you set within the Options dialog before exporting.  Here is a link to the online help page for the most popular DXF export method, which shows most of the options that are available to that code based export process.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes