hexagon logo

SaveAs2 Function

There is a function available in the object library called "SaveAs2" which is supposed to allow you to save the part program with CAD as reference. I can't seem to get this to work. It saves the part program just fine but it also saves the CAD no matter what value I pass in the second argument. Has anyone else had any luck with this?

Function SaveAs2(Name As String, CadAsReference As Boolean) As Boolean
Member of PCDLRN.PartProgram
Saves the part program with the provided name. CadAsReference allows to save the CAD as reference to the original one
Parents
  • Can you post the code of how you passed the value to get it to work?

    I'm using 2013MR1 SP5. This script runs at the end of the program as the last action. I've added the Kill line to delete the CAD since I wasn't able to get the byref to work. It sounds like this might actually work better since I don't want the 1kb CAD file either. I just want no CAD file. Still curious why I couldn't get it to work.

    Dim App As Object
    Dim Part As Object
    Dim Cmds As Object
    Dim Cmd As Object
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Initializes PC-DMIS
    'Change History:
    'A (JS,8/24/14) : Code from A. Mavrov from PC-DMIS forum
    '
    '
    '
    '------------------------------------------------
    Sub Initialize()
    
    Set App = CreateObject("PCDLRN.Application")
        If App Is Nothing Then
            MsgBox "PC-DMIS initialization error!",48, "Error!"
            Exit Sub
        Else
            Set Part = App.ActivePartProgram
            If Part Is Nothing Then
                MsgBox "Part Program not opened!", 48, "Error!"
                Exit Sub
            Else
                Set Cmds = Part.Commands
                If Cmds Is Nothing Then
                    MsgBox "Pointer to commands not valid!", 48, "Error!"
                    Exit Sub
                End If
            End If
        End If
    
    End Sub
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Saves the Active Part Program To the Name And Path Passed. CAD is Deleted.
    'Change History:
    'A (JS,9/01/14) : Creation
    '
    '
    '
    '------------------------------------------------
    Sub PCDSaveAs(Path As String)
    
    Dim Bln As Boolean
    
    Bln = Part.SaveAs2(Path,True)
    
    Kill Path & ".CAD" 
    
    End Sub
    
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Saves the Active Part Program To the Name And Path Passed in from PC-DMIS. CAD is deleted.
    'Change History:
    'A (JS,9/01/14) : Creation
    '
    '------------------------------------------------
    Sub Main(Path As String)
    
    Call Initialize()
    Call PCDSaveAs(Path)
    
    'Cleanup
    Set Cmd = Nothing
    Set Cmds = Nothing
    Set Part = Nothing
    Set App = Nothing
    
    End Sub
Reply
  • Can you post the code of how you passed the value to get it to work?

    I'm using 2013MR1 SP5. This script runs at the end of the program as the last action. I've added the Kill line to delete the CAD since I wasn't able to get the byref to work. It sounds like this might actually work better since I don't want the 1kb CAD file either. I just want no CAD file. Still curious why I couldn't get it to work.

    Dim App As Object
    Dim Part As Object
    Dim Cmds As Object
    Dim Cmd As Object
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Initializes PC-DMIS
    'Change History:
    'A (JS,8/24/14) : Code from A. Mavrov from PC-DMIS forum
    '
    '
    '
    '------------------------------------------------
    Sub Initialize()
    
    Set App = CreateObject("PCDLRN.Application")
        If App Is Nothing Then
            MsgBox "PC-DMIS initialization error!",48, "Error!"
            Exit Sub
        Else
            Set Part = App.ActivePartProgram
            If Part Is Nothing Then
                MsgBox "Part Program not opened!", 48, "Error!"
                Exit Sub
            Else
                Set Cmds = Part.Commands
                If Cmds Is Nothing Then
                    MsgBox "Pointer to commands not valid!", 48, "Error!"
                    Exit Sub
                End If
            End If
        End If
    
    End Sub
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Saves the Active Part Program To the Name And Path Passed. CAD is Deleted.
    'Change History:
    'A (JS,9/01/14) : Creation
    '
    '
    '
    '------------------------------------------------
    Sub PCDSaveAs(Path As String)
    
    Dim Bln As Boolean
    
    Bln = Part.SaveAs2(Path,True)
    
    Kill Path & ".CAD" 
    
    End Sub
    
    
    '======================================================================================================================='------------------------------------------------
    
    'This Sub Saves the Active Part Program To the Name And Path Passed in from PC-DMIS. CAD is deleted.
    'Change History:
    'A (JS,9/01/14) : Creation
    '
    '------------------------------------------------
    Sub Main(Path As String)
    
    Call Initialize()
    Call PCDSaveAs(Path)
    
    'Cleanup
    Set Cmd = Nothing
    Set Cmds = Nothing
    Set Part = Nothing
    Set App = Nothing
    
    End Sub
Children
No Data