Back to top

How to execute custom TSL commands from palette or ribbon

Issue:

Some TSLs provide custom commands which can be accessed by the right mouse button when the instance is selected. You can create a custom command to call these functions.

Solution:

Add a palette button or custom command to the ribbon.

  • Language independent
    ^C^C(defun c:NEWCOMMAND() (Hsb_RecalcTslWithKey (_TM "|COMMANDSTRING|") (_TM "|CUSTOMPROMPT|"))) NEWCOMMAND
  • Language dependent
    ^C^C(defun c:NEWCOMMAND() (Hsb_RecalcTslWithKey "COMMANDSTRING" "CUSTOMPROMPT")) NEWCOMMAND

^C^C: terminates any other ACAD command which might be active

NEWCOMMAND: replace this by any command name you want to assign, but make sure you are not overwriting an existing hsbcad or Autocad command.
You could use one command name for multiple tsls if you do not want to call the command from command line, but just ensure to make a command repeatable, i.e. "MyLastTslCommand"

COMMANDSTRING: replace by custom command string, i.e. Flip Side

CUSTOMPROMPT: replace by a prompt which will be presented to the user, i.e. Select Metalpart(s)

Example:

^C^C(defun c: MyLastTslCommand () (Hsb_RecalcTslWithKey (_TM "|Flip SIde|") (_TM "|Select Metalpart(s)|"))) MYLASTTSLCOMMAND

The sample above could be defined language dependent to German as follows:
^C^C(defun c: MyLastTslCommand () (Hsb_RecalcTslWithKey "Seite wechseln" "Metallteil(e) wählen")) MYLASTTSLCOMMAND.

Remarks:

If you want to create a command which will run in multiple languages you need to define the command with the _TM functions of the English expressions.
It is recommended to specify the command language independent, as the translation might be changed or updated in order to enhance localizations.
The Hsb_RecalcTslWithKey command works with any TSL which has the COMMANDSTRING implemented as key. This means that any TSL matching this would be executed while the behavior is dependent to the individual script.
Example: 'Flip Side' could well be defined to align a certain part of a metalpart or it could be used to drill a beam from one side or the other.

Some custom commands require the selection of additional entities. Each instance in the selection set will prompt for the defined actions unless the author has envisaged a combined behavior for multiple instances.

Need Support?

Can’t find the answer you’re looking for? Don’t worry we’re here to help!

Contact support