3

I'm trying to create a toolbar in Catia. This toolbar (based on a VBA form) will have buttons which should start Catia Commands (among other things). One of the commands I'm trying to start is the "Constraint" command (which should allow you to place dimension to sketch elements 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" (which opens a box where you can set geometrical constraints, which is not what I want). I tried with this (the simplest case):

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

and I also tried writing "c:Constraint" in Catia's command field at the bottom of the window.

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

How do I start the "Constraint" command (used for dimensions) from VBA instead of the "Constraint Box"?

Regards, Christian

EDIT: Fixed some minor spelling mistakes

Christian Eriksson
  • 2,038
  • 2
  • 22
  • 28

3 Answers3

0

Be careful that starting commands by name is locale-dependant. It means you should type "Constraint" in an english CATIA, "Contrainte" in french, etc... Here is a good article on StartCommand, giving a few ways to find command names : http://v5vb.wordpress.com/2010/01/20/startcommand/

By the way, I tried both english and french and on my CATIA R20, it actually launches the command (waiting to select an element to constraint.) Be careful to be :

  • in sketcher
  • with no other command running
Zzirconium
  • 431
  • 1
  • 10
  • 32
  • Hi thanks for your answer. Don't mean to question you but are you sure u run R20 and if so what service pack? I've tried this on multiple setups with R20 (SP1) and R19 (2 different but don't remember which ). I've even asked friends to try it out on their setups but no one have been able to start the Constraint command that way. Perhaps they fixed something later on in R20? – Christian Eriksson Nov 16 '13 at 13:53
  • I tested on R20 SP7... I might be able to test on earlier SP someday. – Zzirconium Nov 17 '13 at 21:26
  • Interesting there might have been some update during R20 then. If you get the chance to try an earlier SP at any point please share what you find. Thank you very much for your input! – Christian Eriksson Dec 03 '13 at 21:04
  • I just tried on SP2 and you are right, it does not work in english ! both macro and power input c:Constraint give me "unknown command" ! "Funny thing" is that it works in french on both SP2 and 7. But for english it just works for me on SP7 (I could not try SP3, 4, 5, 6 so I do not know on which it was solved.) You might want to answer your question and tell the world :D (so little activity on CATIA on this site, this is a shame) – Zzirconium Dec 04 '13 at 09:20
0

If you only want to get the constraint command available all the time, just do a shortcut for it.

Open Sketch->Right Click on any bar -> Customize -> Commands Tab -> Select the command -> Show Properties -> Assign Shortcut.

Example, assign F6 to "Constraint" and that would be equal to:

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

If you want actually constraint two geometrical elements through vba, this is other matter. Say if you need more info on this.

0

your question is quite unclear, what do you want to achieve in fact with constraints? additionally "Constraint" function doesn't have any dialog attached to it, but "Constraints defined in dialog box" does, in order to make any of them to do any action, you have to pre-select some geometry on which is possible to make such constraint first

you dont need to customize anything, those functions by default have icons defined so you can always use them with start command, if you are in correct workbench of course, as constraint function exists on different levels, part, product, sketch..

tsolina
  • 141
  • 15