cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to open a New Assembly Sheet in Creo using VB.NET

avijayan-2
14-Alexandrite

How to open a New Assembly Sheet in Creo using VB.NET

Hai All,

          I have written a code to open a creo session and set working directory using vb.net. and the code was working fine for me. now i trying to open a blank new assembly sheet using VBAPI

But i am getting some error, and i not able to get pass it, i went through the document but didnt get any help.

I am pasting my code over here.

Imports pfcls

Public Class Form1

    Private asyncConnection As IpfcAsyncConnection

    Private basesession As IpfcBaseSession

    Private descModel As IpfcModelDescriptor

    Private descModelCreate As CCpfcModelDescriptor

    Private model As IpfcAssembly

    Private session As IpfcBaseSession

    Private Sub Browse_Click(sender As Object, e As EventArgs) Handles Browse.Click

        OFD.Title = "Creo Parametric"

        OFD.FileName = "xtop"

        OFD.InitialDirectory = System.Environment.CurrentDirectory

        If (OFD.ShowDialog() = Windows.Forms.DialogResult.OK) Then

            CreoPath.Text = OFD.FileName

        End If

    End Sub

    Private Sub btnBWD_Click(sender As Object, e As EventArgs) Handles btnBWD.Click

        FBD.SelectedPath = System.Environment.CurrentDirectory

        FBD.Description = "Select Creo Parametric working directory."

        If (FBD.ShowDialog() = Windows.Forms.DialogResult.OK) Then

            txtWD.Text = FBD.SelectedPath

        End If

    End Sub

    Private Sub Start_Click(sender As Object, e As EventArgs) Handles Start.Click

        Dim asyncConnection As IpfcAsyncConnection = Nothing

        Try

            If CreoPath.Text = "" Then

                MsgBox("Please enter path to Creo Parametric executable", MsgBoxStyle.Critical)

            Else

                Me.Cursor = Cursors.WaitCursor

                asyncConnection = (New CCpfcAsyncConnection).Start(CreoPath.Text, ".")

                If Not (txtWD.Text = "") Then

                    asyncConnection.Session.ChangeDirectory(txtWD.Text)

                End If

                Me.WindowState = FormWindowState.Minimized

            End If

        Catch ex As Exception

            MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)

            If Not asyncConnection Is Nothing AndAlso asyncConnection.IsRunning Then

                asyncConnection.End()

            End If

            'lblStatus.Text = "Error occurred while starting new Creo Parametric Session"

        Finally

            Me.WindowState = FormWindowState.Normal

            Me.Cursor = Cursors.Default

            Me.Refresh()

        End Try

    End Sub

    Private Sub NEW_01_Click(sender As Object, e As EventArgs) Handles NEW_01.Click

   

        descModelCreate = New CCpfcModelDescriptor

        descModel = descModelCreate.Create(EpfcModelType.EpfcMDL_ASSEMBLY, "123.asm", Nothing)

        model = session.CreateAssembly("123.asm")

    End Sub

End Class

the session which is highlighted in red is where i am getting trouble. Please help me to crack this

With Regards

Aghil.M

3 REPLIES 3

Hi Aghil,

what error message you recieve?

Regards,

Tom

avijayan-2
14-Alexandrite
(To:TomasLoun)

Hi Tomas.

     Thanks for the reply, i got the solution for this.

and sorry for the late reply. i have posted a new question if you know anything about it, please guide me on that.

With Regards

Aghil

ok

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags