Pro/e vb api: A First Look (Preliminary Exploration of vb api for Secondary Development of Pro/E)

Source: Internet
Author: User
Tags api manual
Original: http://inversionconsulting.blogspot.com/2008/06/proe-visual-basic-api-first-look.html

ProE vb api Manual: http://www.kuaipan.cn/file/id_28189949127819279.htm

Welcome to Development Group 106930856

Obtain the password by yourself (both methods are acceptable)
1, password see this post (need to register for review), http://begtostudy.uueasy.com/read-htm-tid-9.html
Or
2, third-party address (need to register, do not need to review), http://www.linkedin.com/groups? Gid = 4436079

 

 

A peek under the hood of the new API for wildfire 4

In case you didn't know about it, PTC introduced a new PFC based API for Pro/Engineer, starting with Wildfire 4. it's called the vb api and it allows code to be written in Visual Basic that can communicate with Pro/Engineer. (For the curious, it does not work with older versions of Pro/Engineer, sorry)

Unlike Pro/WebLink, it is not limited to running in the embedded web browser. applications written with the vb api can be run almost anywhere that supports a Visual Basic environment (I. e. in an Excel macro ). it's important to understand how this new API works in order to understand some of its limitations and to write robust applications.

The API is an asynchronous pfc api, which means that it shares a set of core classes and methods which are mostly identical to Pro/WebLink and J-Link. it is asynchronous in that vb api applications run outside of the Pro/Engineer process (I. e. in Excel, Word, etc), but still can communicate and control the Pro/Engineer session.

Exe com server?

Similar to Pro/WebLink, it is implemented as a COM server, but (interestingly) not as a DLL. while a vb api application is running, an executable called "pfclscom.exe" starts and runs in the background. this introduces a major limitation.

Only one vb api program can run at a time, even if there are multiple Pro/Engineer sessions. if a second vb api application tries to start, it won't be able to connect to any Pro/Engineer session if the first one is still connected. as long as the first application has disconnected, the second connection will be successful.

This is a little disappointing, because one can have several asynchronous Pro/Toolkit applications connected to a single Pro/Engineer process at the same time. in fact, there cocould be any number of Pro/Toolkit applications connecting to any number of Pro/Engineer sessions. there is really no underlying technical restriction causing this limitation.

You had me at goodbye

Those familiar with asynchronous Pro/Toolkit and J-Link applications probably already know that the main steps in an asynchronous application are: 1) Connect to the Pro/Engineer session, 2) do some stuff, 3) Disconnect. while step 2 is somewhat optional, step 3 is absolutely critical.

The primary reason is that Pro/Engineer keeps track of all asynchronous connections, and considers connections that have not disconnected as "open ". unfortunately, there is a limit to the number of "open" connections, and that limit is surpisingly low.

If you have an asynchronous application that connects over and over with no disconnect, Pro/Engineer will eventually refuse any further connections. it doesn't matter if it's a Pro/Toolkit, J-Link, or vb api application. the limit is around 58-60 connections. that might sound a little high, but if you run vb api programs from an Excel macro over and over again, you might hit that limit pretty quick. if you disconnect properly, there shoshould be no limit to the number of times you can connect to a Pro/Engineer session.

You 'd think that with disconnecting being so important for asynchronous applications, it wocould deserve some special mention in the documentation. well, you 'd be wrong. sure, the disconnect () method is mentioned along with the varous flavors of the Connect () method, but there is no mention of the importance of disconnecting. you have been warned.

It it weren't broke, they wouldn't have fixed it

All is not perfect in Pro/engineer vb land however. don't waste your time with the c000 build of wildfire 4. the COM server that comes with the install won't allow any connections.

Another more minor issue has to do with "text message" files that nearly all Pro/engineer api's use. the "text" directory containing these files wocould normally be defined in a protk. DAT file. this is not used for asynchronous applications. instead, it is specified as part of the connection process. all of the Connect () methods have an argument that is supposed to identify the "text" directory.

For some reason, this argument is ignored by the vb api. as a result, only files in subdirectories of the Pro/ENGINEER install can be used (proe/text/usascii if your language is English ). it's not a major problem, but definitely an inconvenience if distributing your code to other users and/or companies.

"Happiness equals reality minus expectations"-Tom Magliozzi

Although I question the choice of an EXE based COM server, on the whole, PTC did a great job making the VB api fully functional and very consistent with its sibling API's (PRO/weblink and J-link ). while I find that Visual Basic has a kludgey syntax and a somewhat broken object model, the API itself gets the job done.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.