As a side note, for generic use (outside of maya) you can use boost python
to call python from C++ and vice versa:
https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/index.html




On Tue, May 18, 2021, 23:30 Todd Widup <todd.wi...@gmail.com> wrote:

> Thanks Marcus,
> the txt file will be just a bunch of values and matrices ... it might be
> binary it might be ascii..not 100% yet, depends how big the files get.....
> was leaning towards JSon for easy of use/setup
> the python Q was purely curiosity
>
> On Tue, May 18, 2021 at 9:50 AM Marcus Ottosson <konstrukt...@gmail.com>
> wrote:
>
>> what would I use to allow the plugin to read an external user specified
>> file, either a txt or json?
>>
>> You could make a string attribute on the node, and set 
>> MFnAttribute::isUsedAsFilename
>> = true
>> <https://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=__cpp_ref_class_m_fn_attribute_html#a47fb4f02f1619e47363c39c9794d8191>,
>> which will let users browse for a file.
>>
>> Once you’ve got access to a path from C++, have a look at RapidJSON
>> <https://rapidjson.org/> or nlohmann/json
>> <https://github.com/nlohmann/json> for a fast or convenient option, in
>> that order. They’re both header-only and work just fine with something like
>> Maya. You’ll likely get more options from others, because there are just so
>> many options here. If you drill down into more specifics about your
>> requirements, e.g. should it be human-readable? Does it need to be JSON?
>> Does it need to be small? Network friendly? Is the data large, like a
>> pointcache or small like a set of attributes? Will you be serialising data?
>> Would you need something that can be deserialised into the same data
>> structure? Etc.
>>
>> is there a way to have a C++ plugin run python at all?
>>
>> Yes, you can either call on Maya’s Python from C++ via 
>> MGlobal::executePythonCommand("print('hello
>> world!')");
>> <https://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=__cpp_ref_class_m_global_html#af47e37db0e53940620c6cd1f1111e41d>
>> or you can embed another Python yourself and call that. The latter would
>> have the benefit of not polluting the global Python namespace and memory,
>> and is something you could use to spin up multiple Python interpreters in
>> parallel if your code is performance sensitive (though I’d question why
>> you’d turn to Python in that case).
>>
>> On Tue, 18 May 2021 at 16:34, Todd Widup <todd.wi...@gmail.com> wrote:
>>
>>> me writing maya plugins has been limited to mostly utility nodes and an
>>> occasionally deformer.  I am working on something a bit bigger and what
>>> would I use to allow the plugin to read an external user specified file,
>>> either a txt or json?  also, been wondering, is there a way to have a C++
>>> plugin run python at all?
>>>
>>> --
>>> Todd Widup
>>> Creature TD / Technical Artist
>>> todd.wi...@gmail.com
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to python_inside_maya+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CABBPk35P29DnsEqw3Chjv%2Biy0GuHkRFDOaf-jJx_o5moTA1e%2Bg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CABBPk35P29DnsEqw3Chjv%2Biy0GuHkRFDOaf-jJx_o5moTA1e%2Bg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOC8cVw97ZeVtLanizhcdCzSwjbr5OY_%2BCDd0UJ-5iipdQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOC8cVw97ZeVtLanizhcdCzSwjbr5OY_%2BCDd0UJ-5iipdQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Todd Widup
> Creature TD / Technical Artist
> todd.wi...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CABBPk34qLGDCYOqxnck7y-o1LYaZRaSa%3D1OB4CdE%2BZXuqE3aRg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CABBPk34qLGDCYOqxnck7y-o1LYaZRaSa%3D1OB4CdE%2BZXuqE3aRg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMQ7LY0OBFdE8t%2BJAs4z5VizR-X-ZHMCY5HgDaS0%3DDCjkg%40mail.gmail.com.

Reply via email to