Creating a New VSTA Project
This tasks explains how to create a new VSTA project.
Select the Tools > Macro > Macros... command
to display the Macros dialog box:
Click the Macro Libraries... button to display
the Macro Libraries... dialog box:
Select PLM VSTA projects as the Library
type then click the Create new library... button:
to display the New VSTA project dialog box:
Select the Macro language.
The macro language can be:
then click OK.
Name the project in the following dialog box:
then click the Finish button.
A progress bar appears while the new project is created in
the ENOVIA V6 database.
In the the Macro Libraries... dialog box:
click the Close button.
Clicking the Close button loads the project into
the VSTA IDE environment. This will take a few seconds.
Opening an Existing VSTA Project
This task explains how to open an existing VSTA project.
Select the Tools > Macro > Macros... command
to display the Macros dialog box:
Click the Macro Libraries... button to display
the Macro Libraries... dialog box:
Select PLM VSTA projects as the Library
type then click the Add existing library... button:
to display the Macro Library Chooser dialog box:
Enter * in the search field and click the Search
button to display the projects saved in the database:
Select the project:
then click OK to display the Macro Libraries...
dialog box:
Note that the Remove selected library button deletes
the macro library from the current session, but does NOT delete
it from the database.
Click the Close button to load the project
into your current session:
Creating, Editing, Renaming and Deleting Macros in a VSTA Project
This task explains how to create, edit, rename and delete macros in a VSTA project.
With the current macro library selected:
click the Create... button to display the Create
a new macro dialog box:
Select the Macro language and the Macro name.
The Macro name must begin with the string "Macro". Any attempt
to assign a different name will produce an error.
Click the OK button.
The macro name is displayed in the Macros dialog
box:
To edit the macro, click the Edit... button
to open the VSTA IDE editor:
Check the Activate debug mode check button to run
the editor debug mode allowing you, for example, to place breakpoints.
To delete the macro, select the macro and click the
Delete... button:
To rename the macro, select the macro and click the
Rename... button:
Rename the macro and click OK.
The Macro name must begin with the string "Macro". Any attempt
to assign a different name will produce an error.
Solving Buildtime and Runtime Errors
This task explains how to solve buildtime and runtime errors.
The following tutorial will show you how to simulate and solve buildtime
and runtime errors, that you are likely to face when developing VSTA macros.
Navigate to Tools>Macros>Macros...
Click Macro libraries.
Choose PLM VSTA Project in the combo box.
Click Create new library. Choose C#, and click
OK.
Select an appropriate name in the PLM New
window. Click OK.
The empty VSTA project is created.
Create a new macro named "Macro1".
Edit it as follows:
public void Macro1(){System.Windows.Forms.MessageBox.Show(CATIA.FullName);}
Go back to CATIA, re-open Tools>Macros>Macros...,
the macro project should build in the background, and if you run Macro1,
the message box should be displayed showing the full path to your installation
of CATIA.
Introduce a build-time error as follows (the semicolon is missing):
public void Macro1(){System.Windows.Forms.MessageBox.Show(CATIA.FullName)}
Go back to CATIA, re-open the Macros GUI, you get the
following error:
Edit the macro, remove the build-time error. Introduce
a run-time error as follows (there is no editor currently opened in
CATIA, hence we cannot get the active object's name):
public void Macro1(){System.Windows.Forms.MessageBox.Show(CATIA.ActiveEditor.ActiveObject.get_Name());}
If you go back to CATIA, and re-open the Macros GUI,
Macro1 is displayed. Run it. You get the following error:
Edit the macro, add a breakpoint (F9) on the faulty
source line:
Go back to CATIA, check the Activate debug mode
check button, and run the macro. The VSTA IDE should stop on your breakpoint
and display the source code:
Check that you can watch some variables, as when debugging
inside Visual Studio. Next press F8 to execute the faulty
line. You will get a message box in CATIA (note that the error line
is now displayed):
You may now correct the error.
|