Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

cncah

Verified Members
  • Posts

    37
  • Joined

  • Last visited

Posts posted by cncah

  1. Thanks for the reference Roger. I think that is close to what I'm looking for. I tried the RefreshOperationsManager command

    after setting the RefreshEnabled property to True, but it didn't work. I will research the API info to see if I can find a method that works.

    Thanks again for the help. I'll keep you posted as I'm able to find time to work on this project.

  2. Thanks Mick. I had thought about that but I figured that might cause extra processing time especially if there were a lot of 3D toolpaths. Here is what I ended up with:

    For i As Integer = 0 To UBound(ops)
       Dim op As Mastercam.Database.Operation = CType(ops(i), Mastercam.Database.Operation)
       If Not op Is Nothing Then
          If op.Type = 4 Then
             If op.Selected = False Then
                op.Selected = True
                op.Commit()
                op.Regenerate()
             End If
          Else
             If op.Selected = True Then
                op.Selected = False
                op.Commit()
                op.Regenerate()
             End If
          End If
       End If
    Next i
    

    I tried to only call the operation's change in selection if it was needed to keep the regenerate time to a minimum.

    Thanks again.

  3. Hello,

     

    I'm wondering if there is an API call that I'm missing when trying to unselect certain ops. I'm adding to a custom VB.Net Nethook.

    I'm looping through the list of operations and trying to unselect certain ones with this code:

    Dim ops As Array = Mastercam.Support.SearchManager.GetOperations().ToArray
    
    If ops.Length = 0 Then Exit Sub
    
    For i As Integer = 0 To UBound(ops)
        Dim op As Mastercam.Database.Operation = CType(ops(i), Mastercam.Database.Operation)
        If Not op Is Nothing Then
           If op.Type = 4 Then
              op.Selected = True
           Else
              op.Selected = False
           End If
           op.Commit()
        End If
    Next i
    

    Problem I'm running into is if I call op.Commit() then it marks the ops I want to unselect dirty. If I leave the op.Commit() code out then the code doesn't do anything.

    Am I missing something?

     

     

  4. Hello,

     

    I'm trying to add a switch in the header of our post that turn on Force Tool Change for every operation but am having trouble

    with getting it to come out right. I found this in the header:

     

    frcetoolch   : 1    #Force toolchange at each operation? 0 = No, 1 = Yes

     

    But I cannot find the variable: frcetoolch anywhere else in the post.

     

    My company uses a modified version of the MP Master. Any help would be appreciated. Thanks

  5. I'm trying to create a NetHook that will renumber levels like the "Renumber Tools" does in the toolpaths manager. The programmers here want

    to be able to renumber levels based on these options:

     

    All Levels

    Visible Levels

    Non Visible Levels

     

    I'm just trying to make sure the NetHook accounts for everything so I don't have to skip levels that don't have geometry or a name assigned to them.

  6. Hello,

     

    I'm starting a new NetHook and saw how to get a list of levels in a NetHook example project. But I was having trouble locating a way to get a list of all the levels even if they do not contain geometry or a name. Is there an API call for this? I've been looking through the API Reference Guide but have had trouble finding anything. Any help would be greatly appreciated. Thanks.

  7. Thanks Mick! I was missing the "SetChainArray". Only problem I'm having is this works for when I chain

    off of wire geometry that I draw myself in Mastercam or curves that I extract from the edges of the solid

    model, but it doesn't work if I chain directly from the solid itself. Is there a way of checking what kind of

    entity is used for the chain? Because right now it is deleting the chain if a solid edge is used.

  8. I am trying to reverse the chains, and before reversing the chains, store in a variable if the operation is using

    left or right cutter comp. Then after reversing the chain set the cutter comp back to what it was previously.

    This is what I have so far:

    Public Overrides Function Run(ByVal param As Integer) As MCamReturn
    
                'Make sure there are operations to modify
                Dim ops As Array = Mastercam.Support.SearchManager.GetOperations().ToArray
    
                If ops.Length = 0 Then
                    Debug.WriteLine("There Are No Operations To Modify")
                    Return MCamReturn.FunctionExit
                End If
    
                Dim bSelect As Boolean = False
    
                'Loop through all operations to see if there are any selected
                For i As Integer = 0 To UBound(ops)
                    Dim op As Mastercam.Database.Operation = CType(ops(i), Mastercam.Database.Operation)
                    If Not op Is Nothing Then
                        If op.Selected = True Then
                            bSelect = True
                            Exit For
                        End If
                    End If
                Next i
    
                'If there are no selected operations then let's exit
                If bSelect = False Then
                    Debug.WriteLine("There Are No Selected Operations To Modify")
                    Return MCamReturn.FunctionExit
                End If
    
                'Process all selected operations
                Dim bSuccess As Boolean = LoopThroughSelectedOps(ops)
    
                If bSuccess = True Then
                    MsgBox("Chains Reversed And Flipped")
                Else
                    MsgBox("Error Reversing Chains")
                End If
    
                Return MCamReturn.NoErrors
    
            End Function
    

    Here is the code from my module:

    Public Sub ReverseChains(ByVal OpToRegen As Mastercam.Database.Operation, ByVal chains As Array)
    
            If chains.Length = 0 Then Exit Sub
    
            For i As Integer = 0 To UBound(chains)
    
                Dim chain = CType(chains(i), Mastercam.Database.Chain)
    
                If chain.Direction = Mastercam.Database.Types.ChainDirectionType.Clockwise Then
                    chain.Direction = Mastercam.Database.Types.ChainDirectionType.CounterClockwise
                ElseIf chain.Direction = Mastercam.Database.Types.ChainDirectionType.CounterClockwise Then
                    chain.Direction = Mastercam.Database.Types.ChainDirectionType.Clockwise
                End If
    
                OpToRegen.Commit()
                OpToRegen.Regenerate()
    
            Next i
    
        End Sub
    
        Public Function LoopThroughSelectedOps(ByVal OpsToProcess As Array) As Boolean
    
            Dim TheAnswer As Boolean = False
    
            If OpsToProcess.Length = 0 Then
                TheAnswer = False
                Return TheAnswer
                Exit Function
            End If
    
            For i As Integer = 0 To UBound(OpsToProcess)
    
                Dim TheOp As Mastercam.Database.Operation = CType(OpsToProcess(i), Mastercam.Database.Operation)
    
                If TheOp IsNot Nothing Then
    
                    If TheOp.Selected = True Then
    
                        If TheOp.Type = Mastercam.Database.Types.OperationType.Contour Then
    
                            Dim ContourOp As Mastercam.Operations.ContourOperation = CType(TheOp, Mastercam.Operations.ContourOperation)
    
                            ReverseChains(TheOp, ContourOp.GetChainArray)
    
                            'Dim ChainArray = ContourOp.GetChainArray
    
                        End If 'End of Contour Operation type if
    
                        If TheOp.Type = Mastercam.Database.Types.OperationType.Pocket Then
    
                            Dim PocketOp As Mastercam.Operations.PocketOperation = CType(TheOp, Mastercam.Operations.PocketOperation)
    
                            ReverseChains(TheOp, PocketOp.GetChainArray)
    
                        End If 'End of Pocket Operation type if
    
                        If TheOp.Type = Mastercam.Database.Types.OperationType.SlotMill Then
    
                            Dim SlotMillOp As Mastercam.Operations.SlotMillOperation = CType(TheOp, Mastercam.Operations.SlotMillOperation)
    
                            ReverseChains(TheOp, SlotMillOp.GetChainArray)
    
                        End If 'End of SlotMill Operation type if
    
                    End If 'End of TheOp being selected if
    
                End If 'End of TheOp being nothing if
    
            Next i
    
            Return TheAnswer
    
        End Function
    

    So far I am just trying to do the reverse chain part and when I debug the current code I have

    it seems to delete the chain rather than reversing it.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...