vb.net create constraints in SubAssembly with ProxyGeometry

vb.net create constraints in SubAssembly with ProxyGeometry

ssyXENBT
Contributor Contributor
232 Views
0 Replies
Message 1 of 1

vb.net create constraints in SubAssembly with ProxyGeometry

ssyXENBT
Contributor
Contributor

Hi, 

 

I am creating constraints in an assembly, but I always get an error that there is no referenced object. What is the reason for this? 

(System.NullReferenceException: "Object reference not set to an instance of an object.")

From the various documents, I'll pick the appropriate edge and save it as a variable.

 

Thanks in advance for any answer!

 

ssyXENBT_1-1683188522916.png

    Sub placeHLtr(oOcc As ComponentOccurrence, pfDoc As ComponentOccurrence, constraintDocument As ComponentOccurrence, oDoc2 As ComponentOccurrence)
        Dim name As String = ""
        Dim oSavedEdge As Edge
        Dim oOccEdge As ComponentOccurrence
        Dim oHLTrProxyEdge As EdgeProxy
        Dim oHLTrAssyProxyEdge As EdgeProxy

        Dim oSavedEdge2 As Edge
        Dim oPFDocEdgeProxy As EdgeProxy

        Dim oAssyProxy1 As EdgeProxy
        Dim oAssyProxy2 As EdgeProxy



        For Each oOcc2 As ComponentOccurrence In oOcc.SubOccurrences
            Dim solids As SurfaceBody = oOcc2.SurfaceBodies.Item(1)
            Dim posZ As Double
            For Each oEdge As Edge In solids.Edges
                If oEdge.CurveType = CurveTypeEnum.kCircleCurve Then
                    If Math.Round(oEdge.Geometry.Radius * 10, 1) = "21,2" Then
                        If posZ < oEdge.Geometry.center.Z Then
                            posZ = oEdge.Geometry.center.Z
                            oSavedEdge = oEdge
                            oOccEdge = oOcc2
                        End If
                    End If
                End If
            Next
        Next

        Dim posiZ As Double
        For Each oEdge As Edge In pfDoc.SurfaceBodies.Item(1).Edges
            If oEdge.CurveType = CurveTypeEnum.kCircleCurve Then
                If Math.Round(oEdge.Geometry.Radius * 10, 1) = "21,2" Then
                    If posiZ < oEdge.Geometry.center.Z Then
                        posiZ = oEdge.Geometry.center.Z
                        oSavedEdge2 = oEdge
                    End If
                End If
            End If
        Next

        oOccEdge.CreateGeometryProxy(oSavedEdge, oHLTrProxyEdge)
        oOcc.CreateGeometryProxy(oHLTrProxyEdge, oHLTrAssyProxyEdge)
        'constraintDocument.CreateGeometryProxy(oHLTrAssyProxyEdge, oAssyProxy1)


        pfDoc.CreateGeometryProxy(oSavedEdge2, oPFDocEdgeProxy)
        'constraintDocument.CreateGeometryProxy(oPFDocEdgeProxy, oAssyProxy2)


        Dim oConstraint As FlushConstraint
        oConstraint = constraintDocument.Constraints.AddInsertConstraint(oHLTrAssyProxyEdge, oPFDocEdgeProxy, False, 0)

    End Sub

 

0 Likes
233 Views
0 Replies
Replies (0)