Reply

seriously now. I need help CaptureRelationships

[ Edited ]

 

Can anyone, anyone at all help me apply a capture fit.    I took this example for adding a mate from the new programmers guide and I just want to add the capture fit for the single axial align relationship.

Imports SolidEdgeGeometry

Imports System.Runtime.InteropServices

Module Module1

    Sub Main()

        Dim objApplication As SolidEdgeFramework.Application = Nothing

        Dim objDocuments As SolidEdgeFramework.Documents = Nothing

        Dim objAssembly As SolidEdgeAssembly.AssemblyDocument = Nothing

        Dim objOccurrences As SolidEdgeAssembly.Occurrences = Nothing

        Dim objOccurrence1 As SolidEdgeAssembly.Occurrence = Nothing

        Dim objOccurrence2 As SolidEdgeAssembly.Occurrence = Nothing

        Dim objPart As SolidEdgePart.PartDocument = Nothing

        Dim objModels As SolidEdgePart.Models = Nothing

        Dim objModel As SolidEdgePart.Model = Nothing

        Dim objRevolvedProtrusions As SolidEdgePart.RevolvedProtrusions = Nothing

        Dim objRevolvedProtrusion As SolidEdgePart.RevolvedProtrusion = Nothing

        Dim objRevolvedCutouts As SolidEdgePart.RevolvedCutouts = Nothing

        Dim objRevolvedCutout As SolidEdgePart.RevolvedCutout = Nothing

        Dim objFaces As SolidEdgeGeometry.Faces = Nothing

        Dim objFace As SolidEdgeGeometry.Face = Nothing

        Dim objGeometry As Object = Nothing

        Dim objScrewConicalFace As SolidEdgeGeometry.Face = Nothing

        Dim objNutConicalFace As SolidEdgeGeometry.Face = Nothing

        Dim objRefToCylinderInScrew As SolidEdgeFramework.Reference = Nothing

        Dim objRefToConeInNut As SolidEdgeFramework.Reference = Nothing

        Dim objRelations3d As SolidEdgeAssembly.Relations3d = Nothing

        Dim objGroundRel As SolidEdgeAssembly.GroundRelation3d = Nothing

        Dim objRelNuttoScrew As SolidEdgeAssembly.AxialRelation3d = Nothing

        Try

            ' Connect to a running instance of Solid Edge      

            objApplication = Marshal.GetActiveObject("SolidEdge.Application")

            ' Get a reference to the documents collection     

            objDocuments = objApplication.Documents

            ' Create a new assembly document      

            objAssembly = objDocuments.Add("SolidEdge.AssemblyDocument")

            ' Get a reference to the occurrences collection      

            objOccurrences = objAssembly.Occurrences

            ' Add the first occurrence      

            objOccurrence1 = objOccurrences.AddByFilename("C:\Screw.par")

            ' Get a reference to the occurrence document      

            objPart = objOccurrence1.OccurrenceDocument

            ' Get a reference to the models collection      

            objModels = objPart.Models

            ' Get a reference to the one and only model

            objModel = objModels.Item(1)

            ' Get a reference to the revolved protrusions collection      

            objRevolvedProtrusions = objModel.RevolvedProtrusions

            ' Get a reference to the first revolved protrusion      

            objRevolvedProtrusion = objRevolvedProtrusions.Item(1)

            ' Get a reference to the side faces collection      

            objFaces = objRevolvedProtrusion.SideFaces

            ' Loop through the faces      

            For Each objFace In objFaces

                ' Get a reference to the geometry object        

                objGeometry = objFace.Geometry

                If objGeometry.Type = GNTTypePropertyConstants.igCylinder Then         

                    objScrewConicalFace = objFace

                    Exit For

                End If

            Next

            ' Create the first reference      

            objRefToCylinderInScrew = objAssembly.CreateReference(objOccurrence1, objScrewConicalFace)

            ' Add the second occurrence      

            objOccurrence2 = objOccurrences.AddByFilename("C:\Nut2.par")

            ' Get a reference to the occurrence document      

            objPart = objOccurrence2.OccurrenceDocument

            ' Get a reference to the models collection      

            objModels = objPart.Models

            ' Get a reference to the one and only model      

            objModel = objModels.Item(1)

            ' Get a reference to the revolved cutouts collection      

            objRevolvedCutouts = objModel.RevolvedCutouts

            ' Get a reference to the first revolved cutout      

            objRevolvedCutout = objRevolvedCutouts.Item(1)

            ' Get a reference to the side faces collection      

            objFaces = objRevolvedCutout.SideFaces

            ' Loop through the faces      

            For Each objFace In objFaces

                objGeometry = objFace.Geometry

                If objGeometry.Type = GNTTypePropertyConstants.igCylinder Then

                    objNutConicalFace = objFace

                    Exit For

                End If

            Next

            ' Create the second reference      

            objRefToConeInNut = objAssembly.CreateReference(objOccurrence2, objNutConicalFace)

            ' All Occurrences placed through automation are placed "Grounded."      

            ' You must delete the ground constraint on the second Occurrence      

            ' before you can place other relationships.      

            objRelations3d = objAssembly.Relations3d

            objGroundRel = objRelations3d.Item(2)

            objGroundRel.Delete()

            ' Rather than passing literal axes to the AddAxial method, pass      

            ' references to conical faces, Just as you select conical faces      

            ' when you use the interactive Align command.      

            objRelNuttoScrew = objRelations3d.AddAxial(objRefToConeInNut, objRefToCylinderInScrew, False)

        Catch ex As Exception

            Console.WriteLine(ex.Message)

            Console.ReadKey(0)

        Finally

            If Not (objRelNuttoScrew Is Nothing) Then

                Marshal.ReleaseComObject(objRelNuttoScrew)

                objRelNuttoScrew = Nothing

            End If

            If Not (objGroundRel Is Nothing) Then

                Marshal.ReleaseComObject(objGroundRel)

                objGroundRel = Nothing

            End If

            If Not (objRelations3d Is Nothing) Then

                Marshal.ReleaseComObject(objRelations3d)

                objRelations3d = Nothing

            End If

            If Not (objRefToConeInNut Is Nothing) Then

                Marshal.ReleaseComObject(objRefToConeInNut)

                objRefToConeInNut = Nothing

            End If

            If Not (objRefToCylinderInScrew Is Nothing) Then

                Marshal.ReleaseComObject(objRefToCylinderInScrew)

                objRefToCylinderInScrew = Nothing

            End If

            If Not (objNutConicalFace Is Nothing) Then

                Marshal.ReleaseComObject(objNutConicalFace)

                objNutConicalFace = Nothing

            End If

            If Not (objScrewConicalFace Is Nothing) Then

                Marshal.ReleaseComObject(objScrewConicalFace)

                objScrewConicalFace = Nothing

            End If

            If Not (objGeometry Is Nothing) Then

                Marshal.ReleaseComObject(objGeometry)

                objGeometry = Nothing

            End If

            If Not (objFace Is Nothing) Then

                Marshal.ReleaseComObject(objFace)

                objFace = Nothing

            End If

            If Not (objFaces Is Nothing) Then

                Marshal.ReleaseComObject(objFaces)

                objFaces = Nothing

            End If

            If Not (objRevolvedCutout Is Nothing) Then

                Marshal.ReleaseComObject(objRevolvedCutout)

                objRevolvedCutout = Nothing

            End If

            If Not (objRevolvedCutouts Is Nothing) Then

                Marshal.ReleaseComObject(objRevolvedCutouts)

                objRevolvedCutouts = Nothing

            End If

            If Not (objRevolvedProtrusion Is Nothing) Then

                Marshal.ReleaseComObject(objRevolvedProtrusion)

                objRevolvedProtrusion = Nothing

            End If

            If Not (objRevolvedProtrusions Is Nothing) Then

                Marshal.ReleaseComObject(objRevolvedProtrusions)

                objRevolvedProtrusions = Nothing

            End If

            If Not (objModel Is Nothing) Then

                Marshal.ReleaseComObject(objModel)

                objModel = Nothing

            End If

            If Not (objModels Is Nothing) Then

                Marshal.ReleaseComObject(objModels)

                objModels = Nothing

            End If

            If Not (objPart Is Nothing) Then

                Marshal.ReleaseComObject(objPart)

                objPart = Nothing

            End If

            If Not (objOccurrence2 Is Nothing) Then

                Marshal.ReleaseComObject(objOccurrence2)

                objOccurrence2 = Nothing

            End If

            If Not (objOccurrence1 Is Nothing) Then

                Marshal.ReleaseComObject(objOccurrence1)

                objOccurrence1 = Nothing

            End If

            If Not (objOccurrences Is Nothing) Then

                Marshal.ReleaseComObject(objOccurrences)

                objOccurrences = Nothing

            End If

            If Not (objAssembly Is Nothing) Then

                Marshal.ReleaseComObject(objAssembly)

                objAssembly = Nothing

            End If

            If Not (objDocuments Is Nothing) Then

                Marshal.ReleaseComObject(objDocuments)

                objDocuments = Nothing

            End If

            If Not (objApplication Is Nothing) Then

                Marshal.ReleaseComObject(objApplication)

                objApplication = Nothing

            End If

        End Try

    End Sub

 

End Module

 

Posted by: mike drummond
Post date: 10/17/2008 5:08:17 AM