VB.Net addin save dxf problem

VB.Net addin save dxf problem

Anonymous
Not applicable
1,318 Views
3 Replies
Message 1 of 4

VB.Net addin save dxf problem

Anonymous
Not applicable

Hello,

I'm new to programming in VB.Net and trying to create an addin for inventor 2010 to auto save sheetmetal flat patterns as dxf,

after searching through old posts and reading the blog by Brian Eakins I have come up with the following code.

 The message boxes are there for debugging, and only seem to work as far as the first one. 

 

 Private Sub m_appEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_appEvents.OnSaveDocument


            'starting my code here////////////////////////////////////////////////////////

            If DocumentObject.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
                Dim invSheetMetalDoc As Inventor.PartDocument = CType(DocumentObject, Inventor.SheetMetalComponentDefinition)
                'MsgBox("test msg for debuging.", MsgBoxStyle.Information And MsgBoxStyle.OkOnly)


                ' if the flat exists.
                If invSheetMetalDoc.FlatPattern Then
                    MsgBox("test msg for debuging.", MsgBoxStyle.Information And MsgBoxStyle.OkOnly)

                    ' Get the flat pattern.
                    'Dim invFlatPattern As FlatPattern
                    'invFlatPattern = invSheetMetalDoc.FlatPattern
                    ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                    'dxf code
                    Dim Dxf_Lasercut_dir As String

Any idea on how to get this to work? What am I missing.

Mark Yankey
 

0 Likes
1,319 Views
3 Replies
Replies (3)
Message 2 of 4

Mike.Wohletz
Collaborator
Collaborator

you can take what you have started and combine a little of what I have attached and make this work for what you want to do. 

 

 

Public Sub CreateDXFFile(ByVal invDoc As Inventor.Document, ByVal FilePath As String)

  

        Try
            ' Get the DataIO object.
            Dim oDataIO As Inventor.DataIO
            oDataIO = invDoc.ComponentDefinition.DataIO
            ' Build the string that defines the format of the DXF file.
            Dim sOut As String
            sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&BendLayer=Etch&BendDownLayer=Etch"
            ' Create the DXF file.
            oDataIO.WriteDataToFile(sOut, FilePath)
        Catch ex As Exception
            MsgBox("please make sure destination file name is not in use:" & vbCrLf _
                   & ex.Message)

        End Try

        
    End Sub

 

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks Mike,

I will give it a try this evening.

0 Likes
Message 4 of 4

Rene-J
Collaborator
Collaborator

Have you try this addin

 iFlatpatternExport Add-in

http://www.mcadforums.com/forums/viewtopic.php?f=3​4&t=11249

 

René J

 

 

 

0 Likes