Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share catia macros 3

Status
Not open for further replies.

Smileyoer

Mechanical
Dec 31, 2018
16
0
0
HU
Hello all,

I have created a macro userform for Catia with several modules underneath and calling them.
My question is that how can I share this catvba project with others, while they can run the userform but they are not able to see my code. I dont want to share my code with others but they have to run it somehow.
I tried macro protection but in that case they can only use it if they know the password, soes it is not okay.
Maybe calling the userform from another project.

Do you have any idea for that?

Thank you in advance!
 
Replies continue below

Recommended for you

Yeah maybe you are right, but I create a ribbon menu with an icon to run the userform from it. But there is no option to run it only the modules appaer so I can attach them for the button.

I tried to write a module which call the userform when the user run it. It is also appaer when I tried to attach it to the icon, but it doesnt work.

Am I doing it wrong, or do you mean on anything else?
 
Hi

You can call a specific module from a catvba file with a CATScript and for this CATScript you can assign an icon in a (eventually) new toolbar.

Code:
Sub CATMain()

Dim param()
Dim oFilePath, oFileName, oModule As String
Dim oSystemService As Variant
Set oSystemService = CATIA.SystemService


oFilePath = "C:\Temp\"
oFileName = "Test.catvba"
oModule = "Grid"   ' module name

Dim ss as Variant
Set ss = Catia.SystemService
ss.ExecuteScript oFilePath & oFileName , catScriptLibraryTypeVBAProject , oModule , "CATMain" , param

End Sub

Regards
Fernando

- Romania
- EU
 
... and param is an array of the parameters you want to pass into CATMain, i.e param(0)=x, param(1)=y, param(2)=z, CATMain(x,y,z)

regards,
LWolf
 
Hello,
Thank you for the answers.

@ferdo: Is this solution working if my catvba project is really complicated and i have at least 11 modules underneath the userform? I mean, that can i initialize the userform, or i can manage the modules umder it?

So my main goal is that i can make a button on a toolbar which initialize the userform, so i can protect my code from curious eyes... 😁

I hope you will understand my side.

Thanks for previous answers again.
 
Just move you're code to external application (.exe). Probably best way would be to use Visual Studion Express or any free IDE. This means that you would need to recreate the forms, but you should be able to convert relatively easy the code. In this way you could protect the code you make and use full power of vb.net. For the application that I do, I read the PC user and allow only desired users to use the application for a desired time.
 
Hello,

Yes i have seen that creating the code in VB.net will be a good solution, but because of the lack of license its sadly not an option.

@Ferdo:
I tried this code, but it doesnt work for me:
Sub CATMain()

Dim param()
Dim oFilePath, oFileName, oModule As String
Dim oSystemService As Variant
Set oSystemService = CATIA.SystemService


oFilePath = "C:\Temp\"
oFileName = "Test.catvba"
oModule = "Grid" ' module name

Dim ss as Variant
Set ss = Catia.SystemService
ss.ExecuteScript oFilePath & oFileName , catScriptLibraryTypeVBAProject , oModule , "CATMain" , param

End Sub


I have an userform called Userf1.
I create underneath this userform a module called Run, which contains:
Userf1.show modeless.

I want to run this "Run" module whith a catscript, and launch it with an icon.

I passed the path and name of the code corectly, no error message appeared, but nothing happens.


Any idea what is the problem?
 
Hello,

1. Catia V5 R19. I use win10 , x64
2. Correct
3. Correct
4. Correct

The code runs, but it didnt do anything.
I dont know what could be the problem...
 
Status
Not open for further replies.
Back
Top