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

Setting Up VB API

MattWright
1-Visitor

Setting Up VB API

All,

I am attempting to setup/install the VB API component for Wildfire 5.0 on an XP machine.

  1. I set PRO_COMM_MSG_EXE to the pro_install\i486_nt\obj\pro_comm_msg.exe
  2. I ran ptcsetup.bat and installed the VB API
  3. I ran vb_api_register.bat, and am receiving the following error:
    1. "pro_install\i486_nt\obj\pfclscom.exe" is not recognized... yada yada translation it's not there. In fact, it is nowhere on my machine.

Any ideas?

Thanks in advance,

Matt Wright

ACCEPTED SOLUTION

Accepted Solutions

Hi Matt,

It cannot happen that a "vb_api_register.bat" exist in the bin folder and the pfclscom.exe is missing. This clearly tells me that the installion was incomplete.

So, could you please try reinstalling the product with Vb API component selected? This should fix your problem.

Thanks,

Seshu Kumar

Principal Engineer

Technical Support.

View solution in original post

28 REPLIES 28

Matt,

Did you ever figure this out? I am seeing the same problem on my computers.

Thanks,

Mark Bohannon

Hi Matt,

It cannot happen that a "vb_api_register.bat" exist in the bin folder and the pfclscom.exe is missing. This clearly tells me that the installion was incomplete.

So, could you please try reinstalling the product with Vb API component selected? This should fix your problem.

Thanks,

Seshu Kumar

Principal Engineer

Technical Support.

Hello Mr Seshu,

i have written this code but i am not connect with vb to proe and not opening the model through vb.net what chan I do Plz help me i had written this code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Dim componentFeat As pfcls.IpfcComponentFeat

'MsgBox("Feature number: " & componentFeat.Number)

Dim asyncConnection As IpfcAsyncConnection = Nothing

Dim cAC As CCpfcAsyncConnection

Dim session As IpfcBaseSession

Try

'======================================================================

'First Argument : The path to the Pro/E executable along with command

'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,

'non-interactive mode

'Second Argument: String path to menu and message files.

'======================================================================

cAC = New CCpfcAsyncConnection

asyncConnection = cAC.Start("D:\Program Files\proeWildfire 4.0\bin\proe.exe" + " -g:no_graphics -i:rpc_input", ".")

session = asyncConnection.Session

asyncConnection.Session.ChangeDirectory("D:\Test_Proe")

Dim descModel As IpfcModelDescriptor

Dim model As IpfcModel

descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_PART, "D:\ProEExample\test.prt", Nothing)

model = session.RetrieveModel(descModel)

Catch ex As Exception

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

Finally

If Not asyncConnection Is Nothing AndAlso asyncConnection.IsRunning Then

asyncConnection.End()

End If

End Try

End Sub

Hi Mohit,

To have a successful connection with Proe, you need to set PRO_COMM_MSG_EXE environment variable with correct path. Below is the documentation excerpt from VB API documenation. Please refer to this topic on how to set this environment variable. If you have a PTC.com user account, you could find technical articles on this in our Knowledge base. Try this and let me know.

Also, one should pass only the model name without the extension or path to (New CCpfcModelDescriptor).Create() function (second argument). The size limit for this string is 40 (39 + end of line).

Thanks,

Seshu

Setting Up a VB Application

For your application to communicate with Creo Elements/Pro, you must set the PRO_COMM_MSG_EXE environment variable to the full path of the executable, pro_comm_msg.exe. Typically, the path to the executable is [creo_loadpoint]/[machine type]/obj/pro_comm_msg.exe, where machine type is i486_nt for 32-bit Windows and x86e_win64 for 64-bit Windows installations.

Set PRO_COMM_MSG_EXE as:

    1. Click Start > Settings > Control Panel
    1. Click System. The System Properties windows opens.
    2. In the Advanced tab, click the Environment Variables button.
    3. Add PRO_COMM_MSG_EXE to System variables.

Registering the COM Server

To register the COM server, run the vb_api_register.bat file located at [creo_loadpoint]/bin.

To unregister the COM server, run the vb_api_unregister.bat file located at [creo_loadpoint]/bin.

After the COM server is registered with the system, whenever an application tries to access the types contained in this server the server starts automatically. By default, Windows starts services such as pfclscom.exe in the Windows system directory (c:\winnt\system_32). Because the server will also start new sessions of Creo Elements/Pro from the process working directory, you may want to control the server run directory. You can configure the server to start in a specific directory by setting the system environment variable PFCLS_START_DIR to any existing directory on your computer.

Hi Seshu,

Good morning, thanx for your quick reply... I have registered vb_api and setting environment variable my program is running fine but model is not openining only PROE wildfire 4.0 working area is open. Here is my code?? Please help me.. Below is my code......

Dim asyncConnection As IpfcAsyncConnection = Nothing

Dim cAC As CCpfcAsyncConnection

Dim session As IpfcBaseSession

Try

'======================================================================

'First Argument : The path to the Pro/E executable along with command

'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,

'non-interactive mode

'Second Argument: String path to menu and message files.

'======================================================================

cAC = New CCpfcAsyncConnection

asyncConnection = cAC.Start("D:\Program Files\proeWildfire 4.0\bin\proe.exe" + " -g:no_graphics-i:rpc_input", ".")

session = asyncConnection.Session

'======================================================================

'Set working directory

'======================================================================

asyncConnection.Session.ChangeDirectory("D:\Program Files\proeWildfire 4.0\TestModels\")

'======================================================================

'VB api process calls and other processing to be done

'======================================================================

Dim descModel As IpfcModelDescriptor

Dim model As IpfcModel

descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_PART, "el2.prt", Nothing)

model = session.RetrieveModel(descModel)

Catch ex As Exception

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

Finally

'======================================================================

'End the Pro/ENGINEER session when done

'======================================================================

'If Not asyncConnection Is Nothing AndAlso asyncConnection.IsRunning Then

' asyncConnection.End()

' End If

End Try

Hi Mohit,

Do any of the existing functions throw any exceptions? if yes, please let me know which function and what exception. If none of the functions are throwing exception, then it meanse that the model is successfully retrieved. However, you won't be able to see it because you are not displying the model by calling model.Display(). RetrieveModel() function just retrieves the object in to Pro/ENGINEER Session. But, will not display it in the graphics window. One need to call Diaplay() function to be able to see the model.

Also, you are running Pro/ENGINEER in no graphics mode. if you remove the additional string + " -g:no_graphics-i:rpc_input" that is being passed to the Pro/ENGINEER Start command, then you should see Pro/E lanuching and the model would be displayed in the graphics window.

Thanks,

Seshu

haåman
10-Marble
(To:sgudla)

Hello Seshu,

Thank you for providing clear step-to-step instruction for starting the VB API. My question is:

I have setup the environment variable but do not find the vb_api_register.bat.. Do I need to re-install Creo?

Thank you in advance!

Hi Heidi,

If your <Creo Load Point>\Parametric\bin folder does not contain the "vb_api_register.bat" file, it means that either you did not chose to install the VB API customization files Or the installation is incomplete. So, I would suggest a re-install.

Thanks,

Seshu

haåman
10-Marble
(To:sgudla)

Thank you Seshu, I got it to work

Hello Sir,

I have to open Proe using vb program, but it opens and automatically it is closed. Please give me a sample program how to open proe using vb. Here is my sample code.

im asyncConnection As IpfcAsyncConnection = Nothing

Dim cAC As CCpfcAsyncConnection

Dim session As IpfcBaseSession

Try

'======================================================================

'First Argument : The path to the Pro/E executable along with command

'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,

'non-interactive mode

'Second Argument: String path to menu and message files.

'======================================================================

cAC = New CCpfcAsyncConnection

asyncConnection = cAC.Start("D:\Program Files\proeWildfire 5.0\bin\proe.exe" + "-g:graphics-i:rpc_input", ".")

session = asyncConnection.Session

'======================================================================

'Set working directory

'======================================================================

asyncConnection.Session.ChangeDirectory("D:\Program Files\proeWildfire 5.0\bin\TestModels")

'======================================================================

'VB api process calls and other processing to be done

'======================================================================

Dim descModel As IpfcModelDescriptor

Dim model As IpfcModel

descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_PART, "el2.prt", Nothing)

model = session.OpenFile(descModel)

Catch ex As Exception

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

Finally

End Try

Hi Mohit,

In the code you are using, you are not calling any function that would close Pro/ENGINEER after completing the

required task. So, Pro/ENGINEER should not close on its own.

So, without calling IpfcAsyncConnection.End(), if your ProE is closing, then I suspect that something is going wrong in the code which might be causing a premature exit. Debug the code and see after which function ProE is exiting. You may also try writing some lines to a log file after each function to see if the code is executing completely or existing.

To close Pro/ENGINEER from VB code, one should use IpfcAsyncConnection.End().

Thanks,

Seshu

Dear Seshu,

Thanx for ur reply

ProeError111.jpg

Please solve this error its urjent.

Why this error is comming.. this error is comming every time what can I do Please help me

Hi Mohit,

I work in US time zone. So, cannot reply to this post in your time zone. Hence, there will be some delay in my replies.

Regarding the error, this error is thrown when your VB application is attempting to connect to Pro/ENGINEER. Please note that the failure resons could be multipel and it depends on the conditions that exist on the machine at the time of connection attempt is made. I need to look at the machine to find the exact reasons for the connection failure. I cannot do this through this post. I would request you to contact PTC Technical Support if you need immediate help and solution for this issue.

Or you could go through the below given technical articles and try the suggestsions.

https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS59132

https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS46034

https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS129789

https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS53658

https://www.ptc.com/appserver/cs/view/solution.jsp?n=CS82236

Thanks,

Seshu

Thanx a lot for ur help

one error is comming the error is

errorPTC.jpg

Below is my code wich gives this error why?????????? Please

Dim asyncConnection As IpfcAsyncConnection = Nothing

Dim cAC As CCpfcAsyncConnection

Dim session As IpfcBaseSession

Try

'======================================================================

'First Argument : The path to the Pro/E executable along with command

'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,

'non-interactive mode

'Second Argument: String path to menu and message files.

'======================================================================

cAC = New CCpfcAsyncConnection

asyncConnection = cAC.Start("D:\Program Files\proeWildfire 4.0\bin\proe.exe" + " -g:no_graphics-i:rpc_input", ".")

'asyncConnection = (New CCpfcAsyncConnection).Start("D:\Program Files\proeWildfire 5.0\bin\proe.exe", "D:\Program Files\Wrkdir\txt")

'asyncConnection = cAC.Start("D:\Program Files\proeWildfire 5.0\bin\proe.exe" + "", ".")

session = asyncConnection.Session

'======================================================================

'Set working directory

'======================================================================

asyncConnection.Session.ChangeDirectory("D:\ProEExample")

'======================================================================

'VB api process calls and other processing to be done

'======================================================================

Dim descModel As IpfcModelDescriptor

Dim model As IpfcModel

descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_PART, "prt0001.prt", Nothing)

model = session.OpenFile(descModel)

Catch ex As Exception

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

Finally

End Try

hello Mr Seshu,

Can you help me how to get excel values in the current model. and how to regerate the model. I am so many time but the values are not set please give a sample program or procedure to help me. please help me Can you give your Number I need your help. Plz Help me

Please try searching in our online Knowledge Base. You should find good number of example codes for Creo VBA excel example codes.

Thanks,

Seshu

Hello,

could you please help me out.

I am using Creo/Elements Pro M210 without Pro/Toolkit license and want to use VB API.

PRO_COMM_MSG.EXE and PFCLSCOM.EXE are running fine.

When I try to connect to the session with:

Dim asyncConnection As IpfcAsyncConnection =Nothing

asyncConnection = (New CCpfcAsyncConnection).Connect(Nothing, Nothing, Nothing, Nothing)

I get following exception: XToolkitNeedsUnlock

Was there any change in the WF5 because I thought that VB API can be used without any license.

Again Pro/Toolkit license is not available.

Appreciate any help. Thanks

Hi Sven,

This is a known issue already reported and fixed. Please see SPR 2205159 and technical Article CS153281

This issue is corrected in M220 date code which will be available for download on 31-Jan-2014. You may switch to M200 date code OR contact PTC Technical Support to have the pfclscom.exe unlocked.

Thanks,

Seshu Kumar

Hi Seshu,

Thanks a lot for that !

thanx Seshu,

But I have some problem the software AMC is finished my comp has not taken AMC the links are reqired AMC. he links are not open. how can i work please help me yarr i am in very thanfull to you please help me give me your number if you dont have any problem.

Zynk
5-Regular Member
(To:sgudla)

Hi all,

How to ftech creo installed path in VB.net? is there any system commands like %temp% and %appdata%

 

 Fetching from environment variables is the only way? please let me know...

 

~Zynk

ptc-4508290
2-Explorer
(To:Zynk)

you have to write your own algorithm... here is what i wrote... hope it helps.

 

Public Shared Function CreoParametricRootDirectory() As String
Try
Dim dirLocalProgramFiles As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)).Replace(" (x86)", "")
Dim tProRootDir As String = ""
For intVersion As Integer = 1 To 100
For intRelease As Integer = 10 To 400 Step 10
Dim strRelease As String = ""
If intRelease < 100 Then
strRelease = "0" & intRelease.ToString
Else
strRelease = intRelease.ToString
End If
tProRootDir = IO.Path.Combine(dirLocalProgramFiles, "PTC", "Creo " & intVersion.ToString & ".0", "M" & strRelease)
If IO.Directory.Exists(tProRootDir) Then
Exit For
Else
tProRootDir = ""
End If
Next
If tProRootDir <> "" Then Exit For
Next
If tProRootDir = "" Then Throw New Exception("Unable to find Creo Parametric Root Directory.")
Return tProRootDir
Catch ex As Exception
Return ""
MessageBox.Show(ex.Message)
End Try

End Function

What if I installed Creo correctly with VB API options selected at install. Added the system environment variable 'PRO_COMM_MSG_EXE' pointing to <creo_loadpoint>\<datacode>\Common Files\<machine_type>\obj\pro_comm_msg.exe and used the vb_api_register.bat in the <creo_loadpoint>\<datacode>\Parametric\bin directory. However, the COMM reference still will NOT show up when trying to add to my project in VS 2017. Also, I followed the same setup instructions on another machine and it worked great. I am not sure what is wrong here but do you have any ideas? 

I am able to get session object with Administrator access but on same system, one of my colleague who is not having admin access rights is getting error of toolkitnotfound exception....

Appreciate any help on this..

Regards

Ketan

Hi

In general, running VBA apps in Creo does not require any local admin permissions.

However, before you can run any VBA apps you need to run the vb_api_register.bat on all clients; and this will typically require local admin (this .bat registers some DLL's required by the API)

The thing is that if you run the vb_api_register.bat on a client without local admin permissions there is no error message displayed and you may assume that everything is OK while in fact it is not.

Hi,

Thank you very muech for your concern on this issue.

We have run vb_api_register.bat with local admin permissions and same is allowing us to build project.

Issue we are facing is as below in detail:

Case - 1 :

- Working fine with Admin Permission but not working without admin permission. Exception we got is the different one for different users. One is getting toolkitcantmodify whereas other fellow is getting toolkitnotfound exceptions.

All of us are using same system and same code. We are running application from source code rather than double clicking on application executable.

Case - 2 :

- Working fine with Admin Permission as well as without admin permission on different computer used in case - 1. These all users are also referring same code which are used by people of case - 1 and runs application from source code.

Case - 3 :

- Not Working fine with Admin Permission as well on client location. These all users are also referring same code which are used by people of case - 1 and runs application using application executable.

To conclude, as per my understanding, it has nothing to do with admin permission once we have registered bat file. This has something to do with users and systems but i m not able to figure out what is missing.

Any help on this is most welcome.

Thanks and Regards

Ketan

Announcements


Top Tags