如何在脚本对象中获取自身节点?

时间:2015-02-17 16:35:41

标签: maxscript

我在maxscript中编写一个插件助手,需要获取作为对象的节点。听起来很简单吧?哈! “this”返回插件类的实例,我认为..也可能是类本身..谁知道,文档并不完全具体在这个..或任何东西。我已经猜测了正确的单词组合(比如“this.node”或者只是“节点”),那里没有运气。

我可以生成一个选择对话框并自己选择节点,但那是愚蠢的。有线索吗?

1 个答案:

答案 0 :(得分:1)

一般来说,您不希望为对象中的数据引用节点。如果节点依赖于对象,并且对象依赖于节点,则可以看到这将导致很多问题。另一个问题是如果您的插件是实例化的。然后2个节点指向一个对象 - 哪一个是正确的?

理想情况下,您应该以不需要节点指针的方式设计插件(即创建WSModifier,或者作为实用程序工作)。如果你需要节点转换,那么你可以在没有指向节点的指针的情况下得到它: http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_461915FA_31A2_49CE_84AF_2544B782ACA3_htm

The delegate local variable in a scripted plug-in that creates a scene object does not contain the node itself, but a the BaseObject of that node. As such, you can not access the node level properties of the object being created. An exception to this is the node’s transform, which is exposed to the scripted plug-in through a local variable called nodeTM . This variable is described in the applicable scripted plug-in type topics. 

如果您决定直接与节点对话,那么您可以获得依赖于您的班级的所有班级的列表

refs.dependents

http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_95453E22_A022_4543_B31C_A052CECD3598_htm

这将获得所有家属的列表,包括您的节点。迭代列表并使用找到的第一个节点。