Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

GetDirection vb.net

Status
Not open for further replies.

Santa123

Mechanical
Oct 2, 2006
80
0
0
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
 
Replies continue below

Recommended for you

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
 
Status
Not open for further replies.
Back
Top