<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting MFn type from string type name in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13645061#M6</link>
    <description>&lt;P&gt;Hey Brent, thanks for getting back to me so fast!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I should've clarified that I'm working in Maya 2026/python here; I've had some luck using MFnBase.typeString but only in OpenMaya 1 . If do&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from maya.api import OpenMaya
OpenMaya.MFnBase.typeString&lt;/LI-CODE&gt;&lt;P&gt;I get an&amp;nbsp;"AttributeError: type object 'OpenMaya.MFnBase' has no attribute 'typeString'". I don't suppose there's plans to have this work with OpenMaya 2? I only ask as that's what I'm using in the rest of my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also had issues building up this mapping; as I understand it lots of different type names can map to the same underlying MFnType, e.g. an arnold "aiStandardSurface" node is a&amp;nbsp;kPluginDependNode, but MFnBase.typeString(MFnType.kPluginDependNode) doesn't give us any way to get back to aiStandardSurface; do you know if there's any way I could account for this sort of thing?&lt;/P&gt;</description>
    <pubDate>Thu, 22 May 2025 17:08:00 GMT</pubDate>
    <dc:creator>ben_hawkyardJPBMR</dc:creator>
    <dc:date>2025-05-22T17:08:00Z</dc:date>
    <item>
      <title>Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13644585#M4</link>
      <description>&lt;P&gt;Hi folks! I'm writing some code to traverse the scene, which should let users filter for specific node types. Ideally, I want the users calling my code to provide the string type name of the nodes they're after, e.g. "transform", or "aiStandardSurface" etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using MItDependencyGraph under the hood. This can take a MFn.Type as a filter, to let us get specific types of node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My trouble at the moment is I can't find a good way to map string node type names to MFn.Type values. One option I have is to not filter nodes at all and just query their MFnDependencyNode.typeName, but this is quite a bit slower in testing than filtering directly with MItDepdencyGraph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, the one way I can see of doing is, is to take the string type name, then create a node of this type, then get the&amp;nbsp;MFnDependencyNode.typeName of my created node, then delete the node. Obviously this is not ideal! Another approach would be to maintain a very large hardcoded dict mapping string type names to MFn.Types. I'd rather not do this though if possible as it's likely to need to change as we add/remove plugins from our pipeline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a better solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2025 12:55:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13644585#M4</guid>
      <dc:creator>ben_hawkyardJPBMR</dc:creator>
      <dc:date>2025-05-22T12:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13644938#M5</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;There is a static method on MFnBase that will return the name for a given type.&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;const char* MFnBase::typeString(MFn::Type)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;So, you could build a reverse lookup dictionary by looping from &lt;STRONG&gt;MFn::kInvalid&lt;/STRONG&gt; to &lt;STRONG&gt;MFn::kLast&lt;/STRONG&gt;&amp;nbsp;and inserting the result of &lt;STRONG&gt;MFnBase::typeString &lt;/STRONG&gt;into the dictionary if the returned pointer returned is not null. You would only have to do this the first time and cache the dictionary.&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2025 15:55:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13644938#M5</guid>
      <dc:creator>brentmc</dc:creator>
      <dc:date>2025-05-22T15:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13645061#M6</link>
      <description>&lt;P&gt;Hey Brent, thanks for getting back to me so fast!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I should've clarified that I'm working in Maya 2026/python here; I've had some luck using MFnBase.typeString but only in OpenMaya 1 . If do&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from maya.api import OpenMaya
OpenMaya.MFnBase.typeString&lt;/LI-CODE&gt;&lt;P&gt;I get an&amp;nbsp;"AttributeError: type object 'OpenMaya.MFnBase' has no attribute 'typeString'". I don't suppose there's plans to have this work with OpenMaya 2? I only ask as that's what I'm using in the rest of my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also had issues building up this mapping; as I understand it lots of different type names can map to the same underlying MFnType, e.g. an arnold "aiStandardSurface" node is a&amp;nbsp;kPluginDependNode, but MFnBase.typeString(MFnType.kPluginDependNode) doesn't give us any way to get back to aiStandardSurface; do you know if there's any way I could account for this sort of thing?&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2025 17:08:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13645061#M6</guid>
      <dc:creator>ben_hawkyardJPBMR</dc:creator>
      <dc:date>2025-05-22T17:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13645992#M7</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;What about using something like &lt;STRONG&gt;MNodeClass&lt;/STRONG&gt; which can be constructed from a type string and then give you typeid and other info?&lt;BR /&gt;Like your original idea of using &lt;STRONG&gt;createNode&lt;/STRONG&gt; but without creating the actual node.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/MAYADEV/2026/ENU/?guid=MAYA_API_REF_cpp_ref_class_m_node_class_html" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/MAYADEV/2026/ENU/?guid=MAYA_API_REF_cpp_ref_class_m_node_class_html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 08:07:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13645992#M7</guid>
      <dc:creator>brentmc</dc:creator>
      <dc:date>2025-05-23T08:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13646097#M8</link>
      <description>&lt;P&gt;Anything to avoid actually creating nodes!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've had a go at using MNodeClass but I'm not sure this quite works for me either, e.g.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; from maya.api import OpenMaya
&amp;gt;&amp;gt;&amp;gt; cls = OpenMaya.MNodeClass("transform")
&amp;gt;&amp;gt;&amp;gt; cls.typeId.id()
&amp;lt;&amp;lt;&amp;lt; 1481003597
&amp;gt;&amp;gt;&amp;gt; OpenMaya.MFn.kTransform
&amp;lt;&amp;lt;&amp;lt; 110&lt;/LI-CODE&gt;&lt;P&gt;Here the type id I get out of "transform" doesn't line up with the value of MFn.Type.kTransform. I'm not sure I really understand how type ids relate to MFn.Types but as far as I can see they're pretty distinct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a bit of a look at MDGModifier/&lt;SPAN&gt;MDagModifier to "create" the node (not calling doIt) and then seeing if I can inspect that MObject a bit at runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 08:55:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13646097#M8</guid>
      <dc:creator>ben_hawkyardJPBMR</dc:creator>
      <dc:date>2025-05-23T08:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MFn type from string type name</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13646788#M9</link>
      <description>&lt;P&gt;MFn.Type is not really a distinct type in that sense. It's primary purpose is to represent function sets which is more like an interface that can be applied to an MObject. (where the typeId is meant to be unique to each node type)&lt;BR /&gt;&lt;BR /&gt;The original idea behind function sets is you could have a camera interface and maybe cameras and spot lights both support that interface so you could in theory do camera-like things to a spot light. However, I don't think Maya ever leaned heavily into that concept and instead function sets so closely follow the object type. (but not exactly and that is where you are running into issues)&lt;BR /&gt;&lt;BR /&gt;So, maybe your safest bet is to create temporary objects that you can interogate or a combination of this and hard coding some common node types as I'm out of ideas at this point.&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 15:39:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/getting-mfn-type-from-string-type-name/m-p/13646788#M9</guid>
      <dc:creator>brentmc</dc:creator>
      <dc:date>2025-05-23T15:39:45Z</dc:date>
    </item>
  </channel>
</rss>

