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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

VBA Macros/API for Creo

VBA Macros/API for Creo

Mapkeys are pretty very useful to script many simple things in Creo. However they are limited as they don't offer more advanced tools like If-Then statements, variables, custom GUI's, etc. The problem with many/all of the existing Creo APIs is that they usually require IT help in trying to program Creo and IT usually knows very little about CAD. Solidworks and Inventor (and probably other 3D CAD software) have VBA Macros that let their users solve many of their own problems without needing IT.

 

Creo VBA Macros:

  • VBA Macros within Creo would be installed and ready to use by default in all versions of Creo. Most of the current Creo APIs require installing the APIs and turning on lots of different settings so new users struggle simply getting the API turned on. Many Creo users don't have permissions to install software on their computers or create system variables.
  • The ability to record Creo button clicks into VBA code. This is often a great starting point for users.
  • Use the free VBA Editor to easily edit the VBA code directly from Creo and easily create GUI forms/menus. VBA doesn't require users to compile code and users wouldn't have to buy/install software like Visual Studio.
  • VBA works great with Excel and should allow user to drive Excel or Excel to drive Creo.
  • VBA has a large online support. With VBA turned on by default, users could easily share code with each other or create YouTube videos to share with each other.
  • If Creo would have an official way to share VBA code/add-ins with the Creo community, PTC would also get good ideas for future Creo improvements.
  • The VBA macros help documentation should be easy to access and easy to understand with lots of example code.
  • Maximum functionality. Some of the current Creo APIs are fairly limited: the current VB API is limited only to asynchronous mode and fairly limited set of commands. Please provide enough functionality to be useful or the maximum functionality previously allowed in other free APIs.
  • Combining VBA macros and Mapkeys would be awesome.
  • Ability to write custom ModelChecks in VBA macros would be awesome.
4 Comments
sparadis
3-Visitor

I just went through the ordeal of beginning to learn the API world/mess of Creo. I settled on the Jlink API after reading some posts online, but I think it won't be supported in Creo 5, so I stopped and i'm waiting to see what will come up. A complete and easy to use VBA API with COM support and decent documentation would be a minimum I think. PTC, plz have a look at AutoIT's documentation and learn how it's done! It is an open source code for christ sake and your solution is so far behind it's not even funny!

I learned how to use AutoIT in a matter of days and was able to write a script that took control of Excel and Inventor to update thousands of drawings (update revision, change revision symbol, change drawing frame, change notes, etc) after only a few dozen hours of work. I cannot even imagine how much time it would take to do the same with Creo... The Inventor VBA API was "free" (included) with full fonctionnality as far as I can tell and has very good documentation (light years ahead of what PTC offers now for JLink and VBA).

lhoogeveen
17-Peridot

@sparadis Definitely agree. Not sure if I should simply the idea above (too much text?) but Solidworks and Inventor are way ahead here. Here's the Inventor Store where people can share code. And here's the out of the box, easy/ready to use VBA Macros/Editor in Inventor.

Inventor VBA Macros.jpg

 

lhoogeveen
17-Peridot

I've recently figured out how to get the free Creo VB API working with VBA from Excel. The Creo VB API can be accessed from multiple programing languages.

  • Follow the steps outlined in CS141739 - How to install and register Creo VB API Toolkit component in Creo Parametric
    • Unfortunately, the Creo VB API is not installed by default and requires admin access to install the Creo VB API and register vb_api_register.bat. This makes it difficult to share VBA projects at many companies unless your IT team includes the VB API in the Creo install package. It might also be a good idea install the free J-LINK API at the same time as it could allow for using things like CREO|SON (haven't used it yet).
  • In the Excel VBA editor, go to Tools>References and add the reference "Creo VB API Type Library for Creo Parametric 4.0" or whatever version of Creo you're using. Not sure if this reference needs to be manually updated when switching Creo versions (Creo 4 to Creo 7).
  •  Find example code or help documentation:
    • PTC has posted several examples on support.ptc.com. Search for 'VBA' or 'VBA example' and content type = 'articles'.
    • Once the Creo VB API is installed, look in the "<install location>\Common Files\vbapi" folder.
      • The vbbug.pdf documents the various API functions available
      • In the 'vbapi_examples' folder you can find example VB code.
        • I did not find the example 'Async_Mode_Example.xls' useful.
        • You can open the .vb example files in a text editor and try to adapt them to VBA code. Note VB is not equal to VBA. Things like Try-Catch do not exist in VBA and will have to be rewritten but at least you can see examples of the Creo VB API functions being used.
olivierlp
Community Manager
Status changed to: Archived

Hello,

We are archiving your idea as part of a general review. This action is based on the age of your idea and the total number of votes received, as per this announcement.

You can always post a new idea with all the details required in the form.

Thank you for your participation.