Reply

Change TrimSurface Tool

Hi everybody,

I need to redefine the tool that is used for a trimsurface feature but I get an error does anyone already do this or can tell me what's wrong ?

Here is my code so far :

 Sub Main()
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objPart As SolidEdgePart.PartDocument = Nothing

        Try
            objApplication = CType(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
        Catch ex As Exception
            If Not (objApplication Is Nothing) Then
                Marshal.ReleaseComObject(objApplication)
                objApplication = Nothing
            End If
            Return
        End Try

        Try
            objPart = objApplication.ActiveDocument

            Dim Feature2Edit As SolidEdgePart.TrimSurface = Nothing
            Dim ObjTrimSurface As SolidEdgePart.ExtrudedSurface = Nothing

            Dim TmpObj As Object = bjPart.DesignEdgebarFeatures.Item(4)

            If TmpObj.Type = SolidEdgePart.FeatureTypeConstants.igTrimSurfaceObject Then
                Feature2Edit = TmpObj
            End If

            Dim tempTrimSurface As Object = objPart.DesignEdgebarFeatures.Item(2)

            ObjTrimSurface = tempTrimSurface

            If Not Feature2Edit Is Nothing And Not ObjTrimSurface Is Nothing Then
                Dim arrayTrimSurface As System.Array = System.Array.CreateInstance(GetType(Object), 1)
                arrayTrimSurface(0) = ObjTrimSurface
                Dim NbEdge As Integer = 1

                Feature2Edit.SetTrimTools(NbEdge, arrayTrimSurface)

            End If
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally

        End Try
    End Sub

 


Romuald BERTIN
5 REPLIES

Re: Change TrimSurface Tool

Are you sure that your indexes to the DesignEdgebarFeatures are correct?

Normally, the first 3 features are the RefPlanes and the first "real" feature (index =4) cannot be a TrimSurface. Before trimming anything, there must be a surface first!!

So the index of the earliest TrimSurface CANNOT be smaller than 5.

Re: Change TrimSurface Tool

Hi martin,

Thanks for your answer.
I put some random values the whole program get features by their name so I don't care of this id.

You can set ids you want

Bertin romuald

Romuald BERTIN

Re: Change TrimSurface Tool

Bertin,

you are using a feature object as your TrimTool. This is not supported by the UI, so you would better pass only those entities indicated by the UI (single, chain, body).

Try to use the body of your tool surface for the trim tools (Body property of the surface's parent, which is a ConstructionModel).

I did a couple of tests and was not able to replace one trim tool by another, so there might be a problem in the API, but as I said, I only did few tests...

Re: Change TrimSurface Tool

I tried with the body of the surface define as the trimtool as well and can't get a result.

I'll make some other test.


Romuald BERTIN

Re: Change TrimSurface Tool

There seems to be a problem with the API because I can't get the Trimtools as well ...

 

Did you see something wrong in the following code, maybe when declaring the array :

 

    Public Sub GetTrimTools(ByVal TrimFeature As String)
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objPart As SolidEdgePart.PartDocument = Nothing

        Try
            objApplication = CType(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
        Catch ex As Exception
            If Not (objApplication Is Nothing) Then
                Marshal.ReleaseComObject(objApplication)
                objApplication = Nothing
            End If
            Return
        End Try

        Try
            objPart = objApplication.ActiveDocument

            Dim Feature2Edit As SolidEdgePart.TrimSurface = Nothing
            Dim TmpObj As Object

            For i = 1 To objPart.DesignEdgebarFeatures.Count
                If objPart.DesignEdgebarFeatures.Item(i).Name = TrimFeature Then
                    TmpObj = objPart.DesignEdgebarFeatures.Item(i)
                    If TmpObj.Type = SolidEdgePart.FeatureTypeConstants.igTrimSurfaceObject Then
                        Feature2Edit = TmpObj
                        Exit For
                    End If
                End If

            Next

            If Not Feature2Edit Is Nothing Then
                Dim NbEdge As Integer

                Dim TmpArrayTrimSurface(0 To 10) As Object
                Feature2Edit.SetTrimTools(NbEdge, TmpArrayTrimSurface)
            End If
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally

        End Try

    End Sub

 


Romuald BERTIN