Add flange with VB

 

Hello,

I'm trying to add a flange in visual basic, but it doesn't work. I'm begineer programming solid edge with visual basic, I don't know if I am near or not.

 

Can someone help me please? Can someone write an example? I put my wrong code below. Thanks very much.

 

 

Imports SolidEdgeConstants

Imports System.Runtime.InteropServices

Module Module1

    Sub Main()

        Dim objApplication As SolidEdgeFramework.Application = Nothing

        Dim objDocuments As SolidEdgeFramework.Documents = Nothing

        Dim objSheetM As SolidEdgePart.SheetMetalDocument = Nothing

        Dim objProfiles As SolidEdgePart.Profiles = Nothing

        Dim objProfile As SolidEdgePart.Profile = Nothing

        Dim objProfile2 As SolidEdgePart.Profile = Nothing

        Dim objRefplanes As SolidEdgePart.RefPlanes = Nothing

        Dim objRelations2d As SolidEdgeFrameworkSupport.Relations2d = Nothing

        Dim objRelations2d2 As SolidEdgeFrameworkSupport.Relations2d = Nothing

        Dim objRelation2d As SolidEdgeFrameworkSupport.Relation2d = Nothing

        Dim objRelation2d2 As SolidEdgeFrameworkSupport.Relation2d = Nothing

        Dim objLines2d As SolidEdgeFrameworkSupport.Lines2d = Nothing

        Dim objLine2d(0 To 3) As SolidEdgeFrameworkSupport.Line2d

        Dim objModels As SolidEdgePart.Models = Nothing

        Dim objModel As SolidEdgePart.Model = Nothing

        Dim objSketches As SolidEdgePart.Sketchs = Nothing

        Dim objSketch As SolidEdgePart.Sketch = Nothing

        Dim objPliegues As SolidEdgePart.Flanges = Nothing

        Dim objPliegue As SolidEdgePart.Flange = Nothing

        Dim objcaraplegados As SolidEdgePart.Tabs = Nothing

        Dim objcaraplegado As SolidEdgePart.Tab = Nothing

        Dim objlineaplegados As SolidEdgePart.Tabs = Nothing

        Dim objlineaplegado As SolidEdgePart.Tab = Nothing

        'Dim aProfiles As Array

        Try

            objApplication = Marshal.GetActiveObject("SolidEdge.Application") 'conecta con SE

            objDocuments = objApplication.Documents 'referencia a documentos

            objSheetM = objDocuments.Add("SolidEdge.SheetMetalDocument") 'crear nuevo documento -chapa

 

            'HACER CARA PLANA

            objSketches = objSheetM.Sketches 'referencia a coleccion de bocetos

            objSketch = objSketches.Add() 'añadir nuevo boceto

 

            objProfiles = objSketch.Profiles 'referencia a colección de perfiles

            objRefplanes = objSheetM.RefPlanes 'referencia a colección de planos

            objProfile = objProfiles.Add(objRefplanes.Item(3)) 'añadir perfil

 

            objLines2d = objProfile.Lines2d 'referencia a colección de lineas 2d

            objLine2d(0) = objLines2d.AddBy2Points(0, 0, 0.1, 0) 'dibujar el perfil

            objLine2d(1) = objLines2d.AddBy2Points(0.1, 0, 0.1, 0.1)

            objLine2d(2) = objLines2d.AddBy2Points(0.1, 0.1, 0, 0.1)

            objLine2d(3) = objLines2d.AddBy2Points(0, 0.1, 0, 0)

 

            objRelations2d = objProfile.Relations2d 'definir relaciones para cerrar el perfil

 

            objRelation2d = objRelations2d.AddKeypoint( _

            objLines2d(0), KeypointIndexConstants.igLineEnd, _

            objLines2d(1), KeypointIndexConstants.igLineStart)

 

            objRelation2d = objRelations2d.AddKeypoint( _

            objLines2d(1), KeypointIndexConstants.igLineEnd, _

            objLines2d(2), KeypointIndexConstants.igLineStart)

 

            objRelation2d = objRelations2d.AddKeypoint( _

            objLines2d(2), KeypointIndexConstants.igLineEnd, _

            objLines2d(3), KeypointIndexConstants.igLineStart)

 

            objRelation2d = objRelations2d.AddKeypoint( _

            objLines2d(3), KeypointIndexConstants.igLineEnd, _

            objLines2d(0), KeypointIndexConstants.igLineStart)

 

            objProfile.End(SolidEdgePart.ProfileValidationType.igProfileClosed) 'cerrar el perfil

            objProfile.Visible = False 'ocultar el perfil

 

            objModels = objSheetM.Models 'reeferencia a colección de modelos-operaciones

            objModel = objModels.AddBaseTab(objProfile, SolidEdgePart.FeaturePropertyConstants.igRight)

 

            objcaraplegados = objModel.Tabs

            objcaraplegado = objcaraplegados.Item(1)

            objlineaplegados = objcaraplegado.Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)

            objlineaplegado = objlineaplegados.Item(1)

 

            objPliegues = objModel.Flanges

            objPliegue = objPliegues.Add(objlineaplegado, SolidEdgePart.FeaturePropertyConstants.igLinear, 0.02)

 

 

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        Finally

            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 (objRelations2d Is Nothing) Then

                Marshal.ReleaseComObject(objRelations2d)

                objRelations2d = Nothing

            End If

            For i = 0 To 3

                If Not (objLine2d(i) Is Nothing) Then

                    Marshal.ReleaseComObject(objLine2d(i))

                    objLine2d(i) = Nothing

                End If

            Next

            If Not (objLines2d Is Nothing) Then

                Marshal.ReleaseComObject(objLines2d)

                objLines2d = Nothing

            End If

            If Not (objRelation2d Is Nothing) Then

                Marshal.ReleaseComObject(objRelation2d)

                objRelation2d = Nothing

            End If

            If Not (objRefplanes Is Nothing) Then

                Marshal.ReleaseComObject(objRefplanes)

                objRefplanes = Nothing

            End If

            If Not (objProfile Is Nothing) Then

                Marshal.ReleaseComObject(objProfile)

                objProfile = Nothing

            End If

            If Not (objProfiles Is Nothing) Then

                Marshal.ReleaseComObject(objProfiles)

                objProfiles = Nothing

            End If

            If Not (objSketches Is Nothing) Then

                Marshal.ReleaseComObject(objSketches)

                objSketches = Nothing

            End If

            If Not (objSketch Is Nothing) Then

                Marshal.ReleaseComObject(objSketch)

                objSketch = Nothing

            End If

            If Not (objSheetM Is Nothing) Then

                Marshal.ReleaseComObject(objSheetM)

                objSheetM = 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

            If Not (objPliegues Is Nothing) Then

                Marshal.ReleaseComObject(objPliegues)

                objPliegues = Nothing

            End If

            If Not (objPliegue Is Nothing) Then

                Marshal.ReleaseComObject(objPliegue)

                objPliegue = Nothing

            End If

        End Try

    End Sub

End Module

 

 

 

Posted by: Javier C
Post date: 10/16/2011 8:30:30 AM

1 REPLY

RE: Add flange with VB

Hello, I'm trying to make a flange with VB, I have improved but I can't to make the flange yet.

I can to make the tab and almost can to make the flange. I think I don´t define the side to add the flange (inside-outside)... I am trying with

"objPliegue = objPliegues.Add(objLineaPlegado, SolidEdgePart.FeaturePropertyConstants.igOutside, 0.02, , 0)"

I think the problem is with the "SolidEdgePart.FeaturePropertyConstants.igOutside" because I have changed it some times to other opcions (igRight, igInside, etc) and the result is the same.

When I run the program SE draw the flange but it is like don't finish the flange. Can someone help me please? Can someone to explain me how to make flanges?

Thanks very much.

 

 

objModels = objSheetM.Models

objModel = objModels.AddBaseTab(objProfile, SolidEdgePart.FeaturePropertyConstants.igRight)

 

objcaraplegados = objModel.Tabs

objcaraplegado = objcaraplegados.Item(1)

 

objLineaPlegados = objcaraplegado.Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)

objLineaPlegado = objLineaPlegados.Item(3)

objPliegues = objModel.Flanges

objPliegue = objPliegues.Add(objLineaPlegado, SolidEdgePart.FeaturePropertyConstants.igOutside, 0.02, , 0)

 

Posted by: Javier C
Post date: 10/23/2011 1:57:19 AM