Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Message data sent to iframe is expected to be a JSON object with a messageName string and some message dependent strings.

Code Block
{
  messageName: "nameOfTheMessage",
  ...
}

Supported messages

runcommand

Run a command in Kudo:

where resultMessage: if specified, a message with this name is posted to the iframe parent when command execution is done
and messageId: var message = {
    messageName: if specified, it is passed to the resultMessage

Code Block
const message = {
  messageName: "runcommand",

...


  commandString: "_YourCommand",

...


  resultMessage: "nameOfPostedResultMessage", //optional

...


  messageId: "messageId" ;//optional

...


}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

You can also pass parameters to your command like this:    commandString

Code Block
 commandString: "_YourCommand Param1 Param2"

or    commandString

Code Block
commandString: "_YourCommand\nParam1\nParam2"

resultMessage: if specified, message is posted to iframe parent when command execution is done

messageId: if specified, it is passed to resultMessage

Expand
titleExample message to add a line
Code Block
const message = {
  messageName: "runcommand",
  commandString: "_LINE 0,0 10,10  "
}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

Info

Note: Only whitelisted commands are allowed to be run from the client side by runcommand message. To whitelist a command, add it to Default Files

\

/OEM Commands

\

/commands.xml (see Customization package and https://graebert.atlassian.net/l/cp/EUUwZ9r2

Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>


<commands>


 <OEM name="graebert">


   <command name="_XEREPLACEOPEN"/>


   <command name="_DOATTACHMENT"/>


   <command name=" _YourCommand"/>


 </OEM>


</commands>

runlisp

Execute the passed Lisp expression:var

message = {
    messageName: where resultMessage: if specified, a message with this name is posted to iframe parent when lisp execution is done
and messageId: if specified, it is passed to the resultMessage

Code Block
languagejs
const message = {
  messageName: "runlisp",

...


  lispExpression: "lispExpression",

...


  resultMessage: "nameOfPostedResultMessage", //optional

...


  messageId: "messageId"; //optional

...


}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

resultMessage: if specified, message is posted to iframe parent when lisp execution is done

messageId: if specified, it is passed to resultMessage

eventRegister
eventDeRegister

Register/Deregister for receiving different types of additional events. Available event types are:

CommandEvent
LispEvent
SysVarEvent
DrawingEvent
ViewChangedEvent
SelectionEvent

eventRegister/eventDeRegister

Event types: commandEvent, sysVarEvent, lispEvent, drawingEvent, selectionEvent, drawingModifiedEvent

You can find available events on the event page. See https://graebert.atlassian.net/wiki/x/QAFdRg page for more details about events.

eventRegister

Register for receiving different types of additional events notifications.

where eventName will be the event type which you want to register:var message = {
    messageName:

Code Block
languagejs
const message = {
  messageName: "eventRegister",

...


  eventName: "commandEvent";//one of the above event types

...


}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

eventDeRegister

Deregister for event:var message = {
    messageName: to stop receiving different types of additional events notifications.

where eventName will be the event type which you want to deregister:

Code Block
languagejs
const message = {
  messageName: "eventDeRegister",

...


  eventName: "commandEvent";//one of the above event types
}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

Upgrading/Downgrading

Upgrading: To change from View mode to Edit mode

Downgrading: Change from Edit mode to view mode

You can update the drawing state using send post message from iframe parent}
window

where state can be “view” or “edit”

Code Block
languagejs
const message={
  messageName= “stateChanged”,
  state = “view”;
}
const iframe = document.getElementById("cadcontent");
iframe.contentWindow.postMessage(message, '*');

setvariable **

Info

Change a variable value

drawingdescription**

Info

Trigger creation of drawing description

** Not implemented yet