AnsweredAssumed Answered

SOLIDWORKS to MATLAB

Question asked by Hamid Rakhodaei on Apr 3, 2015
Latest reply on Apr 4, 2015 by Deepak Gupta

Hello all

 

I want to send Data from Solid works to matlab

I wrote this code :

Private Sub CommandButton1_Click()

Dim swApp As Object

Dim Measure As Measure

Dim Part As Object

Dim boolstatus As Boolean

Dim boolstatus2 As Boolean

Dim h As Object

 

 

On Error GoTo ErrHandler:

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Set Measure = Part.Extension.CreateMeasure

 

 

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Plat2mid@upp_plat-1@stewart_platform.ASSEMBLYFILETYPE", "DATUMPOINT", 0, 0, 0, True, 0, Nothing, 0)

 

 

 

 

boolstatus = Measure.Calculate(Nothing)

Set h = GetObject(, "Matlab.Desktop.Application")

 

 

If (boolstatus) Then

 

 

    If (Not (Measure.x = -1)) Then

 

 

        TextBox1.Text = Measure.x * 1000

        Call h.PutWorkspaceData("x", "base", Measure.x * 1000)

    End If

    If (Not (Measure.Y = -1)) Then

 

 

        TextBox2.Text = Measure.Y * 1000

        Call h.PutWorkspaceData("y", "base", Measure.Y * 1000)

    End If

    If (Not (Measure.x = -1)) Then

 

 

        TextBox3.Text = Measure.Z * 1000

        Call h.PutWorkspaceData("z", "base", Measure.Z * 1000)

    End If

 

End If

 

 

boolstatus2 = Part.Extension.SelectByID2("Point1@end effcter-1@stewart_platform.ASSEMBLYFILETYPE", "DATUMPOINT", 0, 0, 0, False, 0, Nothing, 0)

boolstatus2 = Measure.Calculate(Nothing)

Set h = GetObject(, "Matlab.Desktop.Application")

 

 

If (boolstatus2) Then

 

 

    If (Not (Measure.x = -1)) Then

 

        Call h.PutWorkspaceData("x2", "base", Measure.x * 1000)

    End If

    If (Not (Measure.Y = -1)) Then

 

 

        TextBox5.Text = Measure.Y * 1000

        Call h.PutWorkspaceData("y2", "base", Measure.Y * 1000)

    End If

    If (Not (Measure.x = -1)) Then

 

 

        TextBox6.Text = Measure.Z * 1000

        Call h.PutWorkspaceData("z2", "base", Measure.Z * 1000)

    End If

 

End If

boolstatus2 = Part.Extension.SelectByID2("Point2@end effcter-1@stewart_platform.ASSEMBLYFILETYPE", "DATUMPOINT", 0, 0, 0, False, 0, Nothing, 0)

boolstatus2 = Measure.Calculate(Nothing)

Set h = GetObject(, "Matlab.Desktop.Application")

 

 

If (boolstatus2) Then

 

 

    If (Not (Measure.x = -1)) Then

 

 

        TextBox7.Text = Measure.x * 1000

        Call h.PutWorkspaceData("x3", "base", Measure.x * 1000)

    End If

    If (Not (Measure.Y = -1)) Then

 

 

        TextBox8.Text = Measure.Y * 1000

        Call h.PutWorkspaceData("y3", "base", Measure.Y * 1000)

    End If

    If (Not (Measure.x = -1)) Then

 

 

        TextBox9.Text = Measure.Z * 1000

        Call h.PutWorkspaceData("z3", "base", Measure.Z * 1000)

    End If

 

End If

 

End Sub

 

I have error in:

Set h = GetObject(, "Matlab.Desktop.Application")

Any help would be great.

 

Thanks in Advanced

Outcomes