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

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

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

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.

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..

Related

Mapping Keyboard Shortcuts in Word (vba) KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."

Good day.
Someone has a list of the commands that can be assigned a keyboard shortcut using the function:
KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."
I want to assign a shortcut to decreasing French indentation, but I only see the command for its increase: Command: = "HangingIndent"
Thank you. Greetings.
Choose Developer>Macros. Change the Macros in dropdown to Word commands. The complete list of available command names is displayed.
If you need to set specific indentation amounts, you'll have to write a simple macro instead of relying on Word's preset indentation values.
But it's probably better to avoid VBA altogether. Instead of relying on local formatting (which a Word command or macro would do), create a typestyle with your preferred indentation and apply that to the text. That's a better practice in Word and easy to update later if you change your mind about the amount of indentation.
The problem is precisely that, that the command related to the decrease of the French indentation does not appear in the list of Word commands. What I need to know is what the said command is called. After a lot of thinking I found a command to list all the keyboard shortcuts in the active document: Application.Run MacroName: =" CommandList" and this allowed me to find what I'm looking for: RemoveHangingIndent

VBA - Word Table : default value and combo box

I have Word Tables, and I don't find how to affect default values for certain columns...
When inserting a new line, I would like a certain column to have a certain drop-down list without user having to do it himself.
To illustrate my thoughts, here is a small image of what I'm looking for
I really don't find how to manipulate my table for it to ends up like this, so I would like to request your help.
When looking on the web for this, I only find information about table default style and no default Value.
So I would like to ask. Is this possible? If yes, how to do it?
I am looking for either a VBA code to set my column default value (which would be great), or even a way to do it in Word GUI at first. Or, obviously, an answer that would tell me that it is impossible to do in Word.
PS: the extremely easy equivalent in Excel of what i'm looking for:
Thanks in advance!
In the GUI:
Click the cell where you would like your dropdown.
In menu, switch to "Developer Tools"
Insert a Dropdown control ("Controls" are, the one in the middle)
In the ribbon, click "Design mode" (I have German Word so the actual name might differ), "Properties"
Now you can enter your options
Alternatively via VBA, I got this with the macro recorder; should give you a start:
[Cell].Range.ContentControls.Add (wdContentControlComboBox)
ActiveDocument.ToggleFormsDesign
Selection.ParentContentControl.DropdownListEntries.Clear
Selection.ParentContentControl.DropdownListEntries.Add Text:="Yes", Value _
:="Yes"
Selection.ParentContentControl.DropdownListEntries.Add Text:="No", Value:= _
"No"

Run macro at key press - Space key

I have a Word 2013 Macro which quickly runs a simple spell check dialogue.
I want to run it every time I type a word.
One way of doing this is by running the macro every time I press space.
Therefore, I tried to use the Options>Customize Ribbon>Keyboard Shortcuts method but that did not work for the space key.
How can I run a macro every time press the "space" key?
Thank you in advance.
You should be able to do this using KeyBindings. I've not tried it with spacebar specifically, but I use this with tab, backspace, etc. The basic idea is:
in a sub that you run at startup or document open:
'This line may differ depending on whether you are running this from a document template or an add-in.
Application.CustomizationContext = ThisDocument.AttachedTemplate
' Create the keybinding.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory:= _
wdKeyCategoryMacro, Command:="MyMacro"
Then make sure your macro is named to match whatever you put in Command.

How to select all instances of a variable and edit variable name in Sublime

If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
Things I've Tried:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
And using Ctrl⌘G simply selects all the string matches:
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
Put the cursor in the variable.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
Press ⌘D as needed. Not on a Mac? Use CtrlD.
Didn't work? Try again, making sure to start with nothing selected.
More commands:
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
Sublime Docs
I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.
Easy way to do it: AltF3.
Despite much effort, I have not found a built-in or plugin-assisted way to do what you're trying to do. I completely agree that it should be possible, as the program can distinguish foo from buffoon when you first highlight it, but no one seems to know a way of doing it.
However, here are some useful key combos for selecting words in Sublime Text 2:
Ctrl⌘G - selects all occurrences of the current word (AltF3 on Windows/Linux)
⌘D - selects the next instance of the current word (CtrlD)
⌘K,⌘D - skips the current instance and goes on to select the next one (CtrlK,CtrlD)
⌘U - "soft undo", moves back to the previous selection (CtrlU)
⌘E, ⌘H - uses the current selection as the "Find" field in Find and Replace (CtrlE,CtrlH)
This worked for me. Put your cursor at the beginning of the word you want to replace, then
CtrlK, CtrlD, CtrlD ...
That should select as many instances of the word as you like, then you can just type the replacement.
The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .
To me, this is the biggest mistake in Sublime. Alt+F3 is hard to reach/remember, and Ctrl+Shift+G makes no sense considering Ctrl+D is "add next instance to selection".
Add this to your User Key Bindings (Preferences > Key Bindings):
{ "keys": ["ctrl+shift+d"], "command": "find_all_under" },
Now you can highlight something, press Ctrl+Shift+D, and it will add every other instance in the file to the selection.
As user1767754 said, the key here is to not make any selection initially.
Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.
Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.
It's mentioned by #watsonic that in Sublime Text 3 on macOS, starting with an empty selection, simply ⌃⌘G (AltF3 on Windows) does the trick, instead of ⌘D + ⌃⌘G in Sublime Text 2.
At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.
Just in case anyone else stumbled on this question while looking for a way to replace a string across multiple files, it is Command+Shift+F

Creating OpenerView in a Notebook for Various Section of the Notebook in Mathematica

I have a notebook with various sections which I would like to contract (i.e show only the title of the section/subsection etc...) and expand as needed to reveal more or less of the content of the various parts (as done in the help section of Mathematica for instance).
I see the function OpenerView creates the icon but appears not to be suited for the purpose.
How do I accomplish that?
From the menu, try "Format->Option Inspector" and select "Selected Notebook" from the drop-down menu. Then in the search box type "opener", and make sure the "ShowGroupOpener" is checked. Then put the parts of your document into "Sections", "Subsections" etc. using the "Format->Style" menu options.
The blue brackets on the right side of the page are cell brackets. They show you want can or will be collapsed. Double click the one that surrounds the block you wish to collapse, or select the section and press: Ctrl+'
If you wish to expand or collapse all of the sections within a section or notebook, select the range you want to affect (Ctrl+a to select all), then use:
Ctrl+Shift+[ to open
Ctrl+Shift+] to close
In the menu Cell>Grouping if Manual Grouping rather than Automatic Grouping is selected, then the sections you want to collapse may not actually be grouped. You can see what is grouped or not, by the blue brackets on the right side of the Notebook. This is what I attempted to allude to above. If you change the setting to Automatic Grouping, or group the cells manually using Ctrl+Shift+g, you should see the brackets indicate the group, and the commands above should work.
If you refer to this post,
https://mathematica.stackexchange.com/questions/265/easiest-way-to-use-showgroupopener-in-mathematica
it will likely have your answer. To enter the expression for the cell, use Cell | Show Expression. There you can turn on the ShowGroupHeader option.