PTC Creo customization using VB API - Lecture 1 - Overview

21,830 views

Published on

Published in: Education, Technology

PTC Creo customization using VB API - Lecture 1 - Overview

  1. 1. PTC Creo customization using VB API Lecture 1 - Overview http://www.learncax.com/ Centre for Computational TechnologiesCCTech Recruitment Brochure Simulation is The Future!
  2. 2. Outline1. Introduction2. VB Applications for Creo3. Setup4. Object Types – Creo Parametric-Related Classes – Compact Data Classes – Union Classes – Sequence Classes – Array Classes – Enumeration Classes – Module-Level Classes – ActionListener Classes Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  3. 3. Reference• Creo™ Parametric VB API User’s Guide Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  4. 4. Prerequisites• This course assumes you have the following knowledge: – Creo Parametric – Visual Basic .NET 2010• Other languages with the built-in capability to use COM servers: • JavaScript • VB.Script • C++ • C# Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  5. 5. Basic goal• Teach you the to customization of Creo using Visual Basic API Toolkit to create your own applications Images courtesy of Orphiro. Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  6. 6. Introduction• VB interface for Creo is free-of-cost interface• However, it has limited functionality as compared to other interfaces It allows the development of VB.NET programs to access the internal components of a Creo session, to customize models. With VB being a object oriented programming tool, the Creo user gains a powerful tool for expanding, customizing and automating the functionality of Creo and Windchill.VB integrate with MS Office tools very easily and is part of the PTC Foundation Class (PFC) package. Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  7. 7. Benefits• No Separate or Additional Licensing• Hardware Platform Independent• Seamlessly embed process• Asynchronous Application• Object Reuse• Create GUI easily• Free VB.Net IDE• Fully Supported Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  8. 8. Asynchronous application• VB API for Creo Parametric is an asynchronous application• Can be used from COM-enable application such as : – Visual Basic.NET (VB.NET) – Visual Basic for Applications (VBA) – Even Internet Explorer instances using scripting Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  9. 9. Typical Visual Basic.NET Applications 1• You can use the VB API for Creo Parametric to: – Create a VB.NET form capable of starting or connecting to Creo Parametric non graphically, accepting user inputs and driving model modifications or deliverables Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  10. 10. Typical Visual Basic.NET Applications 2• You can use the VB • This could be user API for Creo Parametric define feature code to: • This could be a plugin – Create a VB.NET application that may or may not have its own User Interface (UI). The application should be able to establish one or more Creo Parametric UI or event listeners in session, and process those events using VB.NET code Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  11. 11. Visual Basic for Applications• Access to and from Creo to COM products such as – Microsoft Excel – Microsoft Word – Microsoft Access – The COM interface• Limitations of the VB API – The asynchronous COM server has the following limitations: – API calls from single thread – Internally application can have many threads – Only one active connection to Creo Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  12. 12. Set up• PRO_COMM_MSG_EXE environment variable – <creo_loadpoint>/Common Files/<Machine type>/obj/pro_comm_msg.exe• Register the COM server – vb_api_register.bat• Unregister the COM server – vb_api_unregister.bat Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  13. 13. Project References for the VB API Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  14. 14. Project References for the VB.NET environment Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  15. 15. Object Types• Creo Parametric-Related Classes – Contain unique methods and properties that are directly related to the functions in Creo Parametric• Compact Data Classes – Classes containing data needed as arguments to some VB methods.• Union Classes – Classes with a potential to contain multiple types of values• Sequence Classes – Expandable arrays of objects or primitive data types• Array Classes – Arrays that are limited to a certain size Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  16. 16. Object Types• Enumeration Classes – Enumerated types, which list a restricted and valid set of options for the property• Module-Level Classes – Contain static methods used to initialize certain VB objects• ActionListener Classes – Enable you to specify code that will run only if certain events in Creo Parametric take place. Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  17. 17. Creo Parametric-Related Classes• Contain methods that directly manipulate objects – Examples of these objects include models, features, and parameters.• Initialization – Cannot construct one of these objects using the keyword New – Obtain the handle to a Creo Parametric-related object by creating or listing that object with a method on the parent object in the hierarchy – For example, IpfcBaseSession.CurrentModel returns a IpfcModel object set to the current model and IpfcParameterOwner.CreateParam returns a newly created parameter object for manipulation• Properties – They are directly accessible – Might be read-only Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  18. 18. Creo Parametric-Related Classes• Methods - Has to be invoked from initialized object – Following is incorrect Dim window as pfcls.IpfcWindow; window.Activate(); ‘ The window has not yet been initialized. Repaint(); ‘ There is no invoking object. – The following calls are correct: Dim window As Pfcls.IpfcWindow Dim session as pfcls.IpfcSession Dim asyncConnection as pfcls.IpfcAsyncConnection Dim Casync as New pfcls.CCpfcAsyncConnection asyncConnection = Casync.Connect (DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value) session = asyncConnection.Session; window = session.CurrentWindow; You have initialized the window object. window.Activate() window.Repaint() Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  19. 19. Creo Parametric-Related Classes• Inheritance – Many object inherit methods from other interfaces – For example, an IpfcComponentFeat is derived from – IpfcObject – IpfcChild – IpfcActionSource – IpfcModelItem – IpfcFeature – IpfcComponentFeat – You can call the method directly eg: Dim componentFeat as pfcls.IpfcComponentFeat MsgBox ("Feature number: " & componentFeat.Number); – Or you can create object particular class and call eg: Dim componentFeat as pfcls.IpfcComponentFeat Dim feat as pfcls.IpfcFeature feat = componentFeat MsgBox ("Feature number: " & feat.Number); Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  20. 20. Compact Data Classes• Data-only classes• Other than initialized, compact data classes are similar to Creo Parametric-related classes• Initialization – You can create these compact data objects using a designated Create method which resides on the CC version of the compact class – Instantiate the CC class object with the keyword New – For example, Class object, owns Create() Dim tableCellCreate As New pfcls.CCpfcTableCell Dim tableCell As pfcls.IpfcTableCell Set tableCell = tableCellCreate.Create(1, 1) Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  21. 21. Unions• Can containing different value types• Discriminator property with the predefined name, discr – returns a value identifying the type of data• Different properties for accessing the different data types Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  22. 22. Sequences• Expandable arrays of primitive data types• Methods – Append()—Adds a new item to the end of the array – Clear()—Removes all items from the array – Insert()—Inserts a new item at any location of the array – InsertSeq()—Inserts the contents of a sequence of items at any location of the array – Set()—Assigns one item in the array to the input item – Remove()—Removes a range of items from the array Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  23. 23. Arrays• Groups of primitive types or objects of a specified size• Properties – Access using the Item property or directly as an array: Dim point as IpfcPoint3D Dim matrix as IpfcMatrix3D MsgBox (“Y value of point: “ & point.Item (1)) MsgBox (“(2, 2) value of matrix: “ & matrix (2, 2)) Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  24. 24. Enumeration Classes• an enumeration class defines a limited number of values that correspond to the members of the enumeration• In the EpfcFeatureType enumeration class, the value EpfcFEATTYPE_HOLE represents a Hole feature• Enumeration classes generally have names of the form EpfcXYZType or EpfcXYZStatus Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  25. 25. Module-Level Classes• Module classes have the naming convention, CM+ the name of the module, for example CMpfcSelect• Initialization – create instances of these classes directly by instantiating the appropriate class object: Dim mSelect as New CMpfcSelect• Methods – Module-level classes contain only static methods used for initializing certain VB API objects Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  26. 26. Action Listeners• Action Listeners notify you of events in Creo Parametric• They are the basis for customization of the Creo GUI• ActionListeners are not supported from VBA• Initialization – Create a class implementing the listener in question. It should define all the inherited methods, even if you want to only execute code for a few of the listener methods. Those other methods should be implemented with an empty body. – The class should also implement the interface IpfcActionListener, which has no methods. – The class should also implement ICIPClientObject. This method defines the object type to the CIP code in the server. – This method returns a String which is the name of the listener type interface, for example, IpfcSessionActionListener. Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!
  27. 27. Thank You Mail Us @ sandip@cctech.co.in Visit Us @ www.cctech.co.in Call Us @ +91 20 4009 8381/82 Mobile @ +91 98508 60725 Centre for Computational Technologies Pvt. Ltd. Development Centre 1, Akshay Residancy, 50 Anand Park, Aundh, Pune -7 Centre for Computational TechnologiesCreo customization using VB API Simulation is The Future!

×