Showing results for 
Search instead for 
Do you mean 
Reply

How to get Geometry objects from CAM Operation

Hello,

 

in my application i use a list of CAM Operation in a listbox. 

From a listbox will be read a selected from user CAM Operation.

 

var workPart = _theSession.Parts.Work;

// Get selected CAM Operation Object
var camOperationObject =workPart.CAMSetup.CAMOperationCollection.FindObject(selectedCamOperation);

 

I want to know how i can get from CAM Operation a workpiece geometry data (for example a workpiece geometry name) in my app?

 

Thank you in advance.

3 REPLIES

Re: How to get Geometry objects from CAM Operation

You get the parents of an operation through the GetParent method.

theOperation.GetParent(CAM.CAMSetup.View.Geometry)

theOperation must be of type CAM.Operation to get this method.

Code not tested, but written down from the top of my head, so you should trust the code completion feature of your IDE Smiley Wink

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get Geometry objects from CAM Operation

[ Edited ]

Thank you for your reply.

 

I tryed allready this call. It return a NCGroup Object... I need to get an another kind of Information (one or two levels deeper).

 

I need the Information about "specify Part" and "specify Blank" from Workpiece Dialog.

 

Re: How to get Geometry objects from CAM Operation

You need a recursive function to get the last parent of type CAM.FeatureGeometry then you need to create a CAM.MillGeomBuilder to be able to access the geometry lists for part and blank.

Best is to record a journal where you add one object to each list, so you get the methods needed to access the information.

    Private Function GetWorkpiece(oWorkpieceGroup As CAM.FeatureGeometry) As TaggedObject()
        Dim oMillGeomBuilder As CAM.MillGeomBuilder = _
            theWorkPart.CAMSetup.CAMGroupCollection.CreateMillGeomBuilder(oWorkpieceGroup)
        Dim theGeometryItems As New List(Of TaggedObject)
        
        GetWorkpiece = {}
        
        Try
            For Each oGeometrySet As CAM.GeometrySet In oMillGeomBuilder.PartGeometry.GeometryList.GetContents()
                For Each theGeometryItem As TaggedObject In oGeometrySet.GetItems()
                    theGeometryItems.Add(theGeometryItem)
                Next
            Next
            
            theGeometryItems.TrimExcess()
            
            If theGeometryItems.Count > 0 Then
                ReDim GetWorkpiece(theGeometryItems.Count - 1)
                
                theGeometryItems.ToArray().CopyTo(GetWorkpiece, 0)
            End If
        Catch ex As NXException
            theSession.LogFile.WriteLine(ex.ToString())
        Finally
            oMillGeomBuilder.Destroy()
            oMillGeomBuilder = Nothing
        End Try
    End Function
    Private Function GetBlankBody(oWorkpieceGroup As CAM.FeatureGeometry) As TaggedObject()
        Dim oMillGeomBuilder As CAM.MillGeomBuilder = _
            theWorkPart.CAMSetup.CAMGroupCollection.CreateMillGeomBuilder(oWorkpieceGroup)
        Dim theGeometryItems As New List(Of TaggedObject)
        
        GetBlankBody = {}
        
        Try
            If oMillGeomBuilder.BlankGeometry.BlankDefinitionType = CAM.GeometryGroup.BlankDefinitionTypes.FromGeometry Then
                For Each oGeometrySet As CAM.GeometrySet In oMillGeomBuilder.BlankGeometry.GeometryList.GetContents()
                    For Each theGeometryItem As TaggedObject In oGeometrySet.GetItems()
                        theGeometryItems.Add(theGeometryItem)
                    Next
                Next
            End If
            
            theGeometryItems.TrimExcess()
            
            If theGeometryItems.Count > 0 Then
                ReDim GetBlankBody(theGeometryItems.Count - 1)
                
                theGeometryItems.ToArray().CopyTo(GetBlankBody, 0)
            End If
        Catch ex As NXException
            theSession.LogFile.WriteLine(ex.ToString())
        Finally
            oMillGeomBuilder.Destroy()
            oMillGeomBuilder = Nothing
        End Try
    End Function

The functions are provided as is, changes are subject to the requester Smiley Wink

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community