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:
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
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
I don't think is posible, you have to create the constraint in another way...search in v5automation file
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
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
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
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 SubBut this dosen't seem to work either.
Regards,
Skorpan
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
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
RE: Catia v5 VBA, StartCommand "Constraint" doesn't give the expected result
I don't think is a bug in CATIA...
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...