<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to get a port data type?]]></title><description><![CDATA[<p dir="auto">Hi community!</p>
<h3>Questions:</h3>
<p dir="auto">How can I get the datetype of a selected port(GraphNode)?</p>
<h3>Problem:</h3>
<p dir="auto">I want to get a type of a <code>maxon.GraphNode</code> aka a port type. Like picture below, I select three port with very basic port type, and I wang to get the type of the port to do some further conditions, but I have trouble with this task.</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1685516069014-15ce3dae-6f50-4cf3-869f-5b6b1b1da5f0-image.png" alt="15ce3dae-6f50-4cf3-869f-5b6b1b1da5f0-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I didn't find a api looks like build for this task , I try to get it with the codes and return like this, I can get color/ metalness which had a default value, but not the bump port. (the type returned is not like the GUI, but it can work.)</p>
<p dir="auto">Color port</p>
<pre><code>Name: standardmaterial@WO3Q2uk5Kp4pRHlNJ_Douc&lt;com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color
Value: 0.21404114365577698,0.21404114365577698,0.21404114365577698
ID: com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color
Type: net.maxon.parametrictype.col&lt;3,float64&gt;
</code></pre>
<p dir="auto">Metalness port</p>
<pre><code>Name: standardmaterial@WO3Q2uk5Kp4pRHlNJ_Douc&lt;com.redshift3d.redshift4c4d.nodes.core.standardmaterial.metalness
Value: 0
ID: com.redshift3d.redshift4c4d.nodes.core.standardmaterial.metalness
Type: float64
</code></pre>
<p dir="auto">Codes:</p>
<pre><code>import c4d
import maxon

def main():
    mat = doc.GetActiveMaterial()

    nodeMaterial = mat.GetNodeMaterialReference()

    nodespaceId = c4d.GetActiveNodeSpaceId()

    graph = nodeMaterial.GetGraph(nodespaceId)

    def GetName(node):

        if node is None:
            return None

        nodeName = node.GetValue(maxon.NODE.BASE.NAME)

        if nodeName is None:
            nodeName = node.GetValue(maxon.EffectiveName)

        if nodeName is None:
            nodeName = str(node)

        return nodeName

    def RetrieveInformationOfPort(port):

        if port is None:
            return True

        portName = GetName(port)
        portValue = port.GetDefaultValue()

        print(f"Name: {portName}")
        print(f"Value: {portValue}")
        print(f"ID: {port.GetId()}")
        print(f"Type: {portValue.GetType().GetId()}") 

        return True

    maxon.GraphModelHelper.GetSelectedNodes(graph, maxon.NODE_KIND.PORT_MASK, RetrieveInformationOfPort)

    c4d.EventAdd()

if __name__ == "__main__":
    main()
</code></pre>
<p dir="auto">Thanks for your times.</p>
<p dir="auto">Cheers~</p>
]]></description><link>http://developers.maxon.net/forum/topic/14711/how-to-get-a-port-data-type</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 00:09:55 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/14711.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 May 2023 07:10:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get a port data type? on Thu, 10 Aug 2023 05:43:30 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dunhou">@<bdi>Dunhou</bdi></a> ,</p>
<p dir="auto">you are correct, the issue is not fixed yet. As Ferdinand mentioned in the beginning he has flagged it as "to_fix", so it will be fixed as soon as possible.</p>
<p dir="auto">Thanks and Cheers<br />
Maxon SDK Group</p>
]]></description><link>http://developers.maxon.net/forum/post/72212</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72212</guid><dc:creator><![CDATA[jana]]></dc:creator><pubDate>Thu, 10 Aug 2023 05:43:30 GMT</pubDate></item><item><title><![CDATA[Reply to How to get a port data type? on Wed, 09 Aug 2023 14:37:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jana">@<bdi>jana</bdi></a> Hey, I think this problem is not fixed now, I just test it with R2023.2.2.</p>
]]></description><link>http://developers.maxon.net/forum/post/72208</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72208</guid><dc:creator><![CDATA[Dunhou]]></dc:creator><pubDate>Wed, 09 Aug 2023 14:37:43 GMT</pubDate></item><item><title><![CDATA[Reply to How to get a port data type? on Wed, 09 Aug 2023 09:30:29 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dunhou">@<bdi>Dunhou</bdi></a> ,</p>
<p dir="auto">without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly.</p>
<p dir="auto">Thank you for your understanding,<br />
Maxon SDK Group</p>
]]></description><link>http://developers.maxon.net/forum/post/72207</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72207</guid><dc:creator><![CDATA[jana]]></dc:creator><pubDate>Wed, 09 Aug 2023 09:30:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to get a port data type? on Thu, 01 Jun 2023 15:35:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a> thanks for your response.</p>
<p dir="auto">Then only I can do now maybe pick a manual list with bump and displacement&lt;vector&gt; type port and considering with their ids.hope this will be fixed soon.</p>
<p dir="auto">Cheers~</p>
]]></description><link>http://developers.maxon.net/forum/post/71643</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71643</guid><dc:creator><![CDATA[Dunhou]]></dc:creator><pubDate>Thu, 01 Jun 2023 15:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to How to get a port data type? on Wed, 31 May 2023 11:16:04 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/dunhou">@<bdi>Dunhou</bdi></a>,</p>
<p dir="auto">Thank you for reaching out to us. In C++, you would retrieve the attribute <code>maxon::nodes::PortType</code> (id: <code>"type"</code>) on the node. There are also some attributes of similar purpose which return a <code>maxon::DataType</code> for a <code>GraphNode</code>.</p>
<p dir="auto">However, none of these work, because there is a bug in <code>maxon.DataType</code> (i.e., the Python API reflection of <code>maxon::DataType</code>). Currently there is nothing you can do from the Python side of things to fix this. I have filed a bug report and flagged this thread as <code>to_fix</code>.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
<p dir="auto">Result:</p>
<pre><code class="language-py">GetName(port) = 'standardmaterial@Hg9$KeW8OFNmebDk8jn99C&lt;com.redshift3d.redshift4c4d.nodes.core.standardmaterial.bump_input'
port.GetId() = maxon.InternedId('com.redshift3d.redshift4c4d.nodes.core.standardmaterial.bump_input')
&lt;class 'maxon.datatype.DataType'&gt; &lt;NativePyData (net.maxon.datatype.datatype) [dt=0x00007FF7EC8692C0,data=0x000001A756F0A370,owner=false] object at 0x000001A756F0A340&gt;
&lt;class 'maxon.datatype.DataType'&gt; &lt;NativePyData (net.maxon.datatype.datatype) [dt=0x00007FF7EC8692C0,data=0x000001A756F02770,owner=false] object at 0x000001A756F02740&gt;
&lt;class 'maxon.datatype.DataType'&gt; &lt;NativePyData (net.maxon.datatype.datatype) [dt=0x00007FF7EC8692C0,data=0x000001A756F16670,owner=false] object at 0x000001A756F16640&gt;

</code></pre>
<p dir="auto">Code:</p>
<pre><code class="language-py">def RetrieveInformationOfPort(port: maxon.GraphNode) -&gt; bool:
    """
    """
    if not isinstance(port, maxon.GraphNode):
        return False

    print (f"\n{'-' * 100}")
    print(f"{GetName(port) = }")
    print(f"{port.GetId() = }")

    # Try out various node attributes that express a type.
    for aid in ("type", "fixedtype", "synthesizedtype", "net.maxon.node.deducedtype"):
        # We can get these attributes, but they all return malformed data. There is a
        # bug in maxon.DataType itself (the type of all of these attributes).
        attribute: maxon.Data = port.GetValue(maxon.InternedId(aid))
        if attribute is None:
            continue
        
        print (type(attribute), attribute._data)

        # All these lines will fail, because #attribute is malformed in the Python API, 
        # its field DataType._data is not what it should be.
        
        # print(attribute)
        # print(attribute.GetId()) # This would be data type of the port.

</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/71627</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71627</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 31 May 2023 11:16:04 GMT</pubDate></item></channel></rss>