Interaction Tag 交互标签Basic 基础Tag 标签Scripting 脚本Output 输出Poly Info 保利信息科技有限公司Proxy 代理人

Scripting

脚本

This tab can be used to create all types of commands or actions that can, for example, be called when the object to which the tag is assigned (tagged object) is clicked or double-clicked. For those of you who start to panic when they hear the word "script", adding commands (or commenting them out via # or //) is easy: Open the Customize Commands... Manager, enable the Edit Palettes if you want to drag an icon directly into the layout, and simply drag the respective command under the fitting function:

此选项卡可用于创建所有类型的命令或操作,例如,当单击标记分配给的对象(标记对象)或双击该对象时,可以调用这些命令或操作。对于那些听到“ script”这个词就开始恐慌的人来说,添加命令(或者通过 # 或者/添加评论)很简单: 打开自定义命令... 管理器,启用编辑调色板(Edit Palettes) ,如果你想直接拖动一个图标到布局中,只需在拟合函数下拖动相应的命令:

In this example, we switch to the Use Polygon mode when the tagged object is clicked upon. 在这个例子中,我们在单击标记的对象时切换到 Use Polygon 模式

Make sure to remove the comments (Python: #) from in front of functions and commands and to add a tab space (Tab key) in front of the latter.

确保从函数和命令前面删除注释(Python: #) ,并在后者前面添加一个选项卡空间(Tab key)。

Scripting Language

脚本语言

If None is selected, scripting will be disabled - existing scripts will not be deleted. Otherwise, select Python. the C.O.F.F.E.E. option will only be displayed for older scenes that are loaded so the old script can be adapted to Python.

如果没有被选中,脚本将被禁用-现有的脚本将不会被删除。否则,选择 Python。选项将只显示加载的旧场景,以便旧脚本可以适应 Python。

Script
Script

This is where you enter your script(s). Several predefined functions are already included for which can be activated by simply removing the # or // in front of the respective function.

这是您输入脚本的地方。已经包含了一些预定义的函数,只需删除相应函数前面的 # 或//即可激活这些函数。

The following predefined functions are available (support and documentation for Python can also be found at http://developers.maxon.net):

下面的预定义函数是可用的(Python 的支持和文档也可以在 google http://developers.maxon.net 中找到) :

mouseDown

This is called when the user first clicks the mouse button or taps the screen with the stylus. Here you can adjust the proxy object using a script, adjust the document mode using doc.SetMode(MODE_ID) or adjust the active tool to be used by this object with doc.SetAction(TOOL_ID). You can also prepare any data you need for the drag.

当用户第一次单击鼠标按钮或用手写笔轻击屏幕时,就会调用这个函数。这里您可以使用脚本调整代理对象,使用 doc 调整文档模式。SetMode (MODE _ id)或调整此对象使用的活动工具。SetAction (TOOL _ id).您还可以为拖动准备所需的任何数据。

mouseDrag

鼠标拖拽

This is called continuously during a mouse interaction for each refresh as the mouse moves. You cannot change the proxy object, document mode or tool at this point.

当鼠标移动时,每次刷新都会在鼠标交互期间连续调用这个函数。此时无法更改代理对象、文档模式或工具。

mouseUp

This is called when the user releases the mouse button and signals the end of the user interaction. You can reset tools or kill off any memory-hungry objects that have been allocated in mouseDown or mouseDrag at this point.

当用户释放鼠标按钮并发出用户交互结束的信号时,就会调用这个函数。此时,您可以重置工具或关闭在鼠标下或鼠标拖动中分配的任何耗费内存的对象。

onSelect

This is called when the user selects the object to which the tag is assigned. The tag has to be selected (When Selected option).

当用户选择标记分配给的对象时,调用这个函数。必须选择标记(When Selected 选项)。

onDeselect

取消选举

This is called when the user deselects the object to which the tag is assigned.

当用户取消选择标记分配给的对象时,将调用这个函数。

onHighlight

This is called when the object is highlighted by the mouse cursor.

当鼠标光标突出显示对象时调用这个函数。

onUnhighlight

This is called when the object's highlight status is removed by the mouse cursor moving off of the object.

当鼠标光标移出对象时,对象的突出显示状态被移除时,调用这个函数。

message

信息

This is called when a message is set to the object, the arguments are id and data. The data is typically a dictionary in Python. See the SDK docs for an explanation of messages.

当消息设置为对象时,调用这个函数,参数是 id 和数据。数据在 Python 中通常是一个字典。有关消息的解释,请参阅 SDK 文档。

draw

This is called to allow you to draw directly into the Viewport using the passed argument bd (BaseDraw).

调用这个函数是为了允许您使用传递的参数 bd (BaseDraw)直接绘制到 Viewport 中。

Edit Script

编辑脚本

Clicking on this button will open the Expression-Editor, which offers a more comfortable coding field. Both script fields are linked with each other. Therefore, it doesn’t matter which field you use to enter your code - the other field will be updated automatically.

点击这个按钮将打开表达式编辑器,它提供了一个更舒适的编码字段。两个脚本字段相互链接。因此,您使用哪个字段输入代码并不重要——其他字段将自动更新。