Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetDirection vb.net

Status
Not open for further replies.

Santa123

Mechanical
Joined
Oct 2, 2006
Messages
80
Location
PL
Hej,
I am trying to convert my macro from script to vb.net

Code:
Function FuncIsHorizontal(MyPart As Part, i) As Boolean
Dim MyDir() As Variant
Dim MyGeomElementLine As GeometricElement
Set MyGeomElementLine = MyPart.Bodies.Item("PartBody").Sketches.Item(1).Constraints.Item(i).GetConstraintElement(1)
ReDim MyDir(2)
MyGeomElementLine.GetDirection MyDir
    If MyDir(0) = 1 And MyDir(1) = 0 Or MyDir(0) = -1 And MyDir(1) = 0 Then
        FuncIsHorizontal = True
    Else
        FuncIsHorizontal = False
    End If
End Function

and after typing MyGeomElementLine I dont have method GetDirection.

Regards
Santa
 
Show your VB.NET code. Have you made a reference to MECMOD interfaces?
 
Hej,

it finally worked, but intellisense not showing me method GetDirection

Code:
Imports INFITF
Imports MECMOD

Public Class Form1

    Private Sub Form_Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim CATIA As Application
        Dim MyPart As Part
        Try
            CATIA = GetObject(vbNullString, "CATIA.Application")
        Catch ex As Exception
            MessageBox.Show("You don't have active Catia!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Close()
            Exit Sub
        End Try

        MyPart = CATIA.ActiveDocument.part
        Call MyPartSub(MyPart)

    End Sub

    Sub MyPartSub(MyPart As Part)
        Dim MySketch As sketch
        Dim MyGeometricElement As GeometricElement
        Dim MyGeometricElements As GeometricElements
        Dim i As Integer
        Dim MyDir(2)
        i = 0
        MySketch = MyPart.Bodies.Item(1).Sketches.Item(1)
        MyGeometricElements = MySketch.GeometricElements

        For Each MyGeometricElement In MyGeometricElements
            If MyGeometricElement.GeometricType = CatGeometricType.catGeoTypeLine2D Then
                i = i + 1
                MyGeometricElement.getDirection(MyDir)
                If MyDir(0) = 0 And MyDir(1) = -1 Or MyDir(0) = 0 And MyDir(1) = 1 Then
                    MsgBox(MyGeometricElement.Name & " - Vertical")
                Else
                    MsgBox(MyGeometricElement.Name & " - Horizontal")
                End If
            End If
        Next
        lblLine.Text = i
    End Sub
End Class
 
Hej
I can't find this library in Reference Manager, strange.
Regards
Santa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top