×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
Hi,

I'm currently learning to program Catia v5 in VBA. I've done a bit of VBA programming before as well as some other languages (Java, C++ and PHP primarily).

At the moment I'm trying to create a toolbar that, among other things, has buttons, which mimic the command buttons in the default Catia toolbar. I've found the CATIA.StartCommand function to be very useful but when it comes to constraints it doesn't work as I expect.

In my script I want to start the Constraint command (the one used to dimension a sketch in the Sketcher workbench). I looked in the command list (view->commands list...) and found "Constraint" for the dimensioning tool and "Constraint..." for the "Constraint box" (the one where you can only put geometrical constraints). I tried with this:

CODE --> VBA

Sub CATMain()
    CATIA.StartCommand ("Constraint")
End Sub 

and I also tried writing "c:Constraint" in Catia's command box (not sure what it's called but the box at the bottom where you can write your commands instead of clicking the icons).

None of these attempts give me the Constraint command I'm looking for. Instead if I select the sketch element I want to constrain I get the "Constraint box".

How to I start the "Constraint" command from VBA instead of the "Constraint Box"?

Regards,
Skorpan

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
Hi,

Thank you for your reply!

The problem is that I'm not actually trying to create dimensions (constraints) per se. What I want is to mimic the functionality of the button in the Constraint toolbar. So when someone pushes the button I create in VBA I want them to get the same result as if they pushed it in the original toolbar.

In itself it might seem like an unnecessary thing to create but it's part of a bigger project where the implementation makes sense :)

Unfortunately I don't have the v5automation help installed on this computer. I'll see what I can find out when I get back to work, until then I'd we very grateful of any and all information I could get on the subject.

Regards,

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
To add to my previouspost. Since every other command is possible to run through the power bar (I belive that's what the little text box at the bottom of the Catia window is called), why would the Constraint/Dimension command not be possible?

It is also possible to run the command through the "Commands List" although I susspect that Catia is not showing the correct ID for the command.

Regards,

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
That is basically what I want to happen. After the button has been pressed I want the user to pick the sketch element/-s he/she wants to dimension. I'm not trying to set the dimension/constraint in this way I'm only trying to start the command so the user can set them (by picking in the sketch).

I'm now trying to use SendKey like this:

CODE --> VBA

Sub CATMain()
    ' CATIA.StartCommand ("Constraint")
    MsgBox "Attempting to start a Constraint"
    CATIA.RefreshDisplay = True
    SendKeys "%(i)coc"
End Sub 

But this dosen't seem to work either.

Regards,
Skorpan

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
Do you really get that if you run that statement? I only get an error message saying "Unavailable Command" if I run that in a sketch. Or if I first select a sketch element and then run it, I get that box where you can choose constraints (but not make dimensions). :(

I'm running Catia v5R20 ServicePack 1, could it be that they have changed something between versions?

Regards,
Skorpan

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
That is so unfair :o I do exactly the same thing but I get the error explained before :(

Could it be a bug in the version of Catia I'm running?

I also notice you use a different editor commpared to me, do you also use an other type of script?

When I start a new script I go to (in Catia) Tools->Macro->Macros and click "Macro libraries..." choose "VBA projects" as Library type Click "Create new library...". After I decide a name and place I click ok->close->create. I then choose "MS VBA" as Macro Language and type a name and click "ok". When I click "Edit..." I come to the same Editor which office uses (Microsoft Visual Basic). Could this be a source for trouble maybe I get stuff in the file that I can't see but messes up something?

Thanks for taking the time!

Regards,
Skorpan

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

(OP)
I should say that I tried to use CATScript and MS VBScript with the same result as I got in VBA. And when I start script in those other two variants I don't get the option to start my script directly from the editor like you did.

RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result

I'm using Scite Editor, with some modification done by me for properties file, just because I like how is looking (colors for different statements, variables, a.s.o.). I've added also the CATScript and catvbs among files which can run directly from the editor (I'm not using something else). You can do same thing with Notepad++ if you like it more.

I don't think is a bug in CATIA...

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources