Re: [Maya-Python] Re: C++ already deleted

2024-03-25 Thread Justin Israel
On Tue, Mar 26, 2024, 5:35 AM Juan Cristóbal Quesada <
juan.cristobal...@gmail.com> wrote:

> i just ask chatgpt what good practices are.
> i m glad to know that keeping a "global" reference prevents them to be
> deleted.
> Apart from what Justin said regarding the parent-child relationship.
> I guess that is all we should care about.
>
> I had a very specific use case, where a derived QWidget class was
> implementing an interface that would realize a method.
> The thing is, when this object/method was being called as a result of a
> publish/subscriber event, accessing the object was causing the C++ already
> deleted object RuntimeError.
>
> All i did is have the class derive from a base one that registers and
> holds widgets in a static list. Problem, apparently gone.
>

In this particular use case, without the static list, were you only passing
a method of the object to a slot and there was no other reference to the
object being held, and no parent set?


> El lun, 25 mar 2024 a las 11:37, Juan Cristóbal Quesada (<
> juan.cristobal...@gmail.com>) escribió:
>
>> When working with PySide objects, especially when interacting with Qt
>> objects implemented in C++, it's important to handle references correctly
>> to avoid memory issues and potential segmentation faults. Here are some
>> good programming practices to follow:
>>
>>1. Parenting: Assign a parent to PySide objects whenever possible.
>>When an object has a parent, it will be automatically deleted when its
>>parent is deleted. This helps avoid memory leaks and ensures cleaner 
>> object
>>management.
>>
>> pythonCopy code
>> # Example of creating a widget with a parent
>> parent_widget = QtWidgets.QWidget()
>> child_widget = QtWidgets.QWidget(parent_widget)
>>
>>
>>1. Maintain references: Ensure that you maintain references to
>>objects as long as you need them. If an object is a local variable in a
>>function and goes out of scope, it will be automatically destroyed, which
>>can cause issues if it's still needed.
>>
>> pythonCopy code
>> # Example of maintaining a global reference
>> global_object = None
>> def create_object():
>> global global_object
>> global_object = QtWidgets.QWidget()
>>
>> create_object()# 'global_object' is still accessible here
>>
>>
>>1. Use Python's garbage collector: Python's garbage collector can
>>clean up objects that are no longer in use, but you shouldn't rely solely
>>on it to manage PySide objects. It's always better to explicitly release
>>resources when they're no longer needed.
>>
>> pythonCopy code
>> # Example of explicit resource release
>> widget = QtWidgets.QWidget()
>> widget.setParent(None)  # Release the object from the parent
>> widget.deleteLater()# Mark the object to be deleted later
>>
>>
>>1. Avoid reference cycles: Avoid creating object structures that form
>>reference cycles, as this can prevent Python's garbage collector from
>>properly releasing memory.
>>
>> pythonCopy code
>> # Example of reference cycle
>> widget1 = QtWidgets.QWidget()
>> widget2 = QtWidgets.QWidget()
>> widget1.child = widget2
>> widget2.parent = widget1
>>
>> By following these good programming practices, you can handle PySide
>> objects more safely and efficiently, minimizing the chances of encountering
>> issues related to memory management.
>> ChatGPT can make mistakes. Consider checking important information.
>>
>> El dom, 24 mar 2024 a las 19:39, Justin Israel ()
>> escribió:
>>
>>> I'm not familiar with the widget being deleted during some intermediate
>>> operations. Pyside has had some weird bugs related to python garbage
>>> collection over the years, but from my understanding they have been
>>> addressed in modern releases. Could still be edge cases or maybe an older
>>> Pyside version. Would be great to see a repo of the problem.
>>> You should be able to parent the widget to something, and just not show
>>> it. Adding it to a layout later would automatically reparent it.
>>>
>>>
>>> On Mon, Mar 25, 2024, 12:41 AM Juan Cristóbal Quesada <
>>> juan.cristobal...@gmail.com> wrote:
>>>
>>>> Yeah, as i understand, it is good practice whenever you instantiate a
>>>> PySide object to, right after, to add it to a layout, which by default
>>>> would set its parent widget to the widget that holds the layout and keep
>>>> the hierarchy consi

Re: [Maya-Python] Re: C++ already deleted

2024-03-24 Thread Justin Israel
I'm not familiar with the widget being deleted during some intermediate
operations. Pyside has had some weird bugs related to python garbage
collection over the years, but from my understanding they have been
addressed in modern releases. Could still be edge cases or maybe an older
Pyside version. Would be great to see a repo of the problem.
You should be able to parent the widget to something, and just not show it.
Adding it to a layout later would automatically reparent it.


On Mon, Mar 25, 2024, 12:41 AM Juan Cristóbal Quesada <
juan.cristobal...@gmail.com> wrote:

> Yeah, as i understand, it is good practice whenever you instantiate a
> PySide object to, right after, to add it to a layout, which by default
> would set its parent widget to the widget that holds the layout and keep
> the hierarchy consistent.
> The problem arises when this is not always done and you want to
> instantiate a QWidget class without providing a parent right away, and
> perform some intermediate operations first.
>
> Then, situations like the one Chris shows, passing a python reference to a
> class and use it afterwards cause problems. That is why i was wondering if
> having a "class attribute" or "static attribute" would help there?
> It is easy to instantiate a PySide object without taking care of these
> little details, specially when people first arrive to python and PySide, as
> we are used to tinker with python variables as we wish..
>
>
>
> El dom, 24 mar 2024 a las 1:03, Chris Granados- Xian (<
> drummanx...@gmail.com>) escribió:
>
>> When I ran into this, it has almost always been because of method
>> parameters initialized with default values in the constructor of some
>> PySide class. Let’s say class A gets instanced twice. If instance X is
>> garbage collected for whatever reason, when instance Y tries to use Y.b
>> it’ll complain about the C++ ref to 123 being lost.
>>
>> class A:
>> def __init__(self, a=123):
>>     self.b=a
>>
>>
>> *CHRIS GRANADOS - Xian*
>> Pipeline TD- CG Supervisor
>> Bs. As., Argentina
>>
>>
>> On Sat, 23 Mar 2024 at 16:56 Justin Israel 
>> wrote:
>>
>>> Qt (C++) usually honors the parent-child relationship, so it won't
>>> automatically delete a widget unless its parent is being deleted. And if it
>>> doesn't have a parent, it shouldn't be automatically deleted by reference
>>> count unless it is wrapped in a smart pointer. Or maybe you have looked up
>>> a reference to a widget through shiboken that you didn't create, which is
>>> how it could later become invalid.
>>> Do you make use of parent-child assigments in your Python code? Does it
>>> happen with widgets you created in Python, or only widgets you looked up as
>>> a reference through shiboken?
>>>
>>> I think it is fair for Marcus to ask to see concrete code as an example,
>>> because I don't think the idea of C++ objects randomly being deleted from
>>> under the Python refs should be considered normal. It shouldn't be
>>> something you just have to expect would happen at any moment. Rather, there
>>> may be a pattern in your code that should be avoided or worked around.
>>>
>>>
>>>
>>> On Sun, Mar 24, 2024, 7:42 AM Juan Cristóbal Quesada <
>>> juan.cristobal...@gmail.com> wrote:
>>>
>>>> Hi Marcus, thanks for the reply.
>>>>
>>>> You see, that is what i want to avoid at all costs. I dont want this
>>>> thread conversation to evolve following a concrete, specific use case, but
>>>> rather try to aim at "the bigger" picture. There are may examples of where
>>>> and how this C++ already deleted error occurs. Im sure we all can think of
>>>> one example in our code.
>>>>
>>>> My question, generally speaking, was aiming at preventing this to
>>>> happen at all costs by following a "good coding practice" convention.
>>>> For example, is it good practice to store every python widget in a
>>>> static class variable? would that avoid all these kinds of errors? What if
>>>> you store a QWidget object in a python list and then try to access it
>>>> because it got registered as a subscriber, but, at the moment of calling
>>>> the method you subscribed for, the C++ bound object no longer exists
>>>> because the C++ reference count went to zero?? Is it good practice to try
>>>> to use the shiboken2.isValid() method to validate everytime the C++ Widget
>>>> pointer? all over the code? and to use the MQtUtil

Re: [Maya-Python] Re: C++ already deleted

2024-03-23 Thread Justin Israel
Qt (C++) usually honors the parent-child relationship, so it won't
automatically delete a widget unless its parent is being deleted. And if it
doesn't have a parent, it shouldn't be automatically deleted by reference
count unless it is wrapped in a smart pointer. Or maybe you have looked up
a reference to a widget through shiboken that you didn't create, which is
how it could later become invalid.
Do you make use of parent-child assigments in your Python code? Does it
happen with widgets you created in Python, or only widgets you looked up as
a reference through shiboken?

I think it is fair for Marcus to ask to see concrete code as an example,
because I don't think the idea of C++ objects randomly being deleted from
under the Python refs should be considered normal. It shouldn't be
something you just have to expect would happen at any moment. Rather, there
may be a pattern in your code that should be avoided or worked around.



On Sun, Mar 24, 2024, 7:42 AM Juan Cristóbal Quesada <
juan.cristobal...@gmail.com> wrote:

> Hi Marcus, thanks for the reply.
>
> You see, that is what i want to avoid at all costs. I dont want this
> thread conversation to evolve following a concrete, specific use case, but
> rather try to aim at "the bigger" picture. There are may examples of where
> and how this C++ already deleted error occurs. Im sure we all can think of
> one example in our code.
>
> My question, generally speaking, was aiming at preventing this to happen
> at all costs by following a "good coding practice" convention.
> For example, is it good practice to store every python widget in a static
> class variable? would that avoid all these kinds of errors? What if you
> store a QWidget object in a python list and then try to access it because
> it got registered as a subscriber, but, at the moment of calling the method
> you subscribed for, the C++ bound object no longer exists because the C++
> reference count went to zero?? Is it good practice to try to use the
> shiboken2.isValid() method to validate everytime the C++ Widget pointer?
> all over the code? and to use the MQtUtil.findControl() method to retrieve
> a C++ alive pointer to a widget? What if we need to store a widget
> temporarily with no parent so we are able to further on perform a
> setParent() but the C++ object was already destroyed?
>
> All these are use cases that we all can encounter. Im just trying to
> figure out a general method to avoid all these problems ,specially to the
> more junior TDs, Tech Artists, etc.
> That s why i was asking for a "general rule" to avoid these use cases.
> Again, i would not like to make a discussion here out of a specific use
> case. But rather, mostly curious towards how the more senior profiles
> tackle with this.
>
> Thanks!!
>
> El sáb, 23 mar 2024 a las 19:07, Marcus Ottosson ()
> escribió:
>
>> It would certainly help if you could provide an example of something that
>> causes the error, or at the very least a stacktrace of the error.
>>
>> On Saturday 23 March 2024 at 18:04:59 UTC rainonthescare...@gmail.com
>> wrote:
>>
>>> Hi,
>>> i ve been working for quite some time now and occasionally bumped into
>>> this C++ "unfamous" error. Normally, when found occasionally, ive been able
>>> to fix it by using the widget's "self.findChild"/"self.findChildren" which
>>> i believe keeps the C++ reference count of the object's pointer alive. Fair
>>> enough!
>>> So, instead of storing the C++ widget in a python bound object, i would
>>> retrieve it from the parent-child hierarchy, provided the widget has been
>>> added firstly to the layout.
>>>
>>> Well, we have a snippet of code in our project that relies heavily on
>>> the publish-subscriber/observer pattern and i wouldnt like to rewrite it
>>> because of this C++ infernal error. So here is my question: what's the best
>>> policy to try to avoid this RuntimeError "forever and after"? Ideally, i
>>> would be tempted to use a "template" tool class that would register all the
>>> widgets automatically in its __init__ method and perform a
>>> MQtUtil.findControl/MQtUtil.findLayout, but i am still encountering this
>>> error somewhere else.
>>>
>>> I dont want to solve this punctually but rather establish a good coding
>>> policy to avoid "forever" this!.
>>> So, what is your policy trying to avoid this error? Have you found a
>>> permanent solution to this?
>>>
>>> Thanks in advance,
>>> My name is Juan Cristóbal Quesada
>>> and i work as senior pipeline TD in Spain.
>>>
>>> Kind Regards,
>>> JC
>>>
>> --
>> 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/ea8d4cdc-d206-4492-bd54-d7ca3f2c5e23n%40googlegroups.com
>> 

Re: [Maya-Python] How to analyze other people's codes?

2024-02-28 Thread Justin Israel
It's a tough question to answer with absolute certainty, as it can really
depend on a lot of factors.

It can depend on the quality of the code.
* does it contain helpful comments to explain the intent of sections of code
* is it written with other developers in mind, or is the original developer
using a lot of cute shorthand code and trying to be compact and appear
complex
* is the project well structured over all

And then, it can depend on your own experience as a reader.
* Are you very familiar with the language syntax in the first place.
Otherwise you may be spending an extra amount of time trying to evaluate
every part of the expression of every line, as opposed to more quickly
understanding the intent.
* are you familiar with the problem domain. That is, if it's code dealing
with Houdini SDK, do you know houdini well enough to understand the domain
specific code

It can take time to develop the skill to build a mental model of code, and
keep a running visualization in your head of what the overall program is
doing. If you are just trying to understand what the program is doing and
not trying to find bugs, you may not need to spend as much time parsing the
values of every single line. Try then to explain what a function is doing,
instead of a line.

One approach for a larger project might be to start top-down, where you
start at the 'main' or first call into the code. Then you track what it
does with the inputs, through the program and the various control flow that
can make it go one way or another. It can help to take notes about what you
know along the way, if you find it difficult to remember.
You could also start from bottom-up and try to read what the lowest level
functions do first, and then figure out who calls them. The problem with
this approach could be that you don't have enough context to know why the
lower level stuff is there without knowing first who called it and why.

As Reza said, if there are docs, that is the best place to start, to get
the big picture.
Overall it really just takes practice with a particular language. When you
learn more than one programming language and review enough code, you start
to get faster at reviewing because a lot of concepts are the same, with
different words and symbols to express them.



On Thu, Feb 29, 2024, 5:04 PM Reza Aarabi  wrote:

> You never find out what other people did in their code
> Especially in big studios
> It’s a complete chaos
> :D
>
> But first you should look at the task the code dies, software, tool or
> plugin as a whole
> Then you should see which APIs they used
> And in the main programming language how they have implemented the
> libraries, classes or functions
> And how these codes are related to each other
>
> Of course if you can find API documentation in any studio for their
> libraries (if you find any let me know) it would be great to learn
> functionality of each class and function
>
> If not you have to read the code
> Module by module
> Function by function
> Or line by line to be able to use them
> I’m talking about using APIs (or custom libraries) especially in VFX …
>
> Good luck tho
>
>
>
> -
> *--= Reza Aarabi =--*
> *https://madoodia.com *
>
>
> On Wed, Feb 28, 2024 at 17:44 Abdelhalim abulmagd <
> abdelhalim.abulm...@gmail.com> wrote:
>
>> I'm still a beginner and the most advice I've received while learning. It
>> is that I have to read other people's codes. But when I tried, I found it
>> very difficult. I tried to read the code line by line, but that was very
>> tiring, especially in the long codes. I also tried other methods and they
>> did not work and did not lead me to anything.
>> What is the best way to read other people’s codes and find out how they
>> work?
>>
>> --
>> 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/266c36ad-dc3c-4b66-9eb3-dca5799e01a4n%40googlegroups.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/CADvbQwL5oe8xiBWDNJJRNW3km0qcE3EVgscnDdinvuKJUUJORg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you 

Re: [Maya-Python] Re: Python Maya add new attribute

2023-07-27 Thread Justin Israel
No worries. Happy to help.

On Thu, 27 Jul 2023, 11:47 pm SquashnStretch net, 
wrote:

> I guess I forgot to reply to this Justin, sorry and thank you very much
> for taking the time to explain perfectly ;)
>
> Thanks
> F
>
> Il giorno gio 13 lug 2023 alle ore 10:48 Justin Israel <
> justinisr...@gmail.com> ha scritto:
>
>>
>>
>> On Thu, 13 Jul 2023, 8:55 pm SquashnStretch net, <
>> squashnstret...@gmail.com> wrote:
>>
>>> Thanks Justin,
>>> yes the problem is when I go back and forth between arms to add new
>>> attribute, the code sometimes gets confused :)
>>> I'll try your version..
>>> I have another question.. Does it make sense to wrap these kind of codes
>>> into a class or wouldn't change much ?
>>>
>>
>> The benefit of a class is that you can bind behaviour with state. So your
>> functions become methods. And each instance of the class can track the
>> state between method calls. As an example, a single invocation might create
>> objects and store what it created. Another method could operate on what was
>> previously created. But then a second instance of this class would be an
>> entirely new process that would not become confused with the previous one.
>> That is the trouble with globals. You end up sharing state across many
>> independent actions.
>> Mayas scene selection state can also be thought of as a global. Sometimes
>> code tries to rely too much on the current selection which can change,
>> instead of passing inputs and receiving outputs, between functions.
>>
>> Classes don't solve every problem though. Sometimes it can be better to
>> just try to make your functions more "pure" and pass in the required inputs
>> to perform the work, and return outputs.
>>
>>
>>> Thanks
>>> F
>>>
>>> Il giorno lun 26 giu 2023 alle ore 05:49 Justin Israel <
>>> justinisr...@gmail.com> ha scritto:
>>>
>>>> From what I can see in your last code example and your description of
>>>> the problem you are seeing, is the issue due to the selection changing
>>>> after you run the add_attribute_and_create_group() operation? Because
>>>> unless I am missing something specific to your select, it seems to work
>>>> fine as long as I reselect the "hand" again before running the button. If
>>>> that is the case, then you can make sure to reset the selection to the
>>>> original, after the creation of your group transforms changes the 
>>>> selection:
>>>>
>>>> https://pastebin.com/YSm8gPb8
>>>>
>>>> If that is not what you are seeing as the problem, maybe you can
>>>> provide a simple scene as a sample, and exact steps to reproduce the
>>>> problem using this last code example?
>>>>
>>>> On Sun, Jun 25, 2023 at 11:21 PM SquashnStretch net <
>>>> squashnstret...@gmail.com> wrote:
>>>>
>>>>> Hello Justin,
>>>>> here is the prev version with no globals, i ddnt connect the
>>>>> attributes here because i wanted to solde the parentConstraint first...:
>>>>>
>>>>> import maya.cmds as mc
>>>>>
>>>>> def add_attribute_and_create_group(*args):
>>>>> attribute_name = mc.textField(attribute_field, query=True,
>>>>> text=True)
>>>>> selected_objects = mc.ls(selection=True)
>>>>>
>>>>> created_groups = []
>>>>>
>>>>> for selected_object in selected_objects:
>>>>> if not mc.objExists("{0}.{1}".format(selected_object,
>>>>> attribute_name)):
>>>>> mc.addAttr(selected_object, ln=attribute_name,
>>>>> at="double", min=0, max=1, dv=0, keyable=True)
>>>>>
>>>>> group_name = selected_object + "_spaceGrp"
>>>>> if not mc.objExists(group_name):
>>>>> new_group = mc.group(selected_object, name=group_name)
>>>>> mc.xform(new_group, centerPivots=True)
>>>>> created_groups.append(new_group)
>>>>>
>>>>> print('Returned object is:', created_groups)
>>>>> return created_groups
>>>>>
>>>>> def create_parent_constraint(*args):
>>>>> selected_objects = mc.ls(selection=True)
>>>>> if not selected_objects:
>>>>>   

Re: [Maya-Python] Re: Python Maya add new attribute

2023-07-13 Thread Justin Israel
On Thu, 13 Jul 2023, 8:55 pm SquashnStretch net, 
wrote:

> Thanks Justin,
> yes the problem is when I go back and forth between arms to add new
> attribute, the code sometimes gets confused :)
> I'll try your version..
> I have another question.. Does it make sense to wrap these kind of codes
> into a class or wouldn't change much ?
>

The benefit of a class is that you can bind behaviour with state. So your
functions become methods. And each instance of the class can track the
state between method calls. As an example, a single invocation might create
objects and store what it created. Another method could operate on what was
previously created. But then a second instance of this class would be an
entirely new process that would not become confused with the previous one.
That is the trouble with globals. You end up sharing state across many
independent actions.
Mayas scene selection state can also be thought of as a global. Sometimes
code tries to rely too much on the current selection which can change,
instead of passing inputs and receiving outputs, between functions.

Classes don't solve every problem though. Sometimes it can be better to
just try to make your functions more "pure" and pass in the required inputs
to perform the work, and return outputs.


> Thanks
> F
>
> Il giorno lun 26 giu 2023 alle ore 05:49 Justin Israel <
> justinisr...@gmail.com> ha scritto:
>
>> From what I can see in your last code example and your description of the
>> problem you are seeing, is the issue due to the selection changing after
>> you run the add_attribute_and_create_group() operation? Because unless I am
>> missing something specific to your select, it seems to work fine as long as
>> I reselect the "hand" again before running the button. If that is the case,
>> then you can make sure to reset the selection to the original, after the
>> creation of your group transforms changes the selection:
>>
>> https://pastebin.com/YSm8gPb8
>>
>> If that is not what you are seeing as the problem, maybe you can provide
>> a simple scene as a sample, and exact steps to reproduce the problem using
>> this last code example?
>>
>> On Sun, Jun 25, 2023 at 11:21 PM SquashnStretch net <
>> squashnstret...@gmail.com> wrote:
>>
>>> Hello Justin,
>>> here is the prev version with no globals, i ddnt connect the attributes
>>> here because i wanted to solde the parentConstraint first...:
>>>
>>> import maya.cmds as mc
>>>
>>> def add_attribute_and_create_group(*args):
>>> attribute_name = mc.textField(attribute_field, query=True, text=True)
>>> selected_objects = mc.ls(selection=True)
>>>
>>> created_groups = []
>>>
>>> for selected_object in selected_objects:
>>> if not mc.objExists("{0}.{1}".format(selected_object,
>>> attribute_name)):
>>> mc.addAttr(selected_object, ln=attribute_name, at="double",
>>> min=0, max=1, dv=0, keyable=True)
>>>
>>> group_name = selected_object + "_spaceGrp"
>>> if not mc.objExists(group_name):
>>> new_group = mc.group(selected_object, name=group_name)
>>> mc.xform(new_group, centerPivots=True)
>>> created_groups.append(new_group)
>>>
>>> print('Returned object is:', created_groups)
>>> return created_groups
>>>
>>> def create_parent_constraint(*args):
>>> selected_objects = mc.ls(selection=True)
>>> if not selected_objects:
>>> print("Nessun oggetto selezionato.")
>>> return
>>>
>>> groups = mc.ls("*_spaceGrp")
>>> if not groups:
>>> print("Nessun gruppo creato.")
>>> return
>>>
>>> for selected_object in selected_objects:
>>>     mc.parentConstraint(selected_object, groups[0],
>>> maintainOffset=True)
>>> print("ParentConstraint creato tra", selected_object, "e",
>>> groups[0])
>>>
>>>
>>> # Creazione della finestra
>>> window = mc.window(title="Add Attribute")
>>> mc.columnLayout(adjustableColumn=True)
>>> attribute_field = mc.textField(text="")
>>> mc.button(label="Esegui", command=add_attribute_and_create_group)
>>> mc.button(label="Parent", command=create_parent_constraint)
>>> mc.showWindow(window)
>>>
>>> Thanks for taking a look
>>> F
>>>
>>> 

Re: [Maya-Python] What exactly is the "filenames" attribute in a reference node

2023-06-27 Thread Justin Israel
On Wed, Jun 28, 2023 at 11:22 AM Javier  wrote:

> Hello all,
>
> Maybe this is a niche question but I have recently noticed that there is a
> "filenames" -"fn" for short name- array attribute in reference nodes, and
> it can be set as in "myReferencenodeRN.fn[0]", "myReferencenodeRN.fn[1]",
> etc.
> What confuses me the most is that this attribute is not the same as the
> "filename" attribute (which is not an array of strings but just a string,
> and it is not really an attribute because it is not listed as with
> maya.cmds.listAttr).
> Do you guys have any clue what is this used for? My guess is that it may
> be used just for hinting previously used filenames or something like that?
> In this regard, do you guys know whether there is anywhere some
> documentation about what each attribute does? Like a description or
> something similar, I guess there is not, but maybe a Python's built-in
> help() style utility or something?
>
>

Does the Nodes reference doc page help?
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Nodes/reference.html

It does describe both the long (fileNames) and short (fn) attributes as
being a list


> Thanks in advance,
>
> Kind regards,
>
> --
> 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/55e4d720-1dd9-4a1b-8829-d1132915f3f6n%40googlegroups.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/CAPGFgA0_gPkH-ABeRb_OXnOkK%2Bj90wW7soyCER3KnaRkpUcs5w%40mail.gmail.com.


Re: [Maya-Python] Re: Python Maya add new attribute

2023-06-25 Thread Justin Israel
>From what I can see in your last code example and your description of the
problem you are seeing, is the issue due to the selection changing after
you run the add_attribute_and_create_group() operation? Because unless I am
missing something specific to your select, it seems to work fine as long as
I reselect the "hand" again before running the button. If that is the case,
then you can make sure to reset the selection to the original, after the
creation of your group transforms changes the selection:

https://pastebin.com/YSm8gPb8

If that is not what you are seeing as the problem, maybe you can provide a
simple scene as a sample, and exact steps to reproduce the problem using
this last code example?

On Sun, Jun 25, 2023 at 11:21 PM SquashnStretch net <
squashnstret...@gmail.com> wrote:

> Hello Justin,
> here is the prev version with no globals, i ddnt connect the attributes
> here because i wanted to solde the parentConstraint first...:
>
> import maya.cmds as mc
>
> def add_attribute_and_create_group(*args):
> attribute_name = mc.textField(attribute_field, query=True, text=True)
> selected_objects = mc.ls(selection=True)
>
> created_groups = []
>
> for selected_object in selected_objects:
> if not mc.objExists("{0}.{1}".format(selected_object,
> attribute_name)):
> mc.addAttr(selected_object, ln=attribute_name, at="double",
> min=0, max=1, dv=0, keyable=True)
>
> group_name = selected_object + "_spaceGrp"
> if not mc.objExists(group_name):
> new_group = mc.group(selected_object, name=group_name)
> mc.xform(new_group, centerPivots=True)
> created_groups.append(new_group)
>
> print('Returned object is:', created_groups)
> return created_groups
>
> def create_parent_constraint(*args):
> selected_objects = mc.ls(selection=True)
> if not selected_objects:
> print("Nessun oggetto selezionato.")
> return
>
> groups = mc.ls("*_spaceGrp")
> if not groups:
> print("Nessun gruppo creato.")
> return
>
> for selected_object in selected_objects:
> mc.parentConstraint(selected_object, groups[0],
> maintainOffset=True)
> print("ParentConstraint creato tra", selected_object, "e",
> groups[0])
>
>
> # Creazione della finestra
> window = mc.window(title="Add Attribute")
> mc.columnLayout(adjustableColumn=True)
> attribute_field = mc.textField(text="")
> mc.button(label="Esegui", command=add_attribute_and_create_group)
> mc.button(label="Parent", command=create_parent_constraint)
> mc.showWindow(window)
>
> Thanks for taking a look
> F
>
> Il giorno ven 23 giu 2023 alle ore 20:05 Justin Israel <
> justinisr...@gmail.com> ha scritto:
>
>>
>>
>> On Sat, 24 Jun 2023, 5:13 am SquashnStretch net, <
>> squashnstret...@gmail.com> wrote:
>>
>>> actually that was the version with globals, I tried many ways but I get
>>> the same results.
>>> thanks
>>>
>>
>> Can you share your attempt without globals?
>>
>>
>>> Il giorno venerdì 23 giugno 2023 alle 17:41:28 UTC+1 SquashnStretch net
>>> ha scritto:
>>>
>>>> Hello Everyone,
>>>> I went back to my attempt on adding new attribute to every rig, like I
>>>> want hand can be constraint to the head and / or to the Body, Hips, etc ...
>>>> If I add al the attributes that I want and I go to the other hand or
>>>> leg etc and add new attributes, everything's fine,
>>>> the problem happens when I go back to the first hand for instance, and
>>>> try to add new attribute, then the script fails because it picks the wrong
>>>> elements to perform the constraints ...
>>>>
>>>> I tried not to use global variables but I cant figure out how to fix
>>>> it. I would like to have this little code/snippet that once I add the new
>>>> attribute and create the constraint etc, it would  clear all the variables
>>>> or what it needs, in order to avoid conflict
>>>>
>>>> Here's the script which create a GUI with a text field where to enter
>>>> name of the attribute we want to add and after we select an object (an hand
>>>> for instance), it add the name etc,
>>>> with the second button we select what it need to follow
>>>>
>>>> https://pastebin.com/raw/cdqeJCx0
>>>>
>>>> thanks in advance
>>>> Flys
>>>>
>>>

Re: [Maya-Python] Re: Python Maya add new attribute

2023-06-23 Thread Justin Israel
On Sat, 24 Jun 2023, 5:13 am SquashnStretch net, 
wrote:

> actually that was the version with globals, I tried many ways but I get
> the same results.
> thanks
>

Can you share your attempt without globals?


> Il giorno venerdì 23 giugno 2023 alle 17:41:28 UTC+1 SquashnStretch net ha
> scritto:
>
>> Hello Everyone,
>> I went back to my attempt on adding new attribute to every rig, like I
>> want hand can be constraint to the head and / or to the Body, Hips, etc ...
>> If I add al the attributes that I want and I go to the other hand or leg
>> etc and add new attributes, everything's fine,
>> the problem happens when I go back to the first hand for instance, and
>> try to add new attribute, then the script fails because it picks the wrong
>> elements to perform the constraints ...
>>
>> I tried not to use global variables but I cant figure out how to fix it.
>> I would like to have this little code/snippet that once I add the new
>> attribute and create the constraint etc, it would  clear all the variables
>> or what it needs, in order to avoid conflict
>>
>> Here's the script which create a GUI with a text field where to enter
>> name of the attribute we want to add and after we select an object (an hand
>> for instance), it add the name etc,
>> with the second button we select what it need to follow
>>
>> https://pastebin.com/raw/cdqeJCx0
>>
>> thanks in advance
>> Flys
>>
> --
> 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/212298a6-ebf7-4ad9-9cf6-f96050987f5cn%40googlegroups.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/CAPGFgA0ehT%3DxShVAvELyt29m8WbiarDyc1QGb0PdU6%3D2cx9o_A%40mail.gmail.com.


Re: [Maya-Python] Missing attribute error after duplicating

2023-06-22 Thread Justin Israel
On Thu, 22 Jun 2023, 10:19 pm Herbert Agudera, 
wrote:

> Hello everyone.
>
> I am fairly new at scripting in maya/python. A few days ago i watched some
> youtube videos about python scripting for maya artists. watched arvids
> video about making a script to convert maya shaders to arnold shaders.
>
> anyway, here is what i am having trouble with
>
> *aiRampHi_mask = pmc.duplicate("aiRamp_Hi", ic = True, ic = True, name =
> "aiRampHi_mask")*
> *aiRampHi_mask.outColorR >> aiLayer.mix4*
>
> *the error*
>
>
>
> *# Error: 'list' object has no attribute 'outColorR'# Traceback (most
> recent call last):#   File "", line 1, in #
> AttributeError: 'list' object has no attribute 'outColorR' #*
>

The return value of duplicate() is a list of the duplicated objects. So the
error is telling you that you are attempting to access a field that does
not exist on a list.
To access the first item of a list:
*item = aiRampHi_mask[0] *


>
> I can connect the two manually but i cant using the script. what is
> missing here?
>
> Thanks!
>
> --
> 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/8578ba87-a1ac-49ea-8e08-d214632b0a21n%40googlegroups.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/CAPGFgA1TA2u8nR7JWN_pwfbuk0u%3DbeKA3KhgQPpVkEgZLUdY%2Bw%40mail.gmail.com.


Re: [Maya-Python] API error

2023-05-20 Thread Justin Israel
Do you need to rename use_NewAPI -> maya_useNewAPI ?
https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_A_First_Plugin_Python_HelloWorldAPI2_html

Also for future code, it would be better to use a pastebin or gist to
retain the formatting, so that when your error contains line references,
they can actually be located by others.

Justin


On Sun, May 21, 2023 at 12:01 PM Abdelhalim abulmagd <
abdelhalim.abulm...@gmail.com> wrote:

> i got this error when i run my first api code .. can anyone help me please
> !
>
> --
> the error :
>
> Error: TypeError: file
> C:/Users/abdelhalim.abdo/Documents/maya/2024/plug-ins/api_learning.py line
> 26: argument 1 must be OpenMaya.MObject, not MObject #
>
> -
>
> the code :
>
>
> import maya.api.OpenMaya as om
>
> import maya.cmds as cmds
>
>
>
> def use_NewAPI():
>
> pass
>
>
> class MyCmd(om.MPxCommand):
>
> NAME = 'heycmd'
>
> def __init__(self):
>
> super(MyCmd, self).__init__()
>
> def doIt(self, args):
>
> print('this my first cmd :)')
>
> @classmethod
>
> def c(cls):
>
> return MyCmd()
>
>
> def initializePlugin(p):
>
> vendor = 'abdo'
>
> version = '1.0.0'
>
> mfn = om.MFnPlugin(p, vendor, version)
>
> mfn.registerCommand(MyCmd.NAME, MyCmd.c)
>
> def uninitializePlugin(p):
>
> mfn = om.MFnPlugin(p)
>
> mfn.deregisterCommand(MyCmd.NAME)
>
>
>
> if __name__ == "__main__":
>
> p_name = 'api_learning.py'
> cmds.evalDeferred(f'if cmds.pluginInfo("{p_name}", q=1, loaded=1):
> cmds.unloadPlugin("{p_name}")')
> cmds.evalDeferred(f'if not cmds.pluginInfo("{p_name}", q=1, loaded=1):
> cmds.loadPlugin("{p_name}")')
>
>
> --
> 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/ee6a4d53-823c-4c06-a9a0-c7d53f4219c4n%40googlegroups.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/CAPGFgA2jrjWmLomwqM0ALTBShF%2B6ettbZgUNstYs9wLuLFvU0w%40mail.gmail.com.


Re: [Maya-Python] Pymel Menu won't autoload Maya 2024

2023-05-18 Thread Justin Israel
On Thu, May 18, 2023 at 5:46 AM A  wrote:

> Hey Folks,
>
> I have pymel, installed via pip on Maya 2024,
>
> Pymel itself is working. But im having a really strange issue.
>
> My studio menu is built with pymel...
>
> I have a maya module..
> ib.mod - this then loads the plugin
> pipeline_module.py - very simple script for making a maya module / plugin
>
> pipeline_module.py imports a maya file called pipeline_menu.py "My maya
> top bar menu"
>
> this menu just holds all my tools etc.
>
> The module wont load via Maya's GUI "Plugin Manager" "just like you would
> load vray kind of setup.
> This worked in Maya 2018 right through to 2023.
> I need to run manually in the python interpreter "import pymel.core as pm"
> This might sound simple but both the pipeline_module.py and pipeline.py
> files run import pymel.core as pm right at the top of both scripts.
>
> Why am I now needing to run this before the module will load?
> The error points to menuOBJ
>
> Error Messages...
> '''
> // Error: file: C:/Program
> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316:
> RuntimeError: file C:\Program
> Files\Autodesk\Maya2024\Python\lib\site-packages\pymel\internal\pmcmds.py
> line 217: menu: Object 'menuOBJ' not found.
> // Warning: file: C:/Program
> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316: Failed to
> run file: C:/Users/Alistair
> Messom/IB/maya_pipeline/mod/plug-ins/pipeline_module.py
> // Error: file: C:/Program
> Files/Autodesk/Maya2024/scripts/others/pluginWin.mel line 316:
>  (pipeline_module)
> '''
>
> My pipeline_menu.py script... well the top of it, the only part that calls
> or refers to menuOBJ is the string in variable menu_obj = 'menuOBJ'
>

The error you reported indicates that it comes from the call to

pm.menu(menu_obj, e=True)

where for whatever reason it thinks the 'menuOBJ' menu does not exist.
Seeing as the label and parent keyword arguments are being ignored in your
first check for existence, could you not just simplify the whole thing with
an exception handler?

try:
found = pm.menu(menu_obj, e=True)
except RuntimeError:
pass
else:
pm.deleteUI(found)


That aside, I don't know why the 'exists' check would succeed, but then it
fails to find the menu object afterwards.

'''
> """
> PIPELINE MENU
> """
> import maya.cmds as cmds
> import pymel.core as pm
> import os
>
> company_name = (
> os.environ['CUSTOM_PIPELINE_NAME'])
>
> def make_the_menu():
>
> main_window = pm.language.melGlobals[
> 'gMainWindow']
> menu_obj = 'menuOBJ'
> menu_label = company_name
>
> if pm.menu(
> menu_obj,
> label=menu_label,
> exists=True,
> parent=main_window):
> pm.deleteUI(pm.menu(menu_obj, e=True))
> '''
> Please not if I manually run "import pymel.core as pm"
>
> Then activate the module with Maya's GUI "plugin Manager" it opens / works
> fine.
> Are we looking at a bug here?
> I just don't get it!!
>
> Thanks,
>
>
> --
> 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/1ade785e-46dd-4181-a2de-aab73c5e6527n%40googlegroups.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/CAPGFgA3p5%3D8okjufHKxLRtMp-ZAdRYyCuj%3D5DMU1c_hqxegATQ%40mail.gmail.com.


Re: [Maya-Python] Adding RIG space

2023-05-10 Thread Justin Israel
Try working with a more simplified version of your script that specifically
isolates the problem you are seeing. That also helps others when you are
asking for help.
Here is a smaller version of your script, with the globals removes, some
excess functions and buttons removed, and a few corrections:
https://pastebin.com/ZLjNaxKc

   - on_make_selection_button_clicked: I noticed that you aren't limiting
   the addAttr() to a specific selected_object when you are looping, so if you
   had more than 1 selection, it would always try to add to all. I've set it
   to add to the current object in the loop
   - on_new_selection_button_clicked: When you are looking up the
   existing_groups, you are grabbing every transform in the scene that ends
   with "_spaceGrp". But the rest of the code in that function seems to want
   to operate only on the selection. So I have updated the ls() to only find
   transforms in the current selection

Other than that, if you want more help, please describe a specific list of
steps to perform, what you expect to happen, and what you actually see
happening as an error instead.

Justin


On Thu, May 11, 2023 at 5:18 AM SquashnStretch net <
squashnstret...@gmail.com> wrote:

> Thanks Justin for your time.
> Good to know about globals can cause issue
> Anyways I tried not to use those, but I keep getting errorsI'll try to
> understand better how to do, maybe I'll create also a global class.
> THanks again
>
> F
>
> Il giorno mercoledì 10 maggio 2023 alle 10:36:29 UTC+1 Justin Israel ha
> scritto:
>
>>
>>
>> On Wed, 10 May 2023, 8:40 pm SquashnStretch net, 
>> wrote:
>>
>>> great, let me know if you can take a look at it.
>>
>>
>>
>> I only took a quick look. It seems like you don't even need globals
>> (unless I missed something). If you get rid of the extra printing code,
>> what is left is the first two button callbacks that app and they get their
>> own selection list each time.
>> Mutable globals as state are a good way to end up with bugs. It is better
>> to try and pass data between functions as args. Or to use a class so that
>> each instance can store state. But maybe just getting rid of globals in the
>> first place is enough here. There is even one of those functions where the
>> selection list isn't declared global so it's a local list in that scope.
>> There may be actual bugs in the Maya commands code but I didn't look
>> closely enough.
>>
>>
>>
>>> Thanks in advance
>>> Filippo
>>>
>>>
>>>
>>> Il giorno mercoledì 10 maggio 2023 alle 08:22:57 UTC+1 Justin Israel ha
>>> scritto:
>>>
>>>>
>>>>
>>>> On Tue, 9 May 2023, 9:45 am SquashnStretch net, 
>>>> wrote:
>>>>
>>>>> oh damn, sorry
>>>>> can you retry please ?
>>>>>
>>>>
>>>> Oops forgot to reply. Yes it's accessible now.
>>>>
>>>>
>>>>> thanks
>>>>> F
>>>>>
>>>>> Il giorno lun 8 mag 2023 alle ore 22:35 Justin Israel <
>>>>> justin...@gmail.com> ha scritto:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, May 9, 2023 at 8:56 AM SquashnStretch net <
>>>>>> squashn...@gmail.com> wrote:
>>>>>>
>>>>>>> In my previous post, I asked for help understanding how to connect
>>>>>>> different nodes from different elements all at once. I managed to work
>>>>>>> around the problem by connecting the attributes one by one, which 
>>>>>>> seemed to
>>>>>>> work.
>>>>>>>
>>>>>>> Now, I have another, easier problem for experienced Python users.
>>>>>>> Let me try to explain.
>>>>>>>
>>>>>>> I am trying to write a code that adds a new space attribute to the
>>>>>>> arm of a rig, connecting to the Head, Hips, and Body if they don't have
>>>>>>> this option. If I add one space option to the right arm at a time, the
>>>>>>> script works well. However, if I add a space to the other arm and then 
>>>>>>> go
>>>>>>> back to the first arm to add another space, the script fails.
>>>>>>>
>>>>>>> I think it may be a matter of some global variable, but even when I
>>>>>>> try to update it, I end up breaking the script. If you have the time, I
>>>>>>>

Re: [Maya-Python] Adding RIG space

2023-05-10 Thread Justin Israel
On Wed, 10 May 2023, 8:40 pm SquashnStretch net, 
wrote:

> great, let me know if you can take a look at it.



I only took a quick look. It seems like you don't even need globals (unless
I missed something). If you get rid of the extra printing code, what is
left is the first two button callbacks that app and they get their own
selection list each time.
Mutable globals as state are a good way to end up with bugs. It is better
to try and pass data between functions as args. Or to use a class so that
each instance can store state. But maybe just getting rid of globals in the
first place is enough here. There is even one of those functions where the
selection list isn't declared global so it's a local list in that scope.
There may be actual bugs in the Maya commands code but I didn't look
closely enough.



> Thanks in advance
> Filippo
>
>
>
> Il giorno mercoledì 10 maggio 2023 alle 08:22:57 UTC+1 Justin Israel ha
> scritto:
>
>>
>>
>> On Tue, 9 May 2023, 9:45 am SquashnStretch net, 
>> wrote:
>>
>>> oh damn, sorry
>>> can you retry please ?
>>>
>>
>> Oops forgot to reply. Yes it's accessible now.
>>
>>
>>> thanks
>>> F
>>>
>>> Il giorno lun 8 mag 2023 alle ore 22:35 Justin Israel <
>>> justin...@gmail.com> ha scritto:
>>>
>>>>
>>>>
>>>> On Tue, May 9, 2023 at 8:56 AM SquashnStretch net 
>>>> wrote:
>>>>
>>>>> In my previous post, I asked for help understanding how to connect
>>>>> different nodes from different elements all at once. I managed to work
>>>>> around the problem by connecting the attributes one by one, which seemed 
>>>>> to
>>>>> work.
>>>>>
>>>>> Now, I have another, easier problem for experienced Python users. Let
>>>>> me try to explain.
>>>>>
>>>>> I am trying to write a code that adds a new space attribute to the arm
>>>>> of a rig, connecting to the Head, Hips, and Body if they don't have this
>>>>> option. If I add one space option to the right arm at a time, the script
>>>>> works well. However, if I add a space to the other arm and then go back to
>>>>> the first arm to add another space, the script fails.
>>>>>
>>>>> I think it may be a matter of some global variable, but even when I
>>>>> try to update it, I end up breaking the script. If you have the time, I
>>>>> would appreciate it if you could take a look at my code. If you want to
>>>>> test it, you can probably use any Maya rig.
>>>>>
>>>>> Thanks in advance
>>>>> Filippo
>>>>>
>>>>> https://pastebin.com/embed_js/GaudeMpR
>>>>>
>>>>
>>>> This pastebin is reporting that it's either private or pending
>>>> moderation. Make sure you set the pastebin to public.
>>>>
>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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_m...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/c92c073f-47d5-4d5a-93c6-06171bf81c5cn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/c92c073f-47d5-4d5a-93c6-06171bf81c5cn%40googlegroups.com?utm_medium=email_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_m...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0vVjVM74WL1Cgi9gxNFm4YSyYugcS-G0rNhcBWn%3DtEtQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0vVjVM74WL1Cgi9gxNFm4YSyYugcS-G0rNhcBWn%3DtEtQ%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>

Re: [Maya-Python] Adding RIG space

2023-05-10 Thread Justin Israel
On Tue, 9 May 2023, 9:45 am SquashnStretch net, 
wrote:

> oh damn, sorry
> can you retry please ?
>

Oops forgot to reply. Yes it's accessible now.


> thanks
> F
>
> Il giorno lun 8 mag 2023 alle ore 22:35 Justin Israel <
> justinisr...@gmail.com> ha scritto:
>
>>
>>
>> On Tue, May 9, 2023 at 8:56 AM SquashnStretch net <
>> squashnstret...@gmail.com> wrote:
>>
>>> In my previous post, I asked for help understanding how to connect
>>> different nodes from different elements all at once. I managed to work
>>> around the problem by connecting the attributes one by one, which seemed to
>>> work.
>>>
>>> Now, I have another, easier problem for experienced Python users. Let me
>>> try to explain.
>>>
>>> I am trying to write a code that adds a new space attribute to the arm
>>> of a rig, connecting to the Head, Hips, and Body if they don't have this
>>> option. If I add one space option to the right arm at a time, the script
>>> works well. However, if I add a space to the other arm and then go back to
>>> the first arm to add another space, the script fails.
>>>
>>> I think it may be a matter of some global variable, but even when I try
>>> to update it, I end up breaking the script. If you have the time, I would
>>> appreciate it if you could take a look at my code. If you want to test it,
>>> you can probably use any Maya rig.
>>>
>>> Thanks in advance
>>> Filippo
>>>
>>> https://pastebin.com/embed_js/GaudeMpR
>>>
>>
>> This pastebin is reporting that it's either private or pending
>> moderation. Make sure you set the pastebin to public.
>>
>>
>>>
>>>
>>> --
>>> 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/c92c073f-47d5-4d5a-93c6-06171bf81c5cn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/c92c073f-47d5-4d5a-93c6-06171bf81c5cn%40googlegroups.com?utm_medium=email_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/CAPGFgA0vVjVM74WL1Cgi9gxNFm4YSyYugcS-G0rNhcBWn%3DtEtQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0vVjVM74WL1Cgi9gxNFm4YSyYugcS-G0rNhcBWn%3DtEtQ%40mail.gmail.com?utm_medium=email_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/CAE8PYnDc3S7%2BMzdzNYg9wo_Tgk0SvUaFxGN2ATN%3DTThrYbQ_Lg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAE8PYnDc3S7%2BMzdzNYg9wo_Tgk0SvUaFxGN2ATN%3DTThrYbQ_Lg%40mail.gmail.com?utm_medium=email_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/CAPGFgA1uBgoXt%3DAgtvrW_keyUePMsx%2Baf0kpAFTqz1yq2b-%2BiA%40mail.gmail.com.


Re: [Maya-Python] Adding RIG space

2023-05-08 Thread Justin Israel
On Tue, May 9, 2023 at 8:56 AM SquashnStretch net 
wrote:

> In my previous post, I asked for help understanding how to connect
> different nodes from different elements all at once. I managed to work
> around the problem by connecting the attributes one by one, which seemed to
> work.
>
> Now, I have another, easier problem for experienced Python users. Let me
> try to explain.
>
> I am trying to write a code that adds a new space attribute to the arm of
> a rig, connecting to the Head, Hips, and Body if they don't have this
> option. If I add one space option to the right arm at a time, the script
> works well. However, if I add a space to the other arm and then go back to
> the first arm to add another space, the script fails.
>
> I think it may be a matter of some global variable, but even when I try to
> update it, I end up breaking the script. If you have the time, I would
> appreciate it if you could take a look at my code. If you want to test it,
> you can probably use any Maya rig.
>
> Thanks in advance
> Filippo
>
> https://pastebin.com/embed_js/GaudeMpR
>

This pastebin is reporting that it's either private or pending moderation.
Make sure you set the pastebin to public.


>
>
> --
> 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/c92c073f-47d5-4d5a-93c6-06171bf81c5cn%40googlegroups.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/CAPGFgA0vVjVM74WL1Cgi9gxNFm4YSyYugcS-G0rNhcBWn%3DtEtQ%40mail.gmail.com.


Re: [Maya-Python] Compiling plugins in Visual Studio for multiple maya versions and platforms

2023-05-05 Thread Justin Israel
I just noticed something from your first email. Your screenshot shows that
your directory is named "cgmake" but you are setting your module path as if
it were called "cgcmake" (like Chad's original repo). Is that the cause of
this whole problem? If so, then you should fix the dir name (or the module
path you are setting) and go back to using
find_package(Maya REQUIRED)
It should discover FindMaya.cmake if your module path matches what really
exists on disk.

On Fri, 5 May 2023, 10:50 pm Rudi Hammad,  wrote:

> I switched because apparently I can't read properly...my bad. Now I am
> using this:
> set(CMAKE_FIND_DEBUG_MODE TRUE)
> find_package("Maya")
> set(CMAKE_FIND_DEBUG_MODE FALSE)
>
>  The output is https://pastebin.com/5gc1q8Jr
>
> ( I was checking again Chad videos again and if I understood properly,
> when CMake runs find_package("Maya")  what it does is looking for the word
> "Find" + the input in between () , so Maya + .cmake.
> That a bit weird, why not just ind_package("FindMaya")? )
>
>
> I also tried this find_path() (I  think I am using it right):
> set(CMAKE_FIND_DEBUG_MODE TRUE)
> find_path(cache "FindMaya.cmake" ${CMAKE_MODULE_PATH})
> set(CMAKE_FIND_DEBUG_MODE FALSE)
>
> The output is https://pastebin.com/nxHyd8dr
> El viernes, 5 de mayo de 2023 a las 9:08:09 UTC+2, Justin Israel escribió:
>
>>
>>
>> On Fri, 5 May 2023, 6:46 pm Rudi Hammad,  wrote:
>>
>>> This is is my src/CMakeLists.txt
>>> https://pastebin.com/EFvNdt9z
>>> here is the entire output
>>> https://pastebin.com/WEmMFGr0
>>>
>>
>>
>> I'm still wondering why you switched from find_package to find_program.
>> My cmake skills are not strong but I thought the latter was for finding the
>> full path to an executable?
>>
>>
>>>
>>>
>>> El viernes, 5 de mayo de 2023 a las 8:02:25 UTC+2, Justin Israel
>>> escribió:
>>>
>>>>
>>>>
>>>> On Fri, 5 May 2023, 5:05 pm Rudi Hammad,  wrote:
>>>>
>>>>> Not sure If I am using  find_program  right.
>>>>
>>>>
>>>> I thought you were previously trying to test the behavior of
>>>> find_package. Did that not seem like the right thing to discover
>>>> FindMaya.cmake? What was the outcome of the debug output?
>>>>
>>>> The signature says find_program ( name1 [path1 path2 ...]) . This
>>>>> what I added
>>>>> set(CMAKE_FIND_DEBUG_MODE TRUE)
>>>>> find_program(cache "FindMaya.cmake" ${CMAKE_MODULE_PATH})
>>>>> set(CMAKE_FIND_DEBUG_MODE FALSE)
>>>>>
>>>>> The console prints out a bunch of paths. The ones at the end are:
>>>>> C:/Users/rudi hammad/Desktop/testCMake/testingCMake/cgcmake/modules/
>>>>> FindMaya.cmake.com
>>>>> C:/Users/rudi
>>>>> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake.exe
>>>>> C:/Users/rudi
>>>>> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake
>>>>>
>>>>>
>>>>> El jueves, 4 de mayo de 2023 a las 21:50:59 UTC+2, Justin Israel
>>>>> escribió:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, 5 May 2023, 5:44 am Rudi Hammad,  wrote:
>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>> since I have time now  I wanted to revive this topic because I have
>>>>>>> to make it work for future project.
>>>>>>> I am trying to track the error, so I added this the code below
>>>>>>> before the error happening with  find_package(Maya REQUIRED)
>>>>>>> message ("---")
>>>>>>> message (${CMAKE_MODULE_PATH})
>>>>>>> message ("---")
>>>>>>> So  I wanted to make sure CMAKE_MODULE_PATH is right. As you can see
>>>>>>> in the image the path is correct and it contains FinMaya.cmake. And 
>>>>>>> still,
>>>>>>> it says I am not providing it. I am really stuck because all looks okey
>>>>>>> doesn't it?
>>>>>>>
>>>>>>
>>>>>> Could you try this, to debug the module search path?
>>>>>>
>>>>>> https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_DEBUG_MOD

Re: [Maya-Python] Compiling plugins in Visual Studio for multiple maya versions and platforms

2023-05-05 Thread Justin Israel
On Fri, 5 May 2023, 6:46 pm Rudi Hammad,  wrote:

> This is is my src/CMakeLists.txt
> https://pastebin.com/EFvNdt9z
> here is the entire output
> https://pastebin.com/WEmMFGr0
>


I'm still wondering why you switched from find_package to find_program. My
cmake skills are not strong but I thought the latter was for finding the
full path to an executable?


>
>
> El viernes, 5 de mayo de 2023 a las 8:02:25 UTC+2, Justin Israel escribió:
>
>>
>>
>> On Fri, 5 May 2023, 5:05 pm Rudi Hammad,  wrote:
>>
>>> Not sure If I am using  find_program  right.
>>
>>
>> I thought you were previously trying to test the behavior of
>> find_package. Did that not seem like the right thing to discover
>> FindMaya.cmake? What was the outcome of the debug output?
>>
>> The signature says find_program ( name1 [path1 path2 ...]) . This
>>> what I added
>>> set(CMAKE_FIND_DEBUG_MODE TRUE)
>>> find_program(cache "FindMaya.cmake" ${CMAKE_MODULE_PATH})
>>> set(CMAKE_FIND_DEBUG_MODE FALSE)
>>>
>>> The console prints out a bunch of paths. The ones at the end are:
>>> C:/Users/rudi hammad/Desktop/testCMake/testingCMake/cgcmake/modules/
>>> FindMaya.cmake.com
>>> C:/Users/rudi
>>> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake.exe
>>> C:/Users/rudi
>>> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake
>>>
>>>
>>> El jueves, 4 de mayo de 2023 a las 21:50:59 UTC+2, Justin Israel
>>> escribió:
>>>
>>>>
>>>>
>>>> On Fri, 5 May 2023, 5:44 am Rudi Hammad,  wrote:
>>>>
>>>>>
>>>>> Hello,
>>>>> since I have time now  I wanted to revive this topic because I have to
>>>>> make it work for future project.
>>>>> I am trying to track the error, so I added this the code below before
>>>>> the error happening with  find_package(Maya REQUIRED)
>>>>> message ("---")
>>>>> message (${CMAKE_MODULE_PATH})
>>>>> message ("---")
>>>>> So  I wanted to make sure CMAKE_MODULE_PATH is right. As you can see
>>>>> in the image the path is correct and it contains FinMaya.cmake. And still,
>>>>> it says I am not providing it. I am really stuck because all looks okey
>>>>> doesn't it?
>>>>>
>>>>
>>>> Could you try this, to debug the module search path?
>>>> https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_DEBUG_MODE.html
>>>>
>>>>
>>>> [image: Capture.JPG]
>>>>> El sábado, 1 de enero de 2022 a las 20:59:55 UTC+1, Justin Israel
>>>>> escribió:
>>>>>
>>>>>> On Sun, Jan 2, 2022 at 7:10 AM Rudi Hammad 
>>>>>> wrote:
>>>>>>
>>>>>>> So I followed Chad Vernom's cmake tutorials on youtube. First I
>>>>>>> wrote a everything as he did, and when it came do the build from the
>>>>>>> command promp I got an error related to maya path or something, so I 
>>>>>>> thought
>>>>>>> F###k that, I'll just copy his repo from github, since I barely
>>>>>>> understand CMake syntax and I might have done plenty of errors.
>>>>>>> Anyway, after copying his repo and rebuilding I get the error
>>>>>>>
>>>>>>> -
>>>>>>>
>>>>>>> Could not find a package configuration file provided by "Maya" with
>>>>>>> any of
>>>>>>>   the following names:
>>>>>>>
>>>>>>> MayaConfig.cmake
>>>>>>> maya-config.cmake
>>>>>>>
>>>>>>>   Add the installation prefix of "Maya" to CMAKE_PREFIX_PATH or set
>>>>>>>   "Maya_DIR" to a directory containing one of the above files.  If
>>>>>>> "Maya"
>>>>>>>   provides a separate development package or SDK, be sure it has been
>>>>>>>   installed.
>>>>>>>
>>>>>>> -
>>>>>>>
&

Re: [Maya-Python] Compiling plugins in Visual Studio for multiple maya versions and platforms

2023-05-05 Thread Justin Israel
On Fri, 5 May 2023, 5:05 pm Rudi Hammad,  wrote:

> Not sure If I am using  find_program  right.


I thought you were previously trying to test the behavior of find_package.
Did that not seem like the right thing to discover FindMaya.cmake? What was
the outcome of the debug output?

The signature says find_program ( name1 [path1 path2 ...]) . This what
> I added
> set(CMAKE_FIND_DEBUG_MODE TRUE)
> find_program(cache "FindMaya.cmake" ${CMAKE_MODULE_PATH})
> set(CMAKE_FIND_DEBUG_MODE FALSE)
>
> The console prints out a bunch of paths. The ones at the end are:
> C:/Users/rudi hammad/Desktop/testCMake/testingCMake/cgcmake/modules/
> FindMaya.cmake.com
> C:/Users/rudi
> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake.exe
> C:/Users/rudi
> hammad/Desktop/testCMake/testingCMake/cgcmake/modules/FindMaya.cmake
>
>
> El jueves, 4 de mayo de 2023 a las 21:50:59 UTC+2, Justin Israel escribió:
>
>>
>>
>> On Fri, 5 May 2023, 5:44 am Rudi Hammad,  wrote:
>>
>>>
>>> Hello,
>>> since I have time now  I wanted to revive this topic because I have to
>>> make it work for future project.
>>> I am trying to track the error, so I added this the code below before
>>> the error happening with  find_package(Maya REQUIRED)
>>> message ("---")
>>> message (${CMAKE_MODULE_PATH})
>>> message ("---")
>>> So  I wanted to make sure CMAKE_MODULE_PATH is right. As you can see in
>>> the image the path is correct and it contains FinMaya.cmake. And still, it
>>> says I am not providing it. I am really stuck because all looks okey
>>> doesn't it?
>>>
>>
>> Could you try this, to debug the module search path?
>> https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_DEBUG_MODE.html
>>
>>
>> [image: Capture.JPG]
>>> El sábado, 1 de enero de 2022 a las 20:59:55 UTC+1, Justin Israel
>>> escribió:
>>>
>>>> On Sun, Jan 2, 2022 at 7:10 AM Rudi Hammad  wrote:
>>>>
>>>>> So I followed Chad Vernom's cmake tutorials on youtube. First I wrote
>>>>> a everything as he did, and when it came do the build from the command
>>>>> promp I got an error related to maya path or something, so I thought
>>>>> F###k that, I'll just copy his repo from github, since I barely
>>>>> understand CMake syntax and I might have done plenty of errors.
>>>>> Anyway, after copying his repo and rebuilding I get the error
>>>>>
>>>>> -
>>>>>
>>>>> Could not find a package configuration file provided by "Maya" with
>>>>> any of
>>>>>   the following names:
>>>>>
>>>>> MayaConfig.cmake
>>>>> maya-config.cmake
>>>>>
>>>>>   Add the installation prefix of "Maya" to CMAKE_PREFIX_PATH or set
>>>>>   "Maya_DIR" to a directory containing one of the above files.  If
>>>>> "Maya"
>>>>>   provides a separate development package or SDK, be sure it has been
>>>>>   installed.
>>>>>
>>>>> -
>>>>>
>>>>> Since I am not familiar at all with CMake I have no idea what to do
>>>>> with this. According to the error it says " If "Maya"  provides a separate
>>>>> development package or SDK, be sure it has been installed. "
>>>>> So should I install maya's devkit separetly or somehing? I so, how to
>>>>> "install it"? Should I copy paste all folder of "dekitBase" in maya? Do I
>>>>> even need the SDK?
>>>>>
>>>>
>>>> Hey Rudi, Since I don't have a WIndows Maya development environment, I
>>>> can only try and guess at the solutions. But it might help you in the
>>>> meantime, until another Windows user chimes in.
>>>>
>>>> This error looks like it is failing to find the FineMaya.cmake
>>>> extension module that was provided by Chad's repo. The idea here with cmake
>>>> is that it is a build system generator, which supports extension modules to
>>>> do reusable custom tasks, and in this case, to find Maya's development en

Re: [Maya-Python] how to get the return value with MGlobal::executePythonCommandStringResult

2023-04-30 Thread Justin Israel
On Mon, May 1, 2023 at 10:15 AM Rudi Hammad  wrote:

> I spent 2 hours looking into this and you solved it in 2 minutes XD. I
> looked into that documentation definition before, but I didn't understand
> as you did what was going on.
> All good now.(In cpp bootstrap is MString type).
> Thanks Justin.
>

No worries. I actually didn't remember how this all works since it has been
years. So I needed to have a quick play, and saw the issues with trying to
send it all through the result command. It triggered some vague memories of
having done this a long time ago and needing to set up the python env
first, with the context code.


>
> El domingo, 30 de abril de 2023 a las 23:14:38 UTC+2, Justin Israel
> escribió:
>
>> "Executes a Python command that returns a string result from the command
>> engine"
>>
>> Given the documentation, executePythonCommandStringResult wants to parse
>> the python statement through its own command engine. It kind of assumes
>> that the statement sent to this particular function is a single command
>> where it can automatically arrange to capture the string result. So if you
>> feed it larger snippets, the parser gets all wonky. What you can do instead
>> is first feed your supporting code to executePythonCommand(), and then just
>> call executePythonCommandStringResult() with your command. The following
>> works in python:
>>
>> import maya.OpenMaya as om
>>
>> bootstrap = """
>> def foo():
>> xx = cmds.joint()
>> return xx
>> """
>> om.MGlobal.executePythonCommand(bootstrap)
>>
>> c = "foo()"
>> ret = om.MGlobal.executePythonCommandStringResult(c)
>> print(ret)
>>
>>
>> On Mon, May 1, 2023 at 8:22 AM Rudi Hammad  wrote:
>>
>>> Hi,
>>> I am writing a Plugin in C++ and I am having trouble figuring out how to
>>> get a return from python execute code.
>>> For instance, this works perfectly:
>>>
>>>  MString pyCommand2;
>>> pyCommand2 = "cmds.joint()";
>>> auto test2 = MGlobal::executePythonCommandStringResult(pyCommand2);
>>> MGlobal::displayInfo(test2);
>>>
>>> Here I get displayed "joint1", so it is catching the return. But this
>>> doesn't work
>>>
>>> MString pyCommand;
>>> pyCommand =
>>> "def foo():\n"
>>> "xx = cmds.joint()\n"
>>> "return xx\n"
>>> " foo()";
>>>
>>> auto test1 = MGlobal::executePythonCommandStringResult(pyCommand);
>>> MGlobal::displayInfo(test1);
>>>
>>> Here the return value that MGlobal::displayInfo(test1) should provide is
>>> empty.
>>> Any ideas?
>>>
>>> thanks
>>>
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/f8e57985-df64-40fe-b8fb-12906ab943b2n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/f8e57985-df64-40fe-b8fb-12906ab943b2n%40googlegroups.com?utm_medium=email_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/2d7cdd35-f585-48a1-82db-cafd0f17ac15n%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/2d7cdd35-f585-48a1-82db-cafd0f17ac15n%40googlegroups.com?utm_medium=email_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/CAPGFgA00H46u2ZNBR-GAvh%3D2vdO3EL5sX%2BYeRD9fD-xkXGQhjw%40mail.gmail.com.


Re: [Maya-Python] how to get the return value with MGlobal::executePythonCommandStringResult

2023-04-30 Thread Justin Israel
"Executes a Python command that returns a string result from the command
engine"

Given the documentation, executePythonCommandStringResult wants to parse
the python statement through its own command engine. It kind of assumes
that the statement sent to this particular function is a single command
where it can automatically arrange to capture the string result. So if you
feed it larger snippets, the parser gets all wonky. What you can do instead
is first feed your supporting code to executePythonCommand(), and then just
call executePythonCommandStringResult() with your command. The following
works in python:

import maya.OpenMaya as om

bootstrap = """
def foo():
xx = cmds.joint()
return xx
"""
om.MGlobal.executePythonCommand(bootstrap)

c = "foo()"
ret = om.MGlobal.executePythonCommandStringResult(c)
print(ret)


On Mon, May 1, 2023 at 8:22 AM Rudi Hammad  wrote:

> Hi,
> I am writing a Plugin in C++ and I am having trouble figuring out how to
> get a return from python execute code.
> For instance, this works perfectly:
>
>  MString pyCommand2;
> pyCommand2 = "cmds.joint()";
> auto test2 = MGlobal::executePythonCommandStringResult(pyCommand2);
> MGlobal::displayInfo(test2);
>
> Here I get displayed "joint1", so it is catching the return. But this
> doesn't work
>
> MString pyCommand;
> pyCommand =
> "def foo():\n"
> "xx = cmds.joint()\n"
> "return xx\n"
> " foo()";
>
> auto test1 = MGlobal::executePythonCommandStringResult(pyCommand);
> MGlobal::displayInfo(test1);
>
> Here the return value that MGlobal::displayInfo(test1) should provide is
> empty.
> Any ideas?
>
> thanks
>
>
> --
> 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/f8e57985-df64-40fe-b8fb-12906ab943b2n%40googlegroups.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/CAPGFgA0EcJYsompVz55YLj8zk7KRiDTyjTaPsFEGf3WCgtJwPA%40mail.gmail.com.


Re: [Maya-Python] Connect rename command in QListWidget item edit

2023-04-21 Thread Justin Israel
Here is an example with a few of the many ways this could be solved:
https://gist.github.com/justinfx/134992bd323c76d55af2c1b2750ebd84

In the MyListWidget example, it is implementing the edit() hook to capture
when an item edit operation is starting, so that we can remember the
current value before it changes.
Then when the itemChanged signal fires, we can handle the slot and compare
the previous value to the current one and choose to call rename()

The MyListWidget2 example is almost the same, but instead of implementing
edit(), it uses the doubleClicked signal to track the current text value
before it changes. I think I like the previous approach better because it
gives you more specific control over when the edit operation is actually
starting. You can even check the specific edit trigger type if you wanted.

Justin


On Fri, Apr 21, 2023 at 7:08 AM Lien  wrote:

> Hi
>
> I am trying to make a QListWidget items window and want to connect the
> cmds.rename() to take whatever user edit the new item name with double
> click.
>
> I am currently connect things up like:
> geo_list_wdt = QtWidgets.QListWidget()
> geo_list_wdt.itemDoubleClicked.connect(self.rename_item)
>
> Is there a way I can query the name that user input/edit and connect up
> with the rename cmd  (cmds.rename(currentItem_name, user_input)) ?
>
> Thank you,
>
>
>
>
>
> --
> 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/26a95e4c-ee05-4bac-afb1-98608492235cn%40googlegroups.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/CAPGFgA2qktCsoTOKF5sENzxAFAvOth1KJRCA0pQfRvDxxbrADw%40mail.gmail.com.


Re: [Maya-Python] PyMEL 1.3.0 Released

2023-04-17 Thread Justin Israel
On Mon, 17 Apr 2023, 8:11 pm Marcus Ottosson, 
wrote:

> I know that pip installing is a bit less convenient
>
> Just adding my two cents to this on how it is not just a bit less
> convenient, but a complete killer in some cases; the cases that are most
> important from my perspective. Namely, external tools development. Take
> mGear for example. A general purpose auto rigging solution built on PyMEL.
> Their potential userbase went from all Maya users to the few who are
> capable of using pip. From riggers to riggers with scripting and pipeline
> experience. A tiny fraction of what it used to be. As a result, they will
> likely need to move away from PyMEL to regain their audience. And in my
> case, had I built Ragdoll Dynamics on PyMEL, I would not only had lost
> userbase, but the vast majority of revenue for my business. My audience
> isn’t even riggers, but animators. An audience that is not expected to know
> anything about pip or even Python. And certainly would not be able to do
> pull-through caching on Nexus or Artifactory.
>

I don't know. This sounds quite over-dramatic to me. We are talking about
the requirement of a single command to install PyMEL, documented by
Autodesk, using mayapy and a bundled pip module. Is it a stretch to expect
a user to run the command? Is it considered a significantly more complex
step than the instructions a given plugin will list to copy/install the
plugin in the first place? It just seems far fetched to suggest the new
requirement will lose the majority of the user base because it is too
technical. It could be one more step added to the install instructions of
the plugin.
But maybe there are other complications, such as breaking changes between
PyMEL releases and 2 different plugins having different requirements on old
and new behavior and really only one can be installed in Maya. That seems
like more of a potential problem than the installation step issue. You
mentioned vendoring support for PyMEL into plugin projects.

I have great respect and appreciation for PyMEL; it’s how I personally went
> from learning Python with maya.cmds to object-oriented thinking and API
> design. But it’s now in the tough position of drawing a crowd of Python
> beginners who is now also expected to know the down and dirty of Python and
> package management. Not to mention that their audience will now have an
> unpredictable version of PyMEL installed their users system, and having to
> account for the differences in their own tools.
>
> A possible solution that I’d recommend is making PyMEL vendorable.
> Something tools developers can embed into their project such that (1) the
> end-user won’t need to install anything and (2) the version developed
> against remain consistent with the tool. For a project like PyMEL, I’d
> imagine this to be a tall order. But unless something is done, pip
> installing isn’t merely less convenient, but a PyMEL killer, IMO.
>
> On Fri, 7 Apr 2023 at 16:22, Chad Dombrova  wrote:
>
>> Hi all,
>> PyMEL 1.3.0 has been released to PyPI. Those of you paying attention to
>> recent releases of Maya may have noticed that PyMEL is no longer
>> distributed with Maya. The new approach is to use pip to install PyMEL
>> from PyPI, and you can find instructions on how to do this on the PyMEL
>> PyPI page  (as well as github).
>>
>> I know that pip installing is a bit less convenient, but on the bright
>> side distributing via PyPI will give us the ability to make patch releases
>> as needed. If access to PyPI is not available in your working environment
>> due to restricted internet, I highly recommend getting your IT team to set
>> up an internal mirror that can do pull-through caching, like Nexus
>>  or Artifactory
>> , both of which have free
>> versions.
>>
>> On to the release. There are two big improvements in 1.3.0:
>>
>>1. support for Maya 2023 and fixes for 2022 in python3 mode
>>2. very accurate stubs for code completion and static analysis,
>>distributed as PEP 561 -compliant
>>pyi files.
>>
>> The second feature means if you use an editor that understands pyi stubs,
>> like PyCharm and VS Code with Pylance
>> ,
>> you should begin to see immediate improvements just by pip installing pymel
>> into a virtual env that your editor knows about.
>>
>> *I wrote a blog post about the stubs* if you’re interested:
>> https://dev.to/chadrik/pymels-new-type-stubs-2die
>>
>> The new stubs include arguments and their types for nearly all functions
>> in pymel, as well as many return types and even many return types that
>> are conditional based on input arguments.
>>
>> I know that this release has been a long time coming.  Finding the time
>> to put together this announcement added some delays (I’m currently writing

Re: [Maya-Python] submit vray scene export job to deadline

2023-04-10 Thread Justin Israel
I haven't used Deadline before, so maybe someone with more experience will
spot something. But just looking at your script, I was wondering if that
was a copy-paste error in the way you build the project_path with the other
parts of the path. 'example' + 'images/' ? I'm not sure what Deadline would
do if it doesn't like the paths. Do they need to be absolute paths like
your UI example? Do they need to exist?
Have you tried inspecting the maya_deadline_info.job file that you write to
the tempdir and comparing it to the settings that you know to be working
from the UI submission? Is the default renderer that you grab from the Maya
api ending up being set to vrayExport?

On another note, I find that the way you are building your job file string
is quite hard to read and very prone to mistakes if you don't make sure to
line up the order of the format arguments. It would be much safer to use
named template variables like "format {this} {that} {this}
var}".format(that='123', this='abc'). Or to instead build it as a list and
join it, so that you can read every value right where it needs to be and
not have to deal with newlines:

info_text = '\n'.join([
'Foo=' + var1,
'Bar=' + var2,
])

But aside from that, I don't have anything to add about how Deadline is
behaving when it receives that job file.

Justin


On Mon, Apr 10, 2023 at 11:34 PM Amit Yablonski  wrote:

> Hey all.
>
> I'm trying to submit (with python) a job to deadline that will export vray
> scene to a specified location.
> the next step will be to send another job with dependency to the previous
> job that will render those vray scenes files with vray standalone nodes.
>
> i managed to send a job with the right parameters that look similar to the
> job submitted from deadline submitter but it doesn't seems to to take the
> output path for the vray scene from the parameter, instead it take the path
> from the render settings field.
> sometimes it renders instead of exporting vray scene files, not sure why.
> in addition it doesn't export vray scene file foe each render layers if
> the maya scene contains it (i'm using render layer legacy)
>
> i'm using and old script i have to send jobs to deadline.
> in order to send vray scene export jon i cahnge the 'Renderer' to
> 'vrayExport' and specifiy the parameter 'VRayExportFile'
> this is the job parameters:
> [image: Screenshot 2023-04-10 140341.png]
> maybe there is a better way to do it..
>
>
> import subprocess
> import pymel.core as pm
> from maya import cmds
> import sys
> import os
> import time
>
>
> class DeadlineLayer:
> def __init__(self):
> self.version = cmds.about(version=True)
> self.scene_file = cmds.file(q=True, sn=True)
> self.project_path = 'example'
> self.camera = 'persp'
> self.priority = 50
> self.width = pm.getAttr("defaultResolution.width")
> self.height = pm.getAttr("defaultResolution.height")
> self.renderer_name =
> pm.getAttr("defaultRenderGlobals.currentRenderer")
> self.output_path = self.project_path + 'images/'
> self.vray_export_path = self.project_path + 'data/vray_scenes/'
> self.output_file_prefix = 'default_output_file_prefix'
> self.startFrame = str(int(pm.playbackOptions(q=True, min=True)))
> self.endFrame = str(int(pm.playbackOptions(q=True, max=True)))
> self.frame_range = self.startFrame + "-" + self.endFrame
> self.chunk_size = 1
> self.job_name = "default_job_name"
> self.output_directory = ''
> self.pool = 'none'
> self.group = ''
> self.batch_name = 'batch_name_default'
> self.plugin = 'MayaBatch'
>
> def maya_deadline_job(self, layer):
> """
> this function will collect scene file information and write a job
> file
> :return:
> """
> info_txt = 'Animation=1\n' \
>'Renderer={}\n' \
>'UsingRenderLayers=1\n' \
>'RenderLayer={}\n' \
>'RenderHalfFrames=0\n' \
>'LocalRendering=0\n' \
>'StrictErrorChecking=0\n' \
>'MaxProcessors=0\n' \
>'AntiAliasing=high\n' \
>'Version={}\n' \
>'Build=64bit\n' \
>'ProjectPath={}\n' \
>'ImageWidth={}\n' \
>'ImageHeight={}\n' \
>'OutputFilePath={}\n' \
>'OutputFilePrefix={}\n' \
>'VRayExportFile={}\n' \
>'Camera={}\n' \
>'Camera0={}\n' \
>'Camera1=RENDERShape\n' \
>'Camera2=frontShape\n' \
>'Camera3=perspShape\n' \
>'Camera4=sideShape\n' \
>'Camera5=topShape\n' \
>'UseLegacyRenderLayers=1\n' \
>

Re: [Maya-Python] Maya 2024 pyMel ;(

2023-04-02 Thread Justin Israel
The last tag was in Nov 2021
Could it be that it's not actively maintained anymore so Autodesk stopped
bundling it?

On Sun, 2 Apr 2023, 9:38 pm Marcus Ottosson,  wrote:

> I've also tried getting to the bottom of why PyMEL stopped being included
> to begin with in 2023, assuming I missed a conversation somewhere. But it
> appears to have happened out of the blue over at Autodesk headquarters? :O
> Maybe @Chad Dombrova  knows more?
>
> On Sun, 2 Apr 2023 at 00:28, Justin Israel  wrote:
>
>>
>>
>> On Sun, 2 Apr 2023, 11:23 am Abdelhalim abulmagd, <
>> abdelhalim.abulm...@gmail.com> wrote:
>>
>>> Why pymel not available?
>>>
>>
>> Seems like they might have stopped shipping with PyMel as of 2023 and you
>> need to manually install it?
>>
>>
>> https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4
>>
>>
>> https://help.autodesk.com/view/MAYAUL/2023/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4
>>
>>
>>> On Sun, Apr 2, 2023, 12:36 AM DGFA DAG's GRAPHIC & FOTO ART <
>>> gerome@gmail.com> wrote:
>>>
>>>> Hi,
>>>> in Maya 2024 is no more pymel available so I have to switch to what
>>>> ever...
>>>>
>>>> But I struggle with Maya cmds.
>>>> How can I translate this to cmds?
>>>>
>>>> import pymel.core as pm
>>>> # import os
>>>> # import maya.mel as mel
>>>> # main call
>>>>
>>>> def dags_menu():
>>>> # call menu objects
>>>> main_window = pm.language.melGlobals['gMainWindow']
>>>> menu_obj = 'DagsMenu'
>>>> menu_label = 'Dags Tools'
>>>>
>>>> if pm.menu(menu_obj, label=menu_label, parent=main_window, exists=True):
>>>> pm.deleteUI(pm.menu(menu_obj, deleteAllItems=True, e=True))
>>>>
>>>> dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
>>>> tearOff=True)
>>>>
>>>>
>>>> project_menu(dags_menu)
>>>> polygon_menu(dags_menu)
>>>> object_menu(dags_menu)
>>>> script_menu(dags_menu)
>>>> material_menu(dags_menu)
>>>> rigging_menu(dags_menu)
>>>> camera_menu(dags_menu)
>>>> light_menu(dags_menu)
>>>> render_menu(dags_menu)
>>>>
>>>>
>>>> # menu Items
>>>> def project_menu(dags_menu):
>>>> # Main Submenu Project
>>>> # pm.setParent('..', menu=True)
>>>> # dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
>>>> tearOff=True)
>>>> pm.menuItem(label='Project', subMenu=True, parent=dags_menu,
>>>> tearOff=True)
>>>> # set project
>>>> pm.menuItem(
>>>> label='Set Project',
>>>> command='SetProject',
>>>> image='fileOpen.png',
>>>> sourceType='mel',
>>>> optionBox=False,
>>>> visible=True,
>>>> )
>>>>
>>>> pm.menuItem(divider=True)
>>>> # save
>>>> pm.menuItem(
>>>> label='Save',
>>>> command='SaveScene',
>>>> image='save.png',
>>>> sourceType='mel',
>>>> optionBox=False,
>>>> visible=True,
>>>> )
>>>> # save as
>>>> pm.menuItem(
>>>> label='Save Scene As...',
>>>> command='SaveSceneAs',
>>>> image='save.png',
>>>> sourceType='mel',
>>>> optionBox=False,
>>>> visible=True,
>>>> )
>>>> # save incremental
>>>> pm.menuItem(
>>>> label='Increment Save',
>>>> command='IncrementAndSave',
>>>> image='saveToShelf.png',
>>>> sourceType='mel',
>>>> optionBox=False,
>>>> visible=True,
>>>> )
>>>>
>>>> Thanks!
>>>> D.
>>>>
>>>> --
>>>> 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/1b086fbd-ac54-435e-b4e7-7d90d1943eb3n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/1b086fbd-ac54-435e-b4e7-7d90d1943eb3n%40go

Re: [Maya-Python] Maya 2024 pyMel ;(

2023-04-01 Thread Justin Israel
On Sun, 2 Apr 2023, 11:23 am Abdelhalim abulmagd, <
abdelhalim.abulm...@gmail.com> wrote:

> Why pymel not available?
>

Seems like they might have stopped shipping with PyMel as of 2023 and you
need to manually install it?

https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4

https://help.autodesk.com/view/MAYAUL/2023/ENU/?guid=GUID-2AA5EFCE-53B1-46A0-8E43-4CD0B2C72FB4


> On Sun, Apr 2, 2023, 12:36 AM DGFA DAG's GRAPHIC & FOTO ART <
> gerome@gmail.com> wrote:
>
>> Hi,
>> in Maya 2024 is no more pymel available so I have to switch to what
>> ever...
>>
>> But I struggle with Maya cmds.
>> How can I translate this to cmds?
>>
>> import pymel.core as pm
>> # import os
>> # import maya.mel as mel
>> # main call
>>
>> def dags_menu():
>> # call menu objects
>> main_window = pm.language.melGlobals['gMainWindow']
>> menu_obj = 'DagsMenu'
>> menu_label = 'Dags Tools'
>>
>> if pm.menu(menu_obj, label=menu_label, parent=main_window, exists=True):
>> pm.deleteUI(pm.menu(menu_obj, deleteAllItems=True, e=True))
>>
>> dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
>> tearOff=True)
>>
>>
>> project_menu(dags_menu)
>> polygon_menu(dags_menu)
>> object_menu(dags_menu)
>> script_menu(dags_menu)
>> material_menu(dags_menu)
>> rigging_menu(dags_menu)
>> camera_menu(dags_menu)
>> light_menu(dags_menu)
>> render_menu(dags_menu)
>>
>>
>> # menu Items
>> def project_menu(dags_menu):
>> # Main Submenu Project
>> # pm.setParent('..', menu=True)
>> # dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
>> tearOff=True)
>> pm.menuItem(label='Project', subMenu=True, parent=dags_menu, tearOff=True)
>> # set project
>> pm.menuItem(
>> label='Set Project',
>> command='SetProject',
>> image='fileOpen.png',
>> sourceType='mel',
>> optionBox=False,
>> visible=True,
>> )
>>
>> pm.menuItem(divider=True)
>> # save
>> pm.menuItem(
>> label='Save',
>> command='SaveScene',
>> image='save.png',
>> sourceType='mel',
>> optionBox=False,
>> visible=True,
>> )
>> # save as
>> pm.menuItem(
>> label='Save Scene As...',
>> command='SaveSceneAs',
>> image='save.png',
>> sourceType='mel',
>> optionBox=False,
>> visible=True,
>> )
>> # save incremental
>> pm.menuItem(
>> label='Increment Save',
>> command='IncrementAndSave',
>> image='saveToShelf.png',
>> sourceType='mel',
>> optionBox=False,
>> visible=True,
>> )
>>
>> Thanks!
>> D.
>>
>> --
>> 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/1b086fbd-ac54-435e-b4e7-7d90d1943eb3n%40googlegroups.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/CAJLC81Omy4V1XC6-7C-xb58C8qAspHhm1wZEav_7GEwYCxwu8A%40mail.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/CAPGFgA3DK3Sd2m1mEnx%2BTRTrrzkKB52pm6dNtzkwtfg2%3DmOqwA%40mail.gmail.com.


Re: [Maya-Python] Maya 2024 pyMel ;(

2023-04-01 Thread Justin Israel
Almost all of those calls have an equivalent maya cmds function, with the
difference that you pass the string name of the ui object returned from
previous ui calls. So just look at the Maya cmds python api.

Getting the main window name can be done with a call into mel:

gMainWindow = maya.mel.eval('$temp1=$gMainWindow')


On Sun, 2 Apr 2023, 10:36 am DGFA DAG's GRAPHIC & FOTO ART, <
gerome@gmail.com> wrote:

> Hi,
> in Maya 2024 is no more pymel available so I have to switch to what ever...
>
> But I struggle with Maya cmds.
> How can I translate this to cmds?
>
> import pymel.core as pm
> # import os
> # import maya.mel as mel
> # main call
>
> def dags_menu():
> # call menu objects
> main_window = pm.language.melGlobals['gMainWindow']
> menu_obj = 'DagsMenu'
> menu_label = 'Dags Tools'
>
> if pm.menu(menu_obj, label=menu_label, parent=main_window, exists=True):
> pm.deleteUI(pm.menu(menu_obj, deleteAllItems=True, e=True))
>
> dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
> tearOff=True)
>
>
> project_menu(dags_menu)
> polygon_menu(dags_menu)
> object_menu(dags_menu)
> script_menu(dags_menu)
> material_menu(dags_menu)
> rigging_menu(dags_menu)
> camera_menu(dags_menu)
> light_menu(dags_menu)
> render_menu(dags_menu)
>
>
> # menu Items
> def project_menu(dags_menu):
> # Main Submenu Project
> # pm.setParent('..', menu=True)
> # dags_menu = pm.menu(menu_obj, label=menu_label, parent=main_window,
> tearOff=True)
> pm.menuItem(label='Project', subMenu=True, parent=dags_menu, tearOff=True)
> # set project
> pm.menuItem(
> label='Set Project',
> command='SetProject',
> image='fileOpen.png',
> sourceType='mel',
> optionBox=False,
> visible=True,
> )
>
> pm.menuItem(divider=True)
> # save
> pm.menuItem(
> label='Save',
> command='SaveScene',
> image='save.png',
> sourceType='mel',
> optionBox=False,
> visible=True,
> )
> # save as
> pm.menuItem(
> label='Save Scene As...',
> command='SaveSceneAs',
> image='save.png',
> sourceType='mel',
> optionBox=False,
> visible=True,
> )
> # save incremental
> pm.menuItem(
> label='Increment Save',
> command='IncrementAndSave',
> image='saveToShelf.png',
> sourceType='mel',
> optionBox=False,
> visible=True,
> )
>
> Thanks!
> D.
>
> --
> 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/1b086fbd-ac54-435e-b4e7-7d90d1943eb3n%40googlegroups.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/CAPGFgA1iznu-EF3b7EwonVbutKnOoO1MTmpPRxkgNmYHggfMHw%40mail.gmail.com.


Re: [Maya-Python] check channels before constraints

2023-03-27 Thread Justin Israel
On Tue, 28 Mar 2023, 12:21 pm SquashnStretch net, 
wrote:

> Justin I ddnt notice that you rewrote my script! it is so ..beautifull
> that way! thanks, a lot to learn from it!
>

No trouble at all! Happy to help out.
Don't hesitate to come back for more advice, as needed.


> Il giorno lunedì 27 marzo 2023 alle 23:56:35 UTC+1 SquashnStretch net ha
> scritto:
>
>> Thanks Justin for your time and advice.
>>
>> Yes I see the script is super complicated, my original one was mainly
>> inside separated functions but not using many loops actually, I need to
>> practice that, seems the right way...
>>
>> I'll try to work that way and im pretty sure I'll annoying you again ;)
>>
>> thanks!
>> F
>>
>> Il giorno domenica 26 marzo 2023 alle 20:35:30 UTC+1 Justin Israel ha
>> scritto:
>>
>>> Quick tip: If you are going to be sharing code longer than a couple
>>> lines, you might want to use something like a pastebin.com link, or
>>> similar, to retain the formatting and make it easier for others to read.
>>>
>>> Considering that most of the operations on your script apply to each
>>> individual selected object, it would make sense to run the entire thing
>>> under a for-loop. The current structure of the script is a bit confusing
>>> because it starts by operating on each item in the selection, builds up a
>>> new list, and then tries to correlate the new list back to the original
>>> selection. Another thing that is a bit harder to read at first is that you
>>> are storing the current selection as a list-of-lists. It would be more
>>> clear if you just store the single list.
>>>
>>> Check out this refactor of your script: https://pastebin.com/FcR1G32m
>>>
>>> I haven't tested it, so you can use it as a starting point. The idea is
>>> that you start with a main function that will get the current selection and
>>> do the up-front check. Then it will call do_constraint for each selected
>>> object. Within the do_constraint function, you only need to worry about
>>> that specific object. It is best if you avoid relying on manipulating the
>>> current selection to make your script work, and instead pass the target
>>> objects to the maya functions.
>>>
>>> Let me know if you need clarification on any part of that script.
>>>
>>> Justin
>>>
>>>
>>>
>>>
>>> On Mon, Mar 27, 2023 at 4:28 AM SquashnStretch net 
>>> wrote:
>>>
>>>> Hello again, update
>>>> I managed to make it work a bit better but still not as I need to...
>>>> thanks to your suggestions I'm able now to check channels and create
>>>> locators, constraints etc ...
>>>> So I have a script that checks everything and if selections have both
>>>> rotations and translations available, it runs the function properly; if
>>>> there is something locked it stop and warn. And I can also have several
>>>> objects selected.
>>>>
>>>> Now Im trying something more...
>>>> I'd like the script to check what channel is available and act
>>>> accordingly, if there is only translation, it contstraint just the
>>>> translations, if only rotations available, it works only with that
>>>> I ended up make it work by adding the skipRotation or skipTranslation
>>>> flag
>>>> but it works only selecting one object at a time, if I select several
>>>> object in the scene where some has both T and R and some had just
>>>> translation and no rotations, it fails for all the object but work only for
>>>> the first one
>>>>
>>>> I guess I need a loop or another condition which checks inside my
>>>> 'userSel' variable but not sure how to do.
>>>> Probably the problem is in the sel[0] call, which looks only on the
>>>> first obj selected, I tried to add a loop but it works only with
>>>> translation, seems that it doesnt connect the rotations
>>>>
>>>> anyways this is what I have so far which works only selecting obj 1 by
>>>> 1:
>>>>
>>>> # this works fine BUT 1 obj x time
>>>>
>>>>
>>>> import maya.cmds as mc
>>>>
>>>>
>>>> LocList = []
>>>>
>>>> userSel = []
>>>>
>>>> len(userSel)
>>>>
>>>> sel = []
>>>>
>>>> sel = mc.ls(sl=1)
>>>>
>>>&g

Re: [Maya-Python] check channels before constraints

2023-03-26 Thread Justin Israel
w=1)
>
> elif _has_rot ==0 and _has_trans ==1:
>
> for idx, item in enumerate(LocList):
>
> ctl = item
>
> makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True,
> w=1, sr=['x', 'y', 'z'])
>
> elif _has_rot ==1 and _has_trans ==0:
>
> for idx, item in enumerate(LocList):
>
> ctl = item
>
> makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True,
> w=1, st=['x', 'y', 'z'])
> Il giorno sabato 25 marzo 2023 alle 22:18:19 UTC SquashnStretch net ha
> scritto:
>
>> that's great Justin, yes with settable I can what is available, now I'll
>> try to check with a condition.I'll let you know if im able to :D
>>
>> thanks
>> F
>>
>> Il giorno sabato 25 marzo 2023 alle 21:20:47 UTC Justin Israel ha scritto:
>>
>>> The getAttr function can tell you if an attribute is locked, or even
>>> "settable":
>>>
>>> https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/getAttr.html
>>>
>>> On Sun, Mar 26, 2023 at 9:05 AM SquashnStretch net 
>>> wrote:
>>>
>>>> Hello everyone,
>>>> I wrote (with a lot of difficulties :) my first python script where I
>>>> wanted to create a locator constraint to any selected animated object, bake
>>>> the anim and reverse the constraint , basically to easily change space if
>>>> needed .
>>>> the script works well but only if the animated object has translate and
>>>> rotate channels available, if they are locked or hidden, the script fails.
>>>>
>>>> Basically I dont know how to check first which channel is available and
>>>> based on the result, constraint only available channels
>>>> hope it makes sense to you 
>>>>
>>>> this is what I have so far and thanks in advance for any helps!
>>>> 
>>>> import maya.cmds as mc
>>>>
>>>> #loc list
>>>> userSel = []
>>>> LocList = []
>>>> len(userSel)
>>>> # get the user selection
>>>> sel = mc.ls(sl=1)
>>>> userSel.append(sel)
>>>>
>>>> # create a loc for ech selected obj and constraint to it
>>>> for obj in sel:
>>>> if len(sel)!=0:
>>>> newLoc = mc.spaceLocator()
>>>> newCon = mc.parentConstraint(obj, newLoc, mo=0)
>>>> LocList.append(newLoc)
>>>> else:
>>>> mc.warning('Please make a selection')
>>>>
>>>> # select all new Loc
>>>> if len(sel) != 0:
>>>> for loc in LocList:
>>>> mc.select (loc, add=1)
>>>> start = mc.playbackOptions(q=True, min=True)
>>>> end = mc.playbackOptions(q=True, max=True)
>>>> mc.bakeResults(sm=1, sr=1, t=(start, end))
>>>> else:
>>>> mc.warning('Please make a selection')
>>>>
>>>> for loc in LocList:
>>>> mc.select (loc, add=1)
>>>> mc.delete(cn=1)
>>>>
>>>> # reverse connection
>>>> for idx, item in enumerate(LocList):
>>>> ctl = item
>>>> makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True, w=1)
>>>>
>>>> --
>>>> 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_m...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/5c5853a4-ec08-40fa-bfea-2bb39ee333d5n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/5c5853a4-ec08-40fa-bfea-2bb39ee333d5n%40googlegroups.com?utm_medium=email_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/4a3f2b41-209c-4868-a257-640db3a3bb41n%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/4a3f2b41-209c-4868-a257-640db3a3bb41n%40googlegroups.com?utm_medium=email_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/CAPGFgA2bRJTHbp2cwOnrhghb3V36%2Bc1P9O6t1swOh%2BRVAvPgVg%40mail.gmail.com.


Re: [Maya-Python] check channels before constraints

2023-03-25 Thread Justin Israel
The getAttr function can tell you if an attribute is locked, or even
"settable":
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/getAttr.html

On Sun, Mar 26, 2023 at 9:05 AM SquashnStretch net <
squashnstret...@gmail.com> wrote:

> Hello everyone,
> I wrote (with a lot of difficulties :) my first python script where I
> wanted to create a locator constraint to any selected animated object, bake
> the anim and reverse the constraint , basically to easily change space if
> needed .
> the script works well but only if the animated object has translate and
> rotate channels available, if they are locked or hidden, the script fails.
>
> Basically I dont know how to check first which channel is available and
> based on the result, constraint only available channels
> hope it makes sense to you 
>
> this is what I have so far and thanks in advance for any helps!
> 
> import maya.cmds as mc
>
> #loc list
> userSel = []
> LocList = []
> len(userSel)
> # get the user selection
> sel = mc.ls(sl=1)
> userSel.append(sel)
>
> # create a loc for ech selected obj and constraint to it
> for obj in sel:
> if len(sel)!=0:
> newLoc = mc.spaceLocator()
> newCon = mc.parentConstraint(obj, newLoc, mo=0)
> LocList.append(newLoc)
> else:
> mc.warning('Please make a selection')
>
> # select all new Loc
> if len(sel) != 0:
> for loc in LocList:
> mc.select (loc, add=1)
> start = mc.playbackOptions(q=True, min=True)
> end = mc.playbackOptions(q=True, max=True)
> mc.bakeResults(sm=1, sr=1, t=(start, end))
> else:
> mc.warning('Please make a selection')
>
> for loc in LocList:
> mc.select (loc, add=1)
> mc.delete(cn=1)
>
> # reverse connection
> for idx, item in enumerate(LocList):
> ctl = item
> makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True, w=1)
>
> --
> 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/5c5853a4-ec08-40fa-bfea-2bb39ee333d5n%40googlegroups.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/CAPGFgA0ozdWmGhWeu3RfAt%2Bk-gWeRvBhfgNs%2BM7iOmutWD%2Besw%40mail.gmail.com.


Re: [Maya-Python] Maya linux Crashing on py3 not with py2

2023-01-01 Thread Justin Israel
Is it an upgrade from a previous major version of Maya that may be picking
up python2 plugins or startup code?

On Sun, 1 Jan 2023, 7:57 pm Maize S,  wrote:

> Hey all,
>
> I have a stack trace here. I cant seem to launch maya 2022, if i add the
> args -pythonver 2 to my command maya launches with no issues.
>
> This is the stack trace:
> https://pastebin.com/q2GZuKSY
>
> Im not much of a python programmer as im still learning but help on this
> matter would be extremely helpful.
>
> Kind regards
>
> --
> 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/7861fee1-b405-471b-9621-3c8b2105bd63n%40googlegroups.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/CAPGFgA3k7_GuuimQx_f4yYuV5CzaOr%3D1ocmnOfB4BpKtVEdD3g%40mail.gmail.com.


Re: [Maya-Python] Maya Python API 1.0 output value to an Array

2022-12-27 Thread Justin Israel
On Wed, 28 Dec 2022, 2:42 am hwee li,  wrote:

> hi, Justin
>   thanks for your reply and your code , after I got someone's help , it is
> about the parameter pointer issues between C++ and Python, which needs
> MscriptUtil() to solve , the blow code works finally .
>

All good. I was avoiding MScriptUtil because it feels like more work than
needed to get the values when you can get them straight from the MColor
instead of special pointer helpers.
Glad you got a solution that works for you!


>
> import maya.OpenMaya as om
>
> mColor=om.MColor(123,222,122)
>
> uti0=om.MScriptUtil()
> uti0.createFromDouble(0.0,0.0,0.0)
> ptr_0=uti0.asFloatPtr()
>
> mColor.get(ptr_0)
>
> print uti0.getFloatArrayItem(ptr_0,1)
> print uti0.getFloatArrayItem(ptr_0,2)
> print uti0.getFloatArrayItem(ptr_0,3)
>
>
> On Tuesday, 27 December 2022 at 21:39:47 UTC+8 hwee li wrote:
>
>> test
>>
>> On Tuesday, 27 December 2022 at 11:13:52 UTC+8 justin...@gmail.com wrote:
>>
>>> Working with Maya arrays and wrappers between Python and C++ is not
>>> always intuitive. Would it be easier to just grab the value as needed?
>>>
>>> import maya.OpenMaya as omi
>>>
>>> col = omi.MColor(1.0, 0.5, 0.25)
>>> # tuple
>>> rgb = col.r, col.g, col.b
>>> # If you need MFloatArray
>>> arr = omi.MFloatArray(3)
>>> arr[0], arr[1], arr[2] = rgb
>>>
>>>
>>>
>>> On Mon, Dec 26, 2022 at 10:46 PM hwee li  wrote:
>>>
 hi, can I know how to get the Out value from maya.OpenMaya API
 correctly ?

 for example, I read the Maya document about MColor object, it has a
 function get() which can output color value to an array.
 MColor.Get()
 

 but in python, when I tried to create an array like
 *array=[0.0,0.0,0.0] *
 or use maya api
 *array= MFloatArray(3)*

 then run the get function from a MColor object

 *colorObject.get(array)*

 maya will give me an error `
 "in method 'MColor_get', argument 2 of type 'float [3]"`
 it seems that the array object I created is not the correct type for
 output value to write in, anyone know how to fix this, I know there is a
 better way in API 2.0 , but I hope to figure out how to solve this kind of
 output value type for API1.0 in python .

 --
 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_m...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/5d08ac61-058d-4575-b55f-f63fb20eaf40n%40googlegroups.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/adc2584e-d59f-400b-8119-368b42b38e90n%40googlegroups.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/CAPGFgA3UVZo9DMvZ%2Bcwm5P%3D9XGB7TXRod_h2--myhiM5zxxZ7g%40mail.gmail.com.


Re: [Maya-Python] Maya Python API 1.0 output value to an Array

2022-12-26 Thread Justin Israel
Working with Maya arrays and wrappers between Python and C++ is not always
intuitive. Would it be easier to just grab the value as needed?

import maya.OpenMaya as omi

col = omi.MColor(1.0, 0.5, 0.25)
# tuple
rgb = col.r, col.g, col.b
# If you need MFloatArray
arr = omi.MFloatArray(3)
arr[0], arr[1], arr[2] = rgb



On Mon, Dec 26, 2022 at 10:46 PM hwee li  wrote:

> hi, can I know how to get the Out value from maya.OpenMaya API correctly ?
>
> for example, I read the Maya document about MColor object, it has a
> function get() which can output color value to an array.
> MColor.Get()
> 
>
> but in python, when I tried to create an array like
> *array=[0.0,0.0,0.0] *
> or use maya api
> *array= MFloatArray(3)*
>
> then run the get function from a MColor object
>
> *colorObject.get(array)*
>
> maya will give me an error `
> "in method 'MColor_get', argument 2 of type 'float [3]"`
> it seems that the array object I created is not the correct type for
> output value to write in, anyone know how to fix this, I know there is a
> better way in API 2.0 , but I hope to figure out how to solve this kind of
> output value type for API1.0 in python .
>
> --
> 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/5d08ac61-058d-4575-b55f-f63fb20eaf40n%40googlegroups.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/CAPGFgA1wsFY1sRfB%2Bo4sa4EaqqEBHcyzp1329s0Mc5FRJMs1ow%40mail.gmail.com.


Re: [Maya-Python] Re: (Maya Python) Is there a way to run a command from a menuItem inside a objectMenu

2022-12-20 Thread Justin Israel
On Wed, 21 Dec 2022, 2:24 pm Kat Patterson,  wrote:

> This helped greatly! Thank you so very much!!
>
> I do have one last question, do you know of a way to make the the changes
> of the dropdown menus only run off of a press of a button? (as in i have a
> 'create' button next to each dropdown menu). As in if i change the option
> to 'sphere' it doesnt change it when i press the option, it changes if i
> press the create button?
>
> It is alright if there is not an option like this, I am very greatful for
> you helping me ♥
>

Yes just don't set the callback on the optionMenu. Instead you can set a
callback on your button that will query the current value from the
optionMenu.

https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/button.html#flagcommand

You will need to save the name of the optionMenu that is returned when you
created it. Then you can query the value of it:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html#flagvalue

Note that the value supports the query mode, so you can do:

opt = cmds.optionMenu(savedOptionsName, q=True, value=True)


> On Tuesday, December 20, 2022 at 5:51:01 PM UTC-7 justin...@gmail.com
> wrote:
>
>> On Wed, Dec 21, 2022 at 1:42 PM Kat Patterson 
>> wrote:
>>
>>> Okay so that did help, but now I am back to how do I add it to each
>>> individual command (i posted my code, it is a menu that creates an object,
>>> and another option to duplicate that object said amount of times) and how
>>> do I add the button into the mix to make said dropdown options run
>>>
>>
>> Well like the document that I had included says, when you use optionMenu,
>> it no longer respects the command attached to each menuItem. You would
>> control it all through the single callback that fires when the option
>> changes. You can either use an if/else like this:
>>
>> def printNewMenuItem(item):
>> if item == "Sphere":
>> printSphere()
>> elif item == "Cube":
>> printCube()
>> def printSphere():
>> print("It's a sphere!")
>> def printCube():
>> print("It's a cube!")
>>
>> Or you can define it in a map to make it easier:
>>
>> menuCallbacks = {
>> "Sphere": printSphere,
>> "Cube": printCube,
>> }
>> def printNewMenuItem(item):
>> cbk = menuCallbacks.get(item)
>> if cbk:
>> cbk()
>> else:
>> print("Oops. I didnt define a callback for {}".format(item))
>>
>>
>>
>>>
>>> On Tuesday, December 20, 2022 at 5:25:09 PM UTC-7 justin...@gmail.com
>>> wrote:
>>>
 On Wed, Dec 21, 2022 at 1:19 PM Kat Patterson 
 wrote:

> def printNewMenuItem( item ):
> print item
>
> This code alone ALWAYS produces a invalid syntax on my end, so I am
> unable to check if that even works, or how it even works. I have looked at
> the documentation and am unable to find a workaround while looking at
> either of those documentation sites.
>

 Are you running a version of Maya using python3? If so,

 def printNewMenuItem( item ):
 print(item)


>
> Any ideas?
>
> On Tuesday, December 20, 2022 at 5:14:28 PM UTC-7 justin...@gmail.com
> wrote:
>
>> Hi Kat,
>>
>> Have a look here:
>>
>> https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html
>>
>> "Note that commands attached to menu items will not get called.
>> Attach any commands via the -cc/changedCommand flag."
>>
>> And specifically the changeCommand:
>>
>> https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html#flagchangeCommand
>>
>> The example at the bottom of the page actually shows you how to use
>> the callback, which will receive the value of the menuItem when it is
>> changed in the optionMenu.
>>
>> Justin
>>
>>
>> On Wed, Dec 21, 2022 at 1:11 PM Kat Patterson 
>> wrote:
>>
>>> https://pastebin.com/SfLxjFmG
>>>
>>> On Tuesday, December 20, 2022 at 5:09:19 PM UTC-7 Kat Patterson
>>> wrote:
>>>
 I am in need of some help, not sure how active this forum is
 anymore.

 I am looking to see if there is any way to make a optionMenu run a
 command for each option in the drop down menu? I am pretty new to maya
 python so I do not know very much, but google is less helpful than 
 finding
 everything out myself.

 Here is the code that i currently have, I just am not sure how to
 connect the commands to the actual window ui;


 --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> 

Re: [Maya-Python] Re: (Maya Python) Is there a way to run a command from a menuItem inside a objectMenu

2022-12-20 Thread Justin Israel
On Wed, Dec 21, 2022 at 1:42 PM Kat Patterson 
wrote:

> Okay so that did help, but now I am back to how do I add it to each
> individual command (i posted my code, it is a menu that creates an object,
> and another option to duplicate that object said amount of times) and how
> do I add the button into the mix to make said dropdown options run
>

Well like the document that I had included says, when you use optionMenu,
it no longer respects the command attached to each menuItem. You would
control it all through the single callback that fires when the option
changes. You can either use an if/else like this:

def printNewMenuItem(item):
if item == "Sphere":
printSphere()
elif item == "Cube":
printCube()
def printSphere():
print("It's a sphere!")
def printCube():
print("It's a cube!")

Or you can define it in a map to make it easier:

menuCallbacks = {
"Sphere": printSphere,
"Cube": printCube,
}
def printNewMenuItem(item):
cbk = menuCallbacks.get(item)
if cbk:
cbk()
else:
print("Oops. I didnt define a callback for {}".format(item))



>
> On Tuesday, December 20, 2022 at 5:25:09 PM UTC-7 justin...@gmail.com
> wrote:
>
>> On Wed, Dec 21, 2022 at 1:19 PM Kat Patterson 
>> wrote:
>>
>>> def printNewMenuItem( item ):
>>> print item
>>>
>>> This code alone ALWAYS produces a invalid syntax on my end, so I am
>>> unable to check if that even works, or how it even works. I have looked at
>>> the documentation and am unable to find a workaround while looking at
>>> either of those documentation sites.
>>>
>>
>> Are you running a version of Maya using python3? If so,
>>
>> def printNewMenuItem( item ):
>> print(item)
>>
>>
>>>
>>> Any ideas?
>>>
>>> On Tuesday, December 20, 2022 at 5:14:28 PM UTC-7 justin...@gmail.com
>>> wrote:
>>>
 Hi Kat,

 Have a look here:

 https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html

 "Note that commands attached to menu items will not get called. Attach
 any commands via the -cc/changedCommand flag."

 And specifically the changeCommand:

 https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html#flagchangeCommand

 The example at the bottom of the page actually shows you how to use the
 callback, which will receive the value of the menuItem when it is changed
 in the optionMenu.

 Justin


 On Wed, Dec 21, 2022 at 1:11 PM Kat Patterson 
 wrote:

> https://pastebin.com/SfLxjFmG
>
> On Tuesday, December 20, 2022 at 5:09:19 PM UTC-7 Kat Patterson wrote:
>
>> I am in need of some help, not sure how active this forum is anymore.
>>
>> I am looking to see if there is any way to make a optionMenu run a
>> command for each option in the drop down menu? I am pretty new to maya
>> python so I do not know very much, but google is less helpful than 
>> finding
>> everything out myself.
>>
>> Here is the code that i currently have, I just am not sure how to
>> connect the commands to the actual window ui;
>>
>>
>> --
> 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_m...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/16e3c45b-8fba-4542-83a9-750fbc0e1ce4n%40googlegroups.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_m...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/e49e0fb6-aceb-4549-b406-e76fb5025476n%40googlegroups.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/b99ee3df-4f2f-4134-b1e3-6ceb062dn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the 

Re: [Maya-Python] Re: (Maya Python) Is there a way to run a command from a menuItem inside a objectMenu

2022-12-20 Thread Justin Israel
On Wed, Dec 21, 2022 at 1:19 PM Kat Patterson 
wrote:

> def printNewMenuItem( item ):
> print item
>
> This code alone ALWAYS produces a invalid syntax on my end, so I am unable
> to check if that even works, or how it even works. I have looked at the
> documentation and am unable to find a workaround while looking at either of
> those documentation sites.
>

Are you running a version of Maya using python3? If so,

def printNewMenuItem( item ):
print(item)


>
> Any ideas?
>
> On Tuesday, December 20, 2022 at 5:14:28 PM UTC-7 justin...@gmail.com
> wrote:
>
>> Hi Kat,
>>
>> Have a look here:
>>
>> https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html
>>
>> "Note that commands attached to menu items will not get called. Attach
>> any commands via the -cc/changedCommand flag."
>>
>> And specifically the changeCommand:
>>
>> https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html#flagchangeCommand
>>
>> The example at the bottom of the page actually shows you how to use the
>> callback, which will receive the value of the menuItem when it is changed
>> in the optionMenu.
>>
>> Justin
>>
>>
>> On Wed, Dec 21, 2022 at 1:11 PM Kat Patterson 
>> wrote:
>>
>>> https://pastebin.com/SfLxjFmG
>>>
>>> On Tuesday, December 20, 2022 at 5:09:19 PM UTC-7 Kat Patterson wrote:
>>>
 I am in need of some help, not sure how active this forum is anymore.

 I am looking to see if there is any way to make a optionMenu run a
 command for each option in the drop down menu? I am pretty new to maya
 python so I do not know very much, but google is less helpful than finding
 everything out myself.

 Here is the code that i currently have, I just am not sure how to
 connect the commands to the actual window ui;


 --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/16e3c45b-8fba-4542-83a9-750fbc0e1ce4n%40googlegroups.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/e49e0fb6-aceb-4549-b406-e76fb5025476n%40googlegroups.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/CAPGFgA29evEBhORu%2BwgrOx7dKS1HzjKm7%3D1BKD-ww9V2uGHCsw%40mail.gmail.com.


Re: [Maya-Python] Re: (Maya Python) Is there a way to run a command from a menuItem inside a objectMenu

2022-12-20 Thread Justin Israel
Hi Kat,

Have a look here:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html

"Note that commands attached to menu items will not get called. Attach any
commands via the -cc/changedCommand flag."

And specifically the changeCommand:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html#flagchangeCommand

The example at the bottom of the page actually shows you how to use the
callback, which will receive the value of the menuItem when it is changed
in the optionMenu.

Justin


On Wed, Dec 21, 2022 at 1:11 PM Kat Patterson 
wrote:

> https://pastebin.com/SfLxjFmG
>
> On Tuesday, December 20, 2022 at 5:09:19 PM UTC-7 Kat Patterson wrote:
>
>> I am in need of some help, not sure how active this forum is anymore.
>>
>> I am looking to see if there is any way to make a optionMenu run a
>> command for each option in the drop down menu? I am pretty new to maya
>> python so I do not know very much, but google is less helpful than finding
>> everything out myself.
>>
>> Here is the code that i currently have, I just am not sure how to connect
>> the commands to the actual window ui;
>>
>>
>> --
> 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/16e3c45b-8fba-4542-83a9-750fbc0e1ce4n%40googlegroups.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/CAPGFgA2QH-142fM4AS8Mc36zTCm%2B_Dayrnw36Yd%2B98GqJmHwRQ%40mail.gmail.com.


Re: [Maya-Python] enable preference option via command

2022-12-16 Thread Justin Israel
On Sat, 17 Dec 2022, 2:03 am Pacifique Nzitonda, <
nzitondapacifi...@gmail.com> wrote:

> Indeed I'm using the inViewmessage from cmds but I noticed sometime in
> Maya that option in disabled in preferences.
> Now I'm looking how to enable it. I also discovered that I can check if it
> is checked or not through Maya optionVars but can't find a way to set it
> On/off
>

Did you try enabling the option in the ScriptEditor menu that will echo
commands as you interact with the UI? It may tell you what is being called
when you toggle the checkbox.


> On Fri, 16 Dec 2022, 13:06 vince touache,  wrote:
>
>> Some maya tools (or third-party tools) use heads up messages as a
>> convenient way to give the user some information. I can't remember off top
>> of my head what tools is using it in maya, but for the time being, you can
>> generate a custom one, and I'm sure that will look familiar!
>> inViewMessage -smg "test message" -pos topRight -bkc 0x -fade;
>> (MEL)
>> source:
>> https://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/Commands/inViewMessage.html
>> If your In-View messages are enabled, you'll be able to see the message.
>> Otherwise, it'll be ignored.
>> Now I'm not sure exactly what you mean by "a way to check/uncheck this
>> button". Can't you simply tick the box from the gui? If not, it might be a
>> graphical bug, and my next try would be to change it via script (I suppose
>> using optionVar)
>>
>>
>> Le ven. 16 déc. 2022, à 12 h 51, Pacifique Nzitonda <
>> nzitondapacifi...@gmail.com> a écrit :
>>
>>> Hi,
>>> Can someone tell me what is the command or a way to check/uncheck this
>>> button?
>>> [image: dasdsa.JPG]
>>>
>>> Thanks
>>>
>>> --
>>> 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/4bd7892c-00b0-47cf-b22a-6865c4239fe2n%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/python_inside_maya/oLPUGfUmrfo/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CAHChmQbZdci9_uB9b0T%3D%3DqEk9Gef4pMegZbEgRhWGPVuf_wwOA%40mail.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/CACNQXpXLdsXxHjtZdNoN_rxPp2vrWS_9VmEjXtaroFqJLmKbeg%40mail.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/CAPGFgA0tLXSFHUA7ba6srhYWDdnwoiHRfxagT4_aAEERSVRkRQ%40mail.gmail.com.


Re: [Maya-Python] Distribute spheres on ellipse pattern with python

2022-10-10 Thread Justin Israel
On Tue, Oct 11, 2022 at 4:30 AM joão chaves  wrote:

> Hey. I believe it would like a diamond in case of 4.
>

In the current implementation, you would have a diamond. But if the 4
points were evenly spaced, you would have a square.


> On Mon, Oct 10, 2022, 15:30 Marcus Ottosson 
> wrote:
>
>> > The only issue I have is that it doesn't evenly distribute the spheres
>> along the ellipse, maybe that's not easy to accomplish?
>>
>> Got an interesting thought-experiment for you. :) What would it look like
>> to only distribute 3 or 4 spheres in an ellipse, with even spacing? Pen and
>> paper is allowed.
>>
>> On Mon, 10 Oct 2022 at 11:41, johancc  wrote:
>>
>>> Hey Justin. That's awesome! Thanks a lot for looking into it. The only
>>> issue I have is that it doesn't evenly distribute the spheres along the
>>> ellipse, maybe that's not easy to accomplish?
>>> But this helps me a lot anyways. :)
>>>
>>>
>>> [image: ellipse.jpg]
>>> A segunda-feira, 10 de outubro de 2022 à(s) 08:38:18 UTC+1,
>>> justin...@gmail.com escreveu:
>>>
>>>> Full disclosure, I am not a math guy and I didn't know the solution
>>>> straight away. But I wanted to look it up and see if I could apply it,
>>>> given a known max and min radius, and an angle.
>>>> I found this to be the most useful of all the links I had found:
>>>> https://stackoverflow.com/a/17762156/496445
>>>>
>>>> What do you think of this solution I came up with based on that?
>>>> https://gist.github.com/justinfx/b257dc162680978786ed4fd45409c997
>>>>
>>>>
>>>> On Mon, Oct 10, 2022 at 9:52 AM joão chaves 
>>>> wrote:
>>>>
>>>>> Hey all.
>>>>>
>>>>> I have a simple script that distributes spheres in a circular pattern
>>>>> (fixed by Justin Israel), and was looking for a solution that would
>>>>> distribute them in an ellipse/oval pattern. I am also trying to do this in
>>>>> bifrost, but as I have done for the circular pattern I need to understand
>>>>> the math first in python.
>>>>>
>>>>> I also found this formula “(x2/a2) + (y2/b2) = 1” but not sure how to
>>>>> apply it.
>>>>>
>>>>> Thank you!
>>>>>
>>>>> import maya.cmds as cmds
>>>>>
>>>>> degrees = 180
>>>>> max_iterations = 21
>>>>> t_x = 6
>>>>> radius=0.15
>>>>>
>>>>> for i in range(max_iterations):
>>>>>
>>>>> print(i)
>>>>>
>>>>>
>>>>> if degrees % 360 == 0:
>>>>> rotation = float(degrees) / max_iterations * i
>>>>> else:
>>>>> rotation = float(degrees) * i / (max_iterations-1)
>>>>>
>>>>> my_sphere = cmds.polySphere(r=radius)
>>>>> cmds.move(t_x,my_sphere, x=1 , absolute=1)
>>>>> cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot', 
>>>>> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>>>>>
>>>>> cmds.rotate(rotation, my_sphere, y=1)
>>>>>
>>>>> --
>>>>> 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_m...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com?utm_medium=email_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/fbe47165-173a-477e-bbdb-1a51d275764dn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/fbe4716

Re: [Maya-Python] Distribute spheres on ellipse pattern with python

2022-10-10 Thread Justin Israel
Full disclosure, I am not a math guy and I didn't know the solution
straight away. But I wanted to look it up and see if I could apply it,
given a known max and min radius, and an angle.
I found this to be the most useful of all the links I had found:
https://stackoverflow.com/a/17762156/496445

What do you think of this solution I came up with based on that?
https://gist.github.com/justinfx/b257dc162680978786ed4fd45409c997


On Mon, Oct 10, 2022 at 9:52 AM joão chaves  wrote:

> Hey all.
>
> I have a simple script that distributes spheres in a circular pattern
> (fixed by Justin Israel), and was looking for a solution that would
> distribute them in an ellipse/oval pattern. I am also trying to do this in
> bifrost, but as I have done for the circular pattern I need to understand
> the math first in python.
>
> I also found this formula “(x2/a2) + (y2/b2) = 1” but not sure how to
> apply it.
>
> Thank you!
>
> import maya.cmds as cmds
>
> degrees = 180
> max_iterations = 21
> t_x = 6
> radius=0.15
>
> for i in range(max_iterations):
>
> print(i)
>
>
> if degrees % 360 == 0:
> rotation = float(degrees) / max_iterations * i
> else:
> rotation = float(degrees) * i / (max_iterations-1)
>
> my_sphere = cmds.polySphere(r=radius)
> cmds.move(t_x,my_sphere, x=1 , absolute=1)
> cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot', 
> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>
> cmds.rotate(rotation, my_sphere, y=1)
>
> --
> 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/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAEuwZHykcUm1Oc%2BQc%2BdU3BBt4rzP8wvLwvv3ckx2C%3DWo4CVHkg%40mail.gmail.com?utm_medium=email_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/CAPGFgA3SbP4FPWsWnwcSD0jz-2uXRVq_H0DXKn7HQdSRsD90Mw%40mail.gmail.com.


Re: [Maya-Python] Duplicate spheres in half circle

2022-10-07 Thread Justin Israel
On Sat, 8 Oct 2022, 2:07 pm joão chaves,  wrote:

> Hey Justin. Thank you so much, this works perfectly :) And that solution
> for the full circle comes in handy too!
>
> Just in case someone stumbles upon this, there is a small typo in your
> code, an extra ")" at the end of the else line. (at least was giving me a
> syntax error)
>

Oops :-)


> Awesome, have a great weekend!
>

You're welcome. Enjoy!


> Justin Israel  escreveu no dia sábado, 8/10/2022
> à(s) 00:17:
>
>>
>>
>> On Sat, Oct 8, 2022 at 7:14 AM johancc  wrote:
>>
>>> Hey, trying to create a radial pattern with a sphere in Python, but
>>> somehow I am missing the last sphere.
>>>
>>> [image: sphere.png]
>>>
>>> As you can see by the image and code below, I am trying to distribute 7
>>> spheres in 180 degrees. If I set it to 360 degrees works fine as it already
>>> has the last point, the first sphere. But if I set it to 90 or 180 for
>>> example, it misses the last sphere. I need to somehow add this last sphere,
>>> but not sure how.
>>>
>>> Increasing the number of spheres (max_iterations) won't do the trick as
>>> it will distribute one more object within a similar radius.
>>>
>>> btw, this can easily be done with MASH and duplicate special, but I need
>>> this in python.
>>> Thank you.
>>>
>>> import maya.cmds as cmds
>>>
>>> degrees = 180
>>> max_iterations = 7
>>>
>>> for i in range(max_iterations):
>>> #print (i)
>>> rotation = (degrees/max_iterations) * i
>>> #print(rotation)
>>> my_sphere = cmds.polySphere(r=0.15)
>>> cmds.move(2,my_sphere, x=1 , absolute=1)
>>> cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot',
>>> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>>>
>>> cmds.rotate(rotation, my_sphere, y=1)
>>>
>>
>> In the case of a complete circle this rotation calculation works because
>> the distribution is shorter and doesn't try to place spheres on a scale of
>> 0-360 inclusive. So what you probably want is to actually place a sphere at
>> the last degree, inclusive.
>>
>> Original:
>>
>> degrees = 180
>> max_iterations = 7
>>
>> [(degrees / max_iterations * i) for i in range(max_iterations)]# Result: [0, 
>> 25, 50, 75, 100, 125, 150] #
>>
>> [(degrees * (float(i) / (max_iterations-1))) for i in 
>> range(max_iterations)]# Result: [0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0] 
>> #
>>
>> Now with the updated calculation it creates the last sphere on the upper
>> limit of degrees (180). But you might not want it distributed that way for
>> a closed circle where it's going to overlap the first and last? So then
>> maybe you want to choose something like this?
>>
>> for i in range(max_iterations):
>> if degrees % 360 == 0:
>> rotation = float(degrees) / max_iterations * i
>> else:
>> rotation = float(degrees) * i / (max_iterations-1))
>> print("#{}: rotation={}".format(i, rotation))
>> my_sphere = cmds.polySphere(r=0.15)
>> cmds.move(2,my_sphere, x=1 , absolute=1)
>> cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot', 
>> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>>
>> cmds.rotate(rotation, my_sphere, y=1)
>>
>>
>> --
>>> 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/32352ddd-7840-4e3a-a0da-194d7410b28bn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/32352ddd-7840-4e3a-a0da-194d7410b28bn%40googlegroups.com?utm_medium=email_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/CAPGFgA1cQeBzxu4Ajah_a0jD0CgZ%2BQmqi9rHumCK8FpE6M-QNQ%40mail.gmail.com
>> <https://groups.google

Re: [Maya-Python] Duplicate spheres in half circle

2022-10-07 Thread Justin Israel
On Sat, Oct 8, 2022 at 7:14 AM johancc  wrote:

> Hey, trying to create a radial pattern with a sphere in Python, but
> somehow I am missing the last sphere.
>
> [image: sphere.png]
>
> As you can see by the image and code below, I am trying to distribute 7
> spheres in 180 degrees. If I set it to 360 degrees works fine as it already
> has the last point, the first sphere. But if I set it to 90 or 180 for
> example, it misses the last sphere. I need to somehow add this last sphere,
> but not sure how.
>
> Increasing the number of spheres (max_iterations) won't do the trick as it
> will distribute one more object within a similar radius.
>
> btw, this can easily be done with MASH and duplicate special, but I need
> this in python.
> Thank you.
>
> import maya.cmds as cmds
>
> degrees = 180
> max_iterations = 7
>
> for i in range(max_iterations):
> #print (i)
> rotation = (degrees/max_iterations) * i
> #print(rotation)
> my_sphere = cmds.polySphere(r=0.15)
> cmds.move(2,my_sphere, x=1 , absolute=1)
> cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot',
> my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )
>
> cmds.rotate(rotation, my_sphere, y=1)
>

In the case of a complete circle this rotation calculation works because
the distribution is shorter and doesn't try to place spheres on a scale of
0-360 inclusive. So what you probably want is to actually place a sphere at
the last degree, inclusive.

Original:

degrees = 180
max_iterations = 7

[(degrees / max_iterations * i) for i in range(max_iterations)]#
Result: [0, 25, 50, 75, 100, 125, 150] #

[(degrees * (float(i) / (max_iterations-1))) for i in
range(max_iterations)]# Result: [0.0, 30.0, 60.0, 90.0, 120.0, 150.0,
180.0] #

Now with the updated calculation it creates the last sphere on the upper
limit of degrees (180). But you might not want it distributed that way for
a closed circle where it's going to overlap the first and last? So then
maybe you want to choose something like this?

for i in range(max_iterations):
if degrees % 360 == 0:
rotation = float(degrees) / max_iterations * i
else:
rotation = float(degrees) * i / (max_iterations-1))
print("#{}: rotation={}".format(i, rotation))
my_sphere = cmds.polySphere(r=0.15)
cmds.move(2,my_sphere, x=1 , absolute=1)
cmds.move( 0,0,0, [ my_sphere[0]+'.scalePivot',
my_sphere[0]+'.rotatePivot' ], xyz=1, absolute=1 )

cmds.rotate(rotation, my_sphere, y=1)


-- 
> 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/32352ddd-7840-4e3a-a0da-194d7410b28bn%40googlegroups.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/CAPGFgA1cQeBzxu4Ajah_a0jD0CgZ%2BQmqi9rHumCK8FpE6M-QNQ%40mail.gmail.com.


Re: [Maya-Python] Python Loop Speed Performance Question & C++ MPxCommand Question

2022-09-23 Thread Justin Israel
I just want to point out that it's not clear that the python GIL is going
to be an issue here unless you are trying to multithread this operation
(which your code doesn't show). The GIL prevents python code from running
in parallel. It can run concurrently by context switching back and forth
quickly to appear parallel. But again, your example code shows that it's
just a single thread doing loops.
So really I think you are seeing the performance issue from having a super
large outer loop * inner loop, and how python has to do alot more work when
it comes to performing reflection on each type, as well as a temporary list
conversion on each point tuple. This is where you might see your gains from
C++ doing the loops, by being able to static type the variables.


On Fri, 23 Sept 2022, 7:27 pm daeseok chae,  wrote:

> Thank you.
>
> I think it will be difficult at the Python level, so I am trying to
> implement the code in C++.
>
> Let's try Array Argument & Return using JSON to String.
>
> 2022년 9월 23일 금요일 오후 4시 18분 35초 UTC+9에 Marcus Ottosson님이 작성:
>
>> Oh, yes you are. My mistake, I'll need to adjust my glasses before
>> replying. 
>>
>> On Friday, 23 September 2022 at 08:17:07 UTC+1 cds...@gmail.com wrote:
>>
>>> hello
>>> I'm already using from maya.api import OpenMaya.
>>> So should I use from maya import OpenMaya?
>>> Is it 1.0 > 2.0?
>>>
>>> 2022년 9월 23일 금요일 오후 4시 7분 53초 UTC+9에 Marcus Ottosson님이 작성:
>>>
 Thanks, the first potential optimisation I can spot is the use of Maya
 API 1.0. I would take 2.0 for a spin also - i.e. from maya.api import
 OpenMaya - I would expect either a small or major improvement, since
 there is less serialisation going on between Python and C++ in 2.0.

 On Fri, 23 Sept 2022 at 08:05, daeseok chae  wrote:

> Hello, thanks for the reply.
>
> I'll show you a simple example of the Python code I'm currently
> writing.
>
> ```
> from maya.api import OpenMaya
>
> DIRECTION_VEC = [OpenMaya.MFloatVector(0, 1, 0),
> OpenMaya.MFloatVector(0, -1, 0), OpenMaya.MFloatVector(1, 0, 0),
> OpenMaya.MFloatVector(-1, 0, 0)]
> mesh = "pCube1" # Deformed
> selectionList = OpenMaya.MGlobal.getSelectionListByName(mesh)
> mDagPath = selectionList.getDagPath(0)
> meshFn = OpenMaya.MFnMesh(mDagPath)
>
> def isIntersectPoints(meshFn, point):
> sourcePt = OpenMaya.MFloatPoint(list(point))
> for directionVec in DIRECTION_VEC:
> if not meshFn.anyIntersection(sourcePt, directionVec,
> OpenMaya.MSpace.kWorld, , False):
> return False;
> return True
>
> idsList = []
> index = 0
> for point in positions: # positions e.g) [(0, 0, 0), (0.5, 0.5, 0.5)
> ... ] count : 10,000
> if isIntersectPoints(meshFn, point):
> idsList.append(index)
> index += 1
> ```
>
> Thank you.
> 2022년 9월 23일 금요일 오후 3시 50분 3초 UTC+9에 Marcus Ottosson님이 작성:
>
>> Hello! I can shed some light on these.
>>
>> I tried to work the Python Loop part with C++ MPxCommand, but I
>> couldn’t find a way to return data by executing the Arguments in the form
>> of Float3Array (Point Positions) and the corresponding command. (Return :
>> IntArray)
>>
>> If you are certain that looping isn’t going to be fast enough in
>> Python, which I don't doubt, then yes this is what I would do. You won’t 
>> be
>> able to return data outside of simple types like integers, floats and
>> strings. But what you can do is serialise the data into e.g. JSON and
>> output a string, and then deserialise it from Python. This is what I
>> normally do. At a certain point, deserialising can become a bottleneck, 
>> at
>> which point you have a JSON deserialiser in PySide2 which may be faster.
>>
>> It is said that the part can be written in C++ using PyBind, but I
>> know that the For Loop speed is limited due to the same GIL issue. Is 
>> there
>> any way to solve it??
>>
>> This point was what prompted me to reply - don’t do it! :D
>>
>> Both MPxCommand and PyBind can work outside of any GIL - they are
>> both called outside of Python - and while PyBind *can* return more
>> complex types like vectors and even Python objects it is terribly
>> inconvenient to work with in Maya. Because Maya - and Python in general -
>> cannot reload or unload a binary Python module. Yes, you read that right.
>> Once you import myBinaryModule you cannot unload it. At all. The
>> only recourse is restarting Maya.
>>
>> Other than that, if that isn’t a problem, then PyBind is a good
>> option for this. You can even pass a NumPy data structure, which would
>> bypass Python even further and keep all data - especially heavy data - in
>> C++ and be as fast as it can be.
>>
>> It seems that there is no way to increase the 

Re: [Maya-Python] PySide2 undo/redo inside Maya

2022-09-23 Thread Justin Israel
On Sat, 24 Sept 2022, 3:29 am Pacifique Nzitonda, <
nzitondapacifi...@gmail.com> wrote:

> Thanks  Marcus,
> After reading your answer, I'll stick to what I have now: for every
> method  I open and close an undoInfo chunk.
>
> I'm writing a renamer tool:
> [image: RENAMER.JPG]
>
> My hope was to find a clean way of handling the undo/redo for each button
> operation.
>

It sounds like what you want is your try/finally example around each button
callback so that esch button click generates its own undo. If you plan to
sometimes combine methods for different buttons, then you could use the
undo only in special wrappers for the button callback only.

def buttonCallback1():
openchunk
method 1
method 2
closechunk

def buttonCallback2():
openchunk
method 2
method 3
closechunk

On Friday, September 23, 2022 at 12:24:16 PM UTC+2 Marcus Ottosson wrote:
>
>> You’ve got the right idea, but I’m not sure what you expect is what your
>> users would expect? Am I understanding it correctly that a user would:
>>
>>1. Open your UI
>>2. Click a button
>>3. Think for a moment..
>>4. Click another button
>>5. Check their phone..
>>6. Click a third button
>>7. Close the UI
>>
>> And then when they hit Ctrl + Z it would undo each of these 3 button
>> presses? If it was me, I would expect 3 clicks to require 3 undos.
>>
>> If you really did want to undo each of the three items, then you’re on a
>> bit of thin ice but not impossibly thin. You can:
>>
>>1. On window open, open that undo chunk
>>2. Let the user click buttons
>>3. On window close, close the undo chunk
>>
>> That way, the next undo would undo all of it. The reason it’s thin ice is
>> because the undo chunk is global to Maya and would include anything they do
>> outside of it also. So the next undo may take other things with it that
>> falls outside of your control.
>>
>> Generally, undo has a temperament and should be dealt with cautiously. It
>> can easily break other undo’s in the queue and often bring Maya down with
>> it. So if you can, I would recommend you do what Maya does naturally and
>> avoid undoInfo.
>>
>> On Fri, 23 Sept 2022 at 10:59, Pacifique Nzitonda 
>> wrote:
>>
>>> I have a question about PySide2 undo/redo in Maya. I read a discussions
>>> about using undoInfo Maya command but what if my GUI has to interact with
>>> many methods? How can I create an undo/redo for all of them at once instead
>>> of doing:
>>>
>>> def method1():
>>> cmds.undoInfo(openChunk=True)
>>> # my code
>>> #
>>> cmds.undoInfo(closeChunk=True)
>>>
>>> # or even
>>> def method2():
>>> try
>>> cmds.undoInfo(openChunk=True)
>>> # my code
>>> #
>>> except:
>>> pass
>>> finally:
>>> cmds.undoInfo(closeChunk=True)
>>>
>>> def method3():
>>> cmds.undoInfo(openChunk=True)
>>> # my code
>>> #
>>> cmds.undoInfo(closeChunk=True)
>>>
>>>
>>> I want this:
>>>
>>> cmds.undoInfo(openChunk=True)
>>> def method1()
>>> def method2()
>>> def method3()
>>> cmds.undoInfo(closeChunk=True)
>>>
>>> Knowing that each method is connected to a button on the GUI
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/15e4aa30-72d1-4122-b1ee-d40b9c63d068n%40googlegroups.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/f2c3aece-a447-43af-9be4-789eaa809e02n%40googlegroups.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/CAPGFgA3384Z9Pj1WEAZ4rkzHQnFBs7eV2pDpmC0xdh6%2BepmzRA%40mail.gmail.com.


Re: [Maya-Python] Custom Python Menu loading from yaml

2022-08-28 Thread Justin Israel
On Sun, Aug 28, 2022 at 8:28 PM DGFA DAG's GRAPHIC & FOTO ART <
gerome@gmail.com> wrote:

> Hi,
>
> I got my custom menu in pyton as well in mel but I want to load the menu
> structure from a yaml file e.g. like this
>
> - command: SetProject
>   icon: fileOpen.png
>   label: Set Project
>   lang: mel
> - divider: ''
> - command: IncrementAndSave
>   icon: saveToShelf.png
>   label: Save icremental
>   lang: mel
> - command: SaveSceneAs
>   icon: save.png
>   label: Save as
>   lang: mel
> - divider: ''
>
> How can I achive this?
>

In Python you can use PyYAML to read in your file.
https://pypi.org/project/PyYAML/
Then you can iterate over the list of commands and call the appropriate
Maya Python menu functions. If you already have this solved in Python then
I would say just have your MEL code call this python code and reuse the
same logic, since there is no point in trying to write and maintain it in 2
places.


>
> Thanks!
>
> --
> 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/67fc3631-dce5-45ae-99cb-32333e7bde12n%40googlegroups.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/CAPGFgA0Qt-n7348XgPmZaERaYwL_PPN%3D1BSRVkkdRGNCWcchbQ%40mail.gmail.com.


Re: [Maya-Python] Mel commands under Python or vice versa

2022-08-27 Thread Justin Israel
>
> DGFA DAG's GRAPHIC & FOTO ART schrieb am Samstag, 27. August 2022 um
>> 08:15:14 UTC+2:
>>
>>> When I do this I get an error "Error line 1.35 Syntax error"
>>> When I run his line as standalone python("import mat"; mat.run()"
>>> this is working but I need a command for the menuItem that runs Mel
>>> commands or python command/script.
>>>
>>> In Maya documentation there are examples for menu but no one have the
>>> flag -c included.
>>>
>>
There are examples of using the python() MEL function in the MEL docs:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/python.html

However, if you are coding your menu in MEL and you want to have your
menuItem use a python syntax callback, then you should check the
documentation for menuItem:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/menuItem.html

You will notice that there is a   *-sourceType*(*-stp*)   flag that allows
you to tell the menu to use python for the callback syntax:

menuItem -p $mainWindow -l "Create Material" -sourceType "python" -c
"import mat; mat.do_something()"


>>> vince touache schrieb am Samstag, 27. August 2022 um 01:34:10 UTC+2:
>>>
 I don't have a maya available to test it currently, but did you try to
 run your command via the "python
 "
 keyword in MEL?
 Calling, in MEL:

 *python "import mat;mat.do_something()" *

 should be understood correctly by your MEL call, I assume


 Le ven. 26 août 2022, à 18 h 58, DGFA DAG's GRAPHIC & FOTO ART <
 gerom...@gmail.com> a écrit :

> Hi,
>
> I struggle with a custom menu. I will to have my own menu with all the
> stuff I have in several shelfs. But when I codethe menu in Mel I don’t 
> know
> how to set the command attribute for executing a Mel  command.
> For example:
> Mel
> menuItem -p $mainWindow -l "Set Project" -c "SetProject"
> menuItem -p $mainWindow -l "Create Material" -c "source mat.py"
>
> The first line works fine the second throws an error "file mat.py not
> found"
>
> How can I solve this?
>
> Thanks,
> Dag
>
> --
> 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_m...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/fe306d38-7042-4206-8656-b105c298d1a8n%40googlegroups.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/de96d854-40d0-48e2-b077-d91609f0cc38n%40googlegroups.com
>> 
>> .
>>
>
>
> --
> "God is a metaphor for a mystery that absolutely transcends all human
> categories of thought. It's as simple as that!" - Joseph Campbell
>
> --
> 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/CAP_aC5avGYkS0B4DUvy9T_fma0MvYmKFWEN7fkTK3q-D7Hn-yQ%40mail.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/CAPGFgA2N1A8yXukXEhLb9W2sKhdHzQJEi8DcnfKj%3DfsuKrLtQw%40mail.gmail.com.


Re: [Maya-Python] dagMenuProc

2022-07-26 Thread Justin Israel
On Tue, 26 Jul 2022, 6:08 pm Sridhar M, 
wrote:

> Hello Justin,
>
> Thanks for your email, I checked the directory and dagMenuProc.mel file.
> It is set to global and in the same directory as the
> buildObjectMenuItemsNow.mel but still I'm facing the same issue do let me
> know if there are any other things I could do or check.
>
> Thanks Again
>
> Regards,
> Sridhar M
>

If things are where they should be then I don't have any other suggestions
other than maybe a 2023 bug loading Mel procs?
Or something else being loaded and messing with things. Maybe someone with
Maya 2023 can comment.


> On Tue, Jul 26, 2022 at 3:10 AM Justin Israel 
> wrote:
>
>>
>>
>> On Mon, Jul 25, 2022 at 10:56 PM Sridhar M 
>> wrote:
>>
>>> Hello Guys, Please help me with the problem
>>> // Error: line 1: Cannot find procedure "dagMenuProc".
>>>
>>> // Error: file: C:/Program
>>> Files/Autodesk/Maya2023/scripts/others/buildObjectMenuItemsNow.mel line
>>> 140: Cannot find procedure "dagMenuProc".
>>>
>>> whenever i using right click and drag option in object mode, i got this
>>> error message.
>>>
>>
>> There should be a dagMenuProc.mel file in the same directory as
>> buildObjectMenuItemsNow.mel
>> Within that file it should be defining "global proc dagMenuProc"
>> Those two factors mean that maya should have automatically loaded and
>> defined dagMenuProc, as it sources all of the mel files and exports all
>> global procs to make them available between mel scripts.
>>
>>
>>> --
>>> 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/48ec0d68-fa62-4f2e-a097-d3a78f393f7dn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/48ec0d68-fa62-4f2e-a097-d3a78f393f7dn%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/python_inside_maya/lTdBfrtrCho/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CAPGFgA1XdM4-8uGWRP2E%2BsHbfCp-HJ4mpx9L776BuAyRKbjObw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1XdM4-8uGWRP2E%2BsHbfCp-HJ4mpx9L776BuAyRKbjObw%40mail.gmail.com?utm_medium=email_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/CAPnMZ1g9NLuGkKHhcupkQdomBPwTjd-DdRPf0sg%3DtPMSUafW5A%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPnMZ1g9NLuGkKHhcupkQdomBPwTjd-DdRPf0sg%3DtPMSUafW5A%40mail.gmail.com?utm_medium=email_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/CAPGFgA2NU0CbTSaHcmB%3Dv-kPR8aK65VGRfVC8Ug%3D4UXPU%3DTbkg%40mail.gmail.com.


Re: [Maya-Python] dagMenuProc

2022-07-25 Thread Justin Israel
On Mon, Jul 25, 2022 at 10:56 PM Sridhar M 
wrote:

> Hello Guys, Please help me with the problem
> // Error: line 1: Cannot find procedure "dagMenuProc".
>
> // Error: file: C:/Program
> Files/Autodesk/Maya2023/scripts/others/buildObjectMenuItemsNow.mel line
> 140: Cannot find procedure "dagMenuProc".
>
> whenever i using right click and drag option in object mode, i got this
> error message.
>

There should be a dagMenuProc.mel file in the same directory as
buildObjectMenuItemsNow.mel
Within that file it should be defining "global proc dagMenuProc"
Those two factors mean that maya should have automatically loaded and
defined dagMenuProc, as it sources all of the mel files and exports all
global procs to make them available between mel scripts.


> --
> 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/48ec0d68-fa62-4f2e-a097-d3a78f393f7dn%40googlegroups.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/CAPGFgA1XdM4-8uGWRP2E%2BsHbfCp-HJ4mpx9L776BuAyRKbjObw%40mail.gmail.com.


Re: [Maya-Python] maya MQUtil Issue

2022-06-25 Thread Justin Israel
On Sun, 26 Jun 2022, 4:30 pm TTw TTa,  wrote:

> I want wo modify Maya UI with PySide2
>
> [image: uTools_1656217414133.png]
> so I write those code
> 
>
> In line 58,I got child widget But it was QList object whitch was
> wrapped with swig
>
> My Qustion was How Could I get this wraped Qt object content, Because
> PySide2 does not has QList type
> ···
>  qt_children = MayaQt.swigToQt(swig_children,   Qustion_Code)
> ···
>

Does shiboken complain if you ask it to wrap to a Python list type?

qt_children = MayaQt.swigToQt(swig_children, list)

I can't test anything at the moment. But I would hope QList is defined in
shiboken to map to python list. Not sure if it returns a list of swig
pointers that again need to be wrapped.


>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> 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/ed15f6c3-0e0b-47b5-8277-4e7863d2a029n%40googlegroups.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/CAPGFgA0dFQN0KUEVNHB3Mz82erWmmOy2c37-hN3L9YcXmKuE3g%40mail.gmail.com.


Re: [Maya-Python] Pyside2/Qt : Image as button with hover state

2022-06-25 Thread Justin Israel
I was back at my computer today so I figured I would give you a complete
example of using the event handlers:

class MyPushButton(QPushButton):

def __init__(self, *a, **kw):
super(MyPushButton, self).__init__(*a, **kw)

pix_normal = QPixmap("my_image.jpg")
pix_over = pix_normal.copy()
painter = QtGui.QPainter(pix_over)
painter.fillRect(pix_over.rect(), QtGui.QBrush(QtGui.QColor(0,0,0,128)))
painter.end()

self._icon_normal = QIcon(pix_normal)
self._icon_over = QIcon(pix_over)
self.setIcon(self._icon_normal)

def enterEvent(self, event):
self.setIcon(self._icon_over)
return super(MyPushButton, self).enterEvent(event)

def leaveEvent(self, event):
self.setIcon(self._icon_normal)
return super(MyPushButton, self).leaveEvent(event)

Justin


On Sun, Jun 26, 2022 at 7:19 AM Justin Israel 
wrote:

>
>
> On Sat, 25 Jun 2022, 5:07 pm johancc,  wrote:
>
>> I was able to darken the image within the paint event, but can't get it
>> to work inside the enterEvent.
>
>
> In your init for the custom button, you can generate the darkened pixmap
> once and then use it over and over in the enterEvent to set the icon.
>
> Create a new QPixmap from the source via calling source_pixmap.copy()
> Start a QPainter with the copy, and darken it.
> Now you have a darkened copy of the pixmap and do not have to keep
> recreating it. Use it in the event handlers.
>
>
>
>
>> from PySide2 import QtWidgets
>> from PySide2 import QtGui
>> from PySide2 import QtCore
>>
>> class PicButton(QtWidgets.QAbstractButton):
>> def __init__(self, pixmap, parent=None):
>> super(PicButton, self).__init__(parent)
>> self.pixmap = pixmap
>>
>> def paintEvent(self, event):
>> painter = QtGui.QPainter(self)
>> painter.drawPixmap(event.rect(), self.pixmap)
>>
>>
>> #painter.setCompositionMode(QtGui.QPainter.CompositionMode_DestinationIn)
>> painter.fillRect(event.rect(), QtGui.QBrush(QtGui.QColor
>> (0,0,0,128)))
>>
>> def enterEvent(self, event):
>> print('hovering')
>>
>> def sizeHint(self):
>> return self.pixmap.size()
>>
>> window_wid = QtWidgets.QWidget()
>> vlayout_wid = QtWidgets.QVBoxLayout()
>>
>> myPixmap = QtGui.QPixmap("D:\DOWNLOADS\GSG Assets S22-R25\GSG
>> Assets\HDRIS\Hdris 1\Commercial
>> Locations\PlusThumbnails\Concrete_Office_Outside.jpg")
>>
>> my_button = PicButton(myPixmap)
>> my_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
>> my_button.setMaximumSize(200,100)
>>
>>
>> vlayout_wid.addWidget(my_button)
>> window_wid.setLayout(vlayout_wid)
>> window_wid.show()
>>
>> A sábado, 25 de junho de 2022 à(s) 05:50:59 UTC+1, johancc escreveu:
>>
>>> Hi, thanks for the reply. Honestly I didn't want to have another image
>>> on the hover effect, I just wanted to darken it or light it somehow with
>>> code. Just not sure how.
>>>
>>> Anyways, I ended up changing a bit the code. Here's my current setup:
>>>
>>> from PySide2 import QtWidgets
>>> from PySide2 import QtGui
>>> from PySide2 import QtCore
>>>
>>> class PicButton(QtWidgets.QAbstractButton):
>>> def __init__(self, pixmap, parent=None):
>>> super(PicButton, self).__init__(parent)
>>> self.pixmap = pixmap
>>>
>>> def paintEvent(self, event):
>>> painter = QtGui.QPainter(self)
>>> painter.drawPixmap(event.rect(), self.pixmap)
>>>
>>> def sizeHint(self):
>>> return self.pixmap.size()
>>>
>>> window_wid = QtWidgets.QWidget()
>>> vlayout_wid = QtWidgets.QVBoxLayout()
>>>
>>> myPixmap = QPixmap(""my_image.jpg")
>>> my_button = PicButton(myPixmap)
>>> my_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
>>> my_button.setMaximumSize(200,100)
>>>
>>>
>>> vlayout_wid.addWidget(my_button)
>>> window_wid.setLayout(vlayout_wid)
>>> window_wid.show()
>>> A sábado, 25 de junho de 2022 à(s) 05:42:03 UTC+1, justin...@gmail.com
>>> escreveu:
>>>
>>>> On Sat, Jun 25, 2022 at 4:12 PM johancc  wrote:
>>>>
>>>>> Q: How to add the hover state to this button I have (as an image)? I
>>>>> need it to have the "hand icon" when hovering and also some sort of 
>>>>> overlay
>>>>> lik

Re: [Maya-Python] Pyside2/Qt : Image as button with hover state

2022-06-25 Thread Justin Israel
On Sat, 25 Jun 2022, 5:07 pm johancc,  wrote:

> I was able to darken the image within the paint event, but can't get it to
> work inside the enterEvent.


In your init for the custom button, you can generate the darkened pixmap
once and then use it over and over in the enterEvent to set the icon.

Create a new QPixmap from the source via calling source_pixmap.copy()
Start a QPainter with the copy, and darken it.
Now you have a darkened copy of the pixmap and do not have to keep
recreating it. Use it in the event handlers.




> from PySide2 import QtWidgets
> from PySide2 import QtGui
> from PySide2 import QtCore
>
> class PicButton(QtWidgets.QAbstractButton):
> def __init__(self, pixmap, parent=None):
> super(PicButton, self).__init__(parent)
> self.pixmap = pixmap
>
> def paintEvent(self, event):
> painter = QtGui.QPainter(self)
> painter.drawPixmap(event.rect(), self.pixmap)
>
>
> #painter.setCompositionMode(QtGui.QPainter.CompositionMode_DestinationIn)
> painter.fillRect(event.rect(), QtGui.QBrush(QtGui.QColor
> (0,0,0,128)))
>
> def enterEvent(self, event):
> print('hovering')
>
> def sizeHint(self):
> return self.pixmap.size()
>
> window_wid = QtWidgets.QWidget()
> vlayout_wid = QtWidgets.QVBoxLayout()
>
> myPixmap = QtGui.QPixmap("D:\DOWNLOADS\GSG Assets S22-R25\GSG
> Assets\HDRIS\Hdris 1\Commercial
> Locations\PlusThumbnails\Concrete_Office_Outside.jpg")
>
> my_button = PicButton(myPixmap)
> my_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
> my_button.setMaximumSize(200,100)
>
>
> vlayout_wid.addWidget(my_button)
> window_wid.setLayout(vlayout_wid)
> window_wid.show()
>
> A sábado, 25 de junho de 2022 à(s) 05:50:59 UTC+1, johancc escreveu:
>
>> Hi, thanks for the reply. Honestly I didn't want to have another image on
>> the hover effect, I just wanted to darken it or light it somehow with code.
>> Just not sure how.
>>
>> Anyways, I ended up changing a bit the code. Here's my current setup:
>>
>> from PySide2 import QtWidgets
>> from PySide2 import QtGui
>> from PySide2 import QtCore
>>
>> class PicButton(QtWidgets.QAbstractButton):
>> def __init__(self, pixmap, parent=None):
>> super(PicButton, self).__init__(parent)
>> self.pixmap = pixmap
>>
>> def paintEvent(self, event):
>> painter = QtGui.QPainter(self)
>> painter.drawPixmap(event.rect(), self.pixmap)
>>
>> def sizeHint(self):
>> return self.pixmap.size()
>>
>> window_wid = QtWidgets.QWidget()
>> vlayout_wid = QtWidgets.QVBoxLayout()
>>
>> myPixmap = QPixmap(""my_image.jpg")
>> my_button = PicButton(myPixmap)
>> my_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
>> my_button.setMaximumSize(200,100)
>>
>>
>> vlayout_wid.addWidget(my_button)
>> window_wid.setLayout(vlayout_wid)
>> window_wid.show()
>> A sábado, 25 de junho de 2022 à(s) 05:42:03 UTC+1, justin...@gmail.com
>> escreveu:
>>
>>> On Sat, Jun 25, 2022 at 4:12 PM johancc  wrote:
>>>
 Q: How to add the hover state to this button I have (as an image)? I
 need it to have the "hand icon" when hovering and also some sort of overlay
 like a darkening/lighting effect. Is it possible with my current code? I am
 using pyside/qt inside a DCC application, in this case Autodesk Maya 2022.
 Thank you.

 from PySide2.QtWidgets import QApplication, QPushButton
 from PySide2.QtGui import QPixmap, QIcon
 from PySide2.QtCore import QSize

 def clicked():
 print("Button clicked!")

 window_wid = QtWidgets.QWidget()
 vlayout_wid = QtWidgets.QVBoxLayout()


 # Set Push Button
 button = QPushButton()

 button.setMaximumSize(200,100)

 vlayout_wid.addWidget(button)

 # Set image in Push Button
 pixmap = QPixmap("my_image.jpg")
 button_icon = QIcon(pixmap)
 button.setIcon(button_icon)
 button.setIconSize(QSize(200,100))

 #button.show()
 button.clicked.connect(clicked)

 window_wid.setLayout(vlayout_wid)
 window_wid.show()

 [image: qt.png]

>>>
>>> QIcon has an "active" mode state but the widget has to support it and it
>>> seems QPushButton does not use the active state of the QIcon during hover.
>>> You could use a custom stylesheet, but that has the effect of needing to
>>> be fully styled or your button looks weird.
>>>
>>> So a pretty easy solution is to just have a custom button class, where
>>> you have full control over what to do when hover starts and stops:
>>>
>>> class MyPushButton(QPushButton):
>>>
>>> def __init__(self, *a, **kw):
>>> super(MyPushButton, self).__init__(*a, **kw)
>>> self._icon_normal = QIcon(QPixmap("my_image.jpg"))
>>> self._icon_over = QIcon(QPixmap("my_image_over.jpg"))
>>>
>>> def enterEvent(self, event):
>>> self.setIcon(self._icon_over)
>>> return super(MyPushButton, self).enterEvent(event)
>>>
>>> def 

Re: [Maya-Python] Pyside2/Qt : Image as button with hover state

2022-06-24 Thread Justin Israel
On Sat, 25 Jun 2022, 4:51 pm johancc,  wrote:

> Hi, thanks for the reply. Honestly I didn't want to have another image on
> the hover effect, I just wanted to darken it or light it somehow with code.
> Just not sure how.
>

If the hover state doesn't need to be recalculated all the time, you could
just generate a lighter version of the original pixmap using QPainter and
then keep using my original example.
A custom paint event gets called often. So it only makes sense if you want
to actively control how it repaints. It would work as well though.


> Anyways, I ended up changing a bit the code. Here's my current setup:
>
> from PySide2 import QtWidgets
> from PySide2 import QtGui
> from PySide2 import QtCore
>
> class PicButton(QtWidgets.QAbstractButton):
> def __init__(self, pixmap, parent=None):
> super(PicButton, self).__init__(parent)
> self.pixmap = pixmap
>
> def paintEvent(self, event):
> painter = QtGui.QPainter(self)
> painter.drawPixmap(event.rect(), self.pixmap)
>
> def sizeHint(self):
> return self.pixmap.size()
>
> window_wid = QtWidgets.QWidget()
> vlayout_wid = QtWidgets.QVBoxLayout()
>
> myPixmap = QPixmap(""my_image.jpg")
> my_button = PicButton(myPixmap)
> my_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
> my_button.setMaximumSize(200,100)
>
>
> vlayout_wid.addWidget(my_button)
> window_wid.setLayout(vlayout_wid)
> window_wid.show()
> A sábado, 25 de junho de 2022 à(s) 05:42:03 UTC+1, justin...@gmail.com
> escreveu:
>
>> On Sat, Jun 25, 2022 at 4:12 PM johancc  wrote:
>>
>>> Q: How to add the hover state to this button I have (as an image)? I
>>> need it to have the "hand icon" when hovering and also some sort of overlay
>>> like a darkening/lighting effect. Is it possible with my current code? I am
>>> using pyside/qt inside a DCC application, in this case Autodesk Maya 2022.
>>> Thank you.
>>>
>>> from PySide2.QtWidgets import QApplication, QPushButton
>>> from PySide2.QtGui import QPixmap, QIcon
>>> from PySide2.QtCore import QSize
>>>
>>> def clicked():
>>> print("Button clicked!")
>>>
>>> window_wid = QtWidgets.QWidget()
>>> vlayout_wid = QtWidgets.QVBoxLayout()
>>>
>>>
>>> # Set Push Button
>>> button = QPushButton()
>>>
>>> button.setMaximumSize(200,100)
>>>
>>> vlayout_wid.addWidget(button)
>>>
>>> # Set image in Push Button
>>> pixmap = QPixmap("my_image.jpg")
>>> button_icon = QIcon(pixmap)
>>> button.setIcon(button_icon)
>>> button.setIconSize(QSize(200,100))
>>>
>>> #button.show()
>>> button.clicked.connect(clicked)
>>>
>>> window_wid.setLayout(vlayout_wid)
>>> window_wid.show()
>>>
>>> [image: qt.png]
>>>
>>
>> QIcon has an "active" mode state but the widget has to support it and it
>> seems QPushButton does not use the active state of the QIcon during hover.
>> You could use a custom stylesheet, but that has the effect of needing to
>> be fully styled or your button looks weird.
>>
>> So a pretty easy solution is to just have a custom button class, where
>> you have full control over what to do when hover starts and stops:
>>
>> class MyPushButton(QPushButton):
>>
>> def __init__(self, *a, **kw):
>> super(MyPushButton, self).__init__(*a, **kw)
>> self._icon_normal = QIcon(QPixmap("my_image.jpg"))
>> self._icon_over = QIcon(QPixmap("my_image_over.jpg"))
>>
>> def enterEvent(self, event):
>> self.setIcon(self._icon_over)
>> return super(MyPushButton, self).enterEvent(event)
>>
>> def leaveEvent(self, event):
>> self.setIcon(self._icon_normal)
>> return super(MyPushButton, self).enterEvent(event)
>>
>>
>> You can do any other settings you want in addition to changing the icon.
>>
>> Justin
>>
>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/28a6b738-6028-4504-b057-6c526bc37da9n%40googlegroups.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/dffe830f-e049-4c53-a022-7ffc271bafb3n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk 

Re: [Maya-Python] Pyside2/Qt : Image as button with hover state

2022-06-24 Thread Justin Israel
On Sat, Jun 25, 2022 at 4:12 PM johancc  wrote:

> Q: How to add the hover state to this button I have (as an image)? I need
> it to have the "hand icon" when hovering and also some sort of overlay like
> a darkening/lighting effect. Is it possible with my current code? I am
> using pyside/qt inside a DCC application, in this case Autodesk Maya 2022.
> Thank you.
>
> from PySide2.QtWidgets import QApplication, QPushButton
> from PySide2.QtGui import QPixmap, QIcon
> from PySide2.QtCore import QSize
>
> def clicked():
> print("Button clicked!")
>
> window_wid = QtWidgets.QWidget()
> vlayout_wid = QtWidgets.QVBoxLayout()
>
>
> # Set Push Button
> button = QPushButton()
>
> button.setMaximumSize(200,100)
>
> vlayout_wid.addWidget(button)
>
> # Set image in Push Button
> pixmap = QPixmap("my_image.jpg")
> button_icon = QIcon(pixmap)
> button.setIcon(button_icon)
> button.setIconSize(QSize(200,100))
>
> #button.show()
> button.clicked.connect(clicked)
>
> window_wid.setLayout(vlayout_wid)
> window_wid.show()
>
> [image: qt.png]
>

QIcon has an "active" mode state but the widget has to support it and it
seems QPushButton does not use the active state of the QIcon during hover.
You could use a custom stylesheet, but that has the effect of needing to be
fully styled or your button looks weird.

So a pretty easy solution is to just have a custom button class, where you
have full control over what to do when hover starts and stops:

class MyPushButton(QPushButton):

def __init__(self, *a, **kw):
super(MyPushButton, self).__init__(*a, **kw)
self._icon_normal = QIcon(QPixmap("my_image.jpg"))
self._icon_over = QIcon(QPixmap("my_image_over.jpg"))

def enterEvent(self, event):
self.setIcon(self._icon_over)
return super(MyPushButton, self).enterEvent(event)

def leaveEvent(self, event):
self.setIcon(self._icon_normal)
return super(MyPushButton, self).enterEvent(event)


You can do any other settings you want in addition to changing the icon.

Justin


> --
> 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/28a6b738-6028-4504-b057-6c526bc37da9n%40googlegroups.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/CAPGFgA0XOa1jdNdBzD9hqc4tpcbd6q3XZZDYq8A5qj3HsEcBvw%40mail.gmail.com.


Re: [Maya-Python] Help with Translate into Maya Tool

2022-06-02 Thread Justin Israel
Hi Daniel,

Thanks for providing the example code. Maybe it would help to also explain
what the outcome was in your current implementation, and what you expected?

Justin


On Thu, Jun 2, 2022 at 7:54 AM Daniel LeBreton 
wrote:

> Hi everyone! I'm trying to make a general layout tool for maya scripting
> course, I have the interface generally down, but I am having trouble adding
> a translate function to the floatFieldGrp for location. If anyone could
> help me sort it out, it would be greatly appreciated! Thanks!
>
> Here is the script so far:
>
> import maya.cmds as cmds
> import random
>#Creates the board to layout buildings, might put into UI later if I
> have time.
> cmds.polyPlane(width=100, height = 100, name = 'Ground')
>#Define class, put DL to avoid confusion between other potential window
> items.
> class DL_Window (object):
> #creates method to construct window, call function "self".
> def __init__(self):
>
> #Creating some attributes, like name, title, and size of the
> window as it will initially appear on the screen.
> self.window = 'DL_Window'
> self.title = "City Layout Creator"
> self.size = (400,400)
> # will close old window if it's still open
> if cmds.window(self.window, exists = True):
> cmds.deleteUI (self.window, window= True)
> #creates the new window
> self.window = cmds.window (self.window, title=self.title,
> widthHeight=self.size)
>
> #adjusts all UI to fit in the column
> cmds.columnLayout(adjustableColumn = True)
>
> #Create a title, and seperator from the name of the UI, and the
> function of the UI
> cmds.text(self.title)
> cmds.separator(height = 20, width = 100)
>
> #Some customizable widgets that can adjust name, location of
> building on map, subdivisions for extruding windows or doors, and lastly
> the button.
> self.cubeName = cmds.textFieldGrp( label = 'Building Name:')
> self.cubeSize = cmds.floatFieldGrp ( numberOfFields = 3, label =
> 'size:', value1=1, value2=1,value3=1 )
> self.cubeLocation = cmds.floatFieldGrp (numberOfFields = 3, label
> = 'location:', value1=1,value2=1,value3=1)
> self.cubeSubdivs =cmds.intSliderGrp(field=True, label = 'subdivs',
> minValue=1,maxValue=20, value=1)
> self.cubeCreateButton = cmds.button(label= 'Create Building',
> command=self.createBuilding)
>
> #Repeat Steps for Trees
> cmds.separator(height = 20, width = 100)
> cmds.text("Tree Generator")
> cmds.separator(height = 20, width = 100)
>
> self.treeName = cmds.textFieldGrp( label = 'Tree Name:')
> self.treeSize = cmds.floatFieldGrp ( numberOfFields = 3, label =
> 'size:', value1=1, value2=1,value3=1 )
> self.treeLocation = cmds.floatFieldGrp (numberOfFields = 3, label
> = 'location:', value1=1,value2=1,value3=1)
> self.treeSubdivs =cmds.intSliderGrp(field=True, label = 'subdivs',
> minValue=1,maxValue=20, value=1)
> self.cubeCreateButton = cmds.button(label= 'Create Tree',
> command=self.createBuilding)
>
>
> # Displays the window in Maya
> cmds.showWindow()
>
> def createBuilding (self, *args):
> print ("A button has been pressed")
>
> name = cmds.textFieldGrp(self.cubeName, query = True, text=True)
>
> width = cmds.floatFieldGrp (self.cubeSize, query=True, value1=True)
> height = cmds.floatFieldGrp (self.cubeSize, query=True,
> value2=True)
> depth = cmds.floatFieldGrp (self.cubeSize, query=True, value3=True)
>
>
> translateX = cmds.floatFieldGrp (self.cubeLocation, query = True,
> value1=True)
> translateY = cmds.floatFieldGrp (self.cubeLocation, query = True,
> value2=True)
> translateZ = cmds.floatFieldGrp (self.cubeLocation, query = True,
> value3=True)
>
> subdivs = cmds.intSliderGrp (self.cubeSubdivs, query=True,
> value=True)
>
> cmds.polyCube(name = name, width = width, height = height, depth =
> depth, translateX=translateX, translateY=translateY,
> translateZ=translateZ,  subdivisionsWidth = subdivs,subdivisionsHeight =
> subdivs,subdivisionsDepth = subdivs)
>
>
>  #Calling the class here
> myWindow = DL_Window()
>
> --
> 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/f634ecdb-043d-4a16-9693-6aca59018d78n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from 

Re: [Maya-Python] QTreeView & Model help. Drag & Drop inside both view and model

2022-05-26 Thread Justin Israel
On Fri, May 27, 2022 at 8:36 AM Benjam901  wrote:

> Ok, after you pointed me towards super I looked into it and stumbled
> across all the right solutions to do this.
>
> Inside my treemodel I am adding an additional custom mime data type and
> checking for that inside the view. If its custom I call super and if not I
> call the normal event accept and run the other code I need to drop in a
> directory from the system :)
>

Ya that's right. Calling the super() dropEvent method allows the original
superclass logic to run, if you haven't manually handled the drop logic
yourself.
I was looking for example links to share when I saw you just figured it
out. So that saves me time :-)


> On Thursday, 26 May 2022 at 21:24:12 UTC+2 Benjam901 wrote:
>
>> I was wondering if that might be the way to go also, but if both
>> instances of the drop event require that a file url be present then both
>> would need to call accept() right?
>>
>> Do you have any examples of this behaviour you could point me toward?
>> Also, I am not 100% clear on the super() event handler
>>
>> // Ben
>>
>> On Thursday, 26 May 2022 at 21:14:59 UTC+2 justin...@gmail.com wrote:
>>
>>>
>>>
>>> On Fri, 27 May 2022, 3:54 am Benjam901,  wrote:
>>>


 When I reimplement the dragEnterEvent and dropEvent in the view itself,
 the drag and drop functionality within the model no longer works... files
 are not moved, nothing happens other than the print statements I have
 inside the dropEvent in the view class.

 Is this normal behaviour for the view to override the drop code inside
 my model? Or should I let the view handle the drop? If the latter, then I
 would need to find the index of the item dropped to from the view.

 Here is the shortnened code for my tree model:
 https://gist.github.com/ben-hearn-sb/a669a25a1f9513207ba3af3f9b801362

>>>
>>> Hey Ben. It's because your overrides for the event handlers are always
>>> calling accept() on the event. You need to check the mimetype and if you
>>> decide its not something you are going to handle then don't call accept so
>>> that the event can propagate. But you should probably also call the super()
>>> event handler as well if you want the original view handler code to be able
>>> to try default drop behavior.
>>>
>>>
>>>

 If anyone can help me with this I would be very grateful :)

 Peace!

 Ben

 --
 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_m...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/59cc4287-d876-4774-9116-14a9cc2185bcn%40googlegroups.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/4f1e1698-b662-4f6a-8068-9784a51a7cb7n%40googlegroups.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/CAPGFgA23zNkosOzg2fg_imutYjdJm2MSp7TSpDjNb0w9E5U8gw%40mail.gmail.com.


Re: [Maya-Python] QTreeView & Model help. Drag & Drop inside both view and model

2022-05-26 Thread Justin Israel
On Fri, 27 May 2022, 3:54 am Benjam901,  wrote:

>
>
> When I reimplement the dragEnterEvent and dropEvent in the view itself,
> the drag and drop functionality within the model no longer works... files
> are not moved, nothing happens other than the print statements I have
> inside the dropEvent in the view class.
>
> Is this normal behaviour for the view to override the drop code inside my
> model? Or should I let the view handle the drop? If the latter, then I
> would need to find the index of the item dropped to from the view.
>
> Here is the shortnened code for my tree model:
> https://gist.github.com/ben-hearn-sb/a669a25a1f9513207ba3af3f9b801362
>

Hey Ben. It's because your overrides for the event handlers are always
calling accept() on the event. You need to check the mimetype and if you
decide its not something you are going to handle then don't call accept so
that the event can propagate. But you should probably also call the super()
event handler as well if you want the original view handler code to be able
to try default drop behavior.



>
> If anyone can help me with this I would be very grateful :)
>
> Peace!
>
> Ben
>
> --
> 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/59cc4287-d876-4774-9116-14a9cc2185bcn%40googlegroups.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/CAPGFgA0091k0JdfHAPfOHyV1gVEfK1sfjp1PuZo3V6v72TCLiA%40mail.gmail.com.


Re: [Maya-Python] casting MPlugArray into a list don't hold the MPlugs in memory?

2022-01-19 Thread Justin Israel
On Thu, 20 Jan 2022, 6:35 am Rudi Hammad,  wrote:

> hello,
>
> I though about sharing someting strange that occured to me. I had a method
> that contained
> MPlug.destinations() which as an art requieres an MPlugArray(). For some
> reason, probably because I was in a hurry and I didn't thought about it, I
> casted all the MPlugs from MPlug.destinations() into a python list. Let's
> call it foo=list().
> And that's where I started getting crashes. For instance, if I did
> something like
> foo[0], which is supposed to hold an MPlug, maya return the MPlug okey,
> but if I did foo[0].isNull() it returned True and then crashed.
>
> Whereas if you don't use a python list,  and query directly the
> MPlugArray  (e.g, myMPlugArr[0].isNull) it returns False and everything is
> ok.
>
> So my question more out curiosity than anything else. I know python lists
> are mutable objects, but not sure how or if that could be related.
>
> Cheers,
> R
>

If foo[0] gives you an object, but foo[0].isNull() crashes, then it could
be a bug in the C++ wrapper and how it reference counts. Does it crash if
you first save the object in a variable?
p = foo[0]
p.isNull()
I think either way it may be a bug in the wrappers around the C++ memory
and the reference counting.


> --
> 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/62002c0d-0c72-43d0-9bd8-5e845d3d43b2n%40googlegroups.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/CAPGFgA3coz%2BvxPQWjH2extc-Lii_TO38kKXUEjnarMkO_Lnz4g%40mail.gmail.com.


Re: [Maya-Python] Compiling plugins in Visual Studio for multiple maya versions and platforms

2022-01-01 Thread Justin Israel
On Sun, Jan 2, 2022 at 7:10 AM Rudi Hammad  wrote:

> So I followed Chad Vernom's cmake tutorials on youtube. First I wrote a
> everything as he did, and when it came do the build from the command promp
> I got an error related to maya path or something, so I thought
> F###k that, I'll just copy his repo from github, since I barely understand
> CMake syntax and I might have done plenty of errors.
> Anyway, after copying his repo and rebuilding I get the error
>
> -
>
> Could not find a package configuration file provided by "Maya" with any of
>   the following names:
>
> MayaConfig.cmake
> maya-config.cmake
>
>   Add the installation prefix of "Maya" to CMAKE_PREFIX_PATH or set
>   "Maya_DIR" to a directory containing one of the above files.  If "Maya"
>   provides a separate development package or SDK, be sure it has been
>   installed.
>
> -
>
> Since I am not familiar at all with CMake I have no idea what to do with
> this. According to the error it says " If "Maya"  provides a separate
> development package or SDK, be sure it has been installed. "
> So should I install maya's devkit separetly or somehing? I so, how to
> "install it"? Should I copy paste all folder of "dekitBase" in maya? Do I
> even need the SDK?
>

Hey Rudi, Since I don't have a WIndows Maya development environment, I can
only try and guess at the solutions. But it might help you in the meantime,
until another Windows user chimes in.

This error looks like it is failing to find the FineMaya.cmake extension
module that was provided by Chad's repo. The idea here with cmake is that
it is a build system generator, which supports extension modules to do
reusable custom tasks, and in this case, to find Maya's development env.
The README in Chad's project is suggesting a way to structure your own
project and the contents of the CMakeLists files, and to ensure that you
have the FindMaya.cmake file in the right spot.

https://github.com/chadmv/cgcmake/blob/master/README.md?plain=1#L34
These lines in the root CMakeLists are setting the tools dir to be relative
to the current source directory processed by cmake (./cgcmake/modules),
so it assumes you have this existing path:
./cgcmake/modules/FindMaya.cmake
Can you confirm that you have this module file in the correct location in
your own project?

It will load the FindMaya.cmake because of this:
https://github.com/chadmv/cgcmake/blob/master/README.md?plain=1#L48

Once you get past that part of cmake finding the module, then it will try
to determine the location of your Maya installation:
https://github.com/chadmv/cgcmake/blob/master/modules/FindMaya.cmake#L54

And you can see what aspects of the Maya installation it expects to find
(includes and devkit):
https://github.com/chadmv/cgcmake/blob/master/modules/FindMaya.cmake#L86

Hope that unblocks you.


>
>
> Anyway, I am completly lost here.
>
> Thanks,
> R
>
>
> El jueves, 14 de octubre de 2021 a las 23:01:30 UTC+2, Mahmoodreza Aarabi
> escribió:
>
>> Good point Chad
>>
>> On Thu, Oct 14, 2021 at 1:44 PM Chad Vernon  wrote:
>>
>>> I've used Jenkins CI in the past to build plugins for multiple versions
>>> of Maya on all 3 platforms. You have to have access to all three platforms
>>> on the same network. I used CMake to set up the build environment for each
>>> platform/maya version.
>>>
>>> Also while you can often use a different Visual Studio version than what
>>> Maya was compiled with, you may sometimes see irregularities, like
>>> difficulties running through a debugger.
>>>
>>> On Thursday, October 14, 2021 at 9:31:40 AM UTC-7 Rudi Hammad wrote:
>>>
 found this on youtube by chad vernom!
 https://www.youtube.com/watch?v=2mUOt_F2ywo=0s


 El jueves, 14 de octubre de 2021 a las 11:38:17 UTC+2, Rudi Hammad
 escribió:

> hello,
>
> Not sure if I am understanding correctly. I only know how to setup VS
> for one maya version. What I do is a set the directories in the properties
> the the corresponding maya verstion path.
> So what I would do to compile for each is manually change every time
> the path, which I am sure is not how to do it.
> I would like to get this right first and then I'll check the replies
> about other platforms.
>
> R
>
> El miércoles, 13 de octubre de 2021 a las 23:15:13 UTC+2, Marcus
> Ottosson escribió:
>
>> Yes, that's not an issue. The version of Maya you build for is
>> determined by the SDK you use, e.g. the Maya 2020 SDK for Maya 2020
>> plug-ins. The only thing to bear in mind is that the compiler version 
>> needs
>> to match the Maya compiler version, so VS 2015 or 2019 for Maya 
>> 2018-2022.
>> You can't build for Mac with VS.
>>
>> On Sun, 10 Oct 2021 at 

Re: [Maya-Python] Creating an .exe installer.

2021-12-24 Thread Justin Israel
On Sat, 25 Dec 2021, 2:48 pm Rudi Hammad,  wrote:

> Fantastic, thanks. I thought something must already exist. It seems that
> is for windows only. What about mac or linux. Any cross platform installer?
>

Maybe search for a dmg installer for macos and do some snaps/deb/rpm
approach for Linux?

Because usually clients have windows or mac. Haven't found som much on
> linux.
>
> On Saturday, December 25, 2021 at 1:22:08 AM UTC+1 justin...@gmail.com
> wrote:
>
>>
>>
>> On Sat, 25 Dec 2021, 1:12 pm Rudi Hammad, 
>> wrote:
>>
>>> Hi,
>>>
>>> I was wondering how to do a .exe installer that display a window as we
>>> see usually in
>>> any software, meaning, you get a UI displaying a first window with a
>>> greeting or whatever,
>>> then you have a button with next that brings you to another window where
>>> you can display
>>> an agreement text, or a button where you can set the instalation path,
>>> etc...
>>>
>>> My guess is that you have to create that UI and the widgets your self,
>>> but before doing it I thought that maybe there is already an existing
>>> python framework that does all that since we see that kind of instalation
>>> setup regulary.
>>>
>>
>> Probably avoid writing your own custom ui solution as a first choice.
>> There are existing tools for creating windows installers. Maybe start here:
>>
>>
>> https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/authoring-a-windows-installer-package?view=vs-2022#setup-tools
>>
>>
>>>
>>> Cheers, and merry christmas
>>> R
>>>
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/34d0aee4-aab5-4e65-ba1a-20e0b174f39dn%40googlegroups.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/7decd941-ac18-4446-bf38-da8fb6ac1586n%40googlegroups.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/CAPGFgA1HcbDm0hAF2WtZuz5O1bOn3e2PSMDy1XuGbdonm-e%2BJg%40mail.gmail.com.


Re: [Maya-Python] Creating an .exe installer.

2021-12-24 Thread Justin Israel
On Sat, 25 Dec 2021, 1:12 pm Rudi Hammad,  wrote:

> Hi,
>
> I was wondering how to do a .exe installer that display a window as we see
> usually in
> any software, meaning, you get a UI displaying a first window with a
> greeting or whatever,
> then you have a button with next that brings you to another window where
> you can display
> an agreement text, or a button where you can set the instalation path,
> etc...
>
> My guess is that you have to create that UI and the widgets your self, but
> before doing it I thought that maybe there is already an existing python
> framework that does all that since we see that kind of instalation setup
> regulary.
>

Probably avoid writing your own custom ui solution as a first choice. There
are existing tools for creating windows installers. Maybe start here:

https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/authoring-a-windows-installer-package?view=vs-2022#setup-tools


>
> Cheers, and merry christmas
> R
>
>
> --
> 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/34d0aee4-aab5-4e65-ba1a-20e0b174f39dn%40googlegroups.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/CAPGFgA3%3DfUhRQx7qKoicHXxQ2XY0Q%3DU_94Ef16vkathzy7N-ng%40mail.gmail.com.


Re: [Maya-Python] Cloud Native Studios discord invite

2021-12-09 Thread Justin Israel
On Fri, Dec 10, 2021 at 6:43 AM Marcus Ottosson 
wrote:

> Cheers, mate. Is there any Maya groups I can join?
>
> Here’s one that has both Maya and Python channels.
>
>- https://discord.gg/8KRhtePS9m (called “Ask a Rigger”)
>
> Thanks to Remi for letting me share an invite link (that does no expire :)
>
I have the option to share one that doesn't expire, for the Cloud Native
server. But I was concerned that it would just be picked up randomly, later
in the archive, by spammers. So I was hoping those that are active readers
of the list would see the link within 7 days. Maybe I was being overly
cautious.


> On Wednesday, 8 December 2021 at 21:18:37 UTC Justin Israel wrote:
>
>>
>>
>> On Thu, Dec 9, 2021 at 10:16 AM Marty  wrote:
>>
>>> Cheers, mate. Is there any Maya groups I can join?
>>>
>>
>> I'm not aware of any. Only started using Discord for the first time as a
>> result of Siggraph, where discussions branched out and eventually became a
>> new Discord server specific to Cloud Native discussions.
>>
>>
>>>
>>> On Wednesday, December 8, 2021 at 5:13:22 PM UTC+13 justin...@gmail.com
>>> wrote:
>>>
>>>> On Wed, Dec 8, 2021 at 5:08 PM Hans Harris  wrote:
>>>>
>>>>> Hey Justin,
>>>>> Could you post a new invitation for that discord that one is not
>>>>> anymore valid?
>>>>> Cheers,
>>>>>
>>>> Hans
>>>>>
>>>>
>>>> Sure!  https://discord.gg/6h82tztY
>>>>
>>>>
>>>>>
>>>>> On Friday, November 5, 2021 at 3:15:33 PM UTC+13 justin...@gmail.com
>>>>> wrote:
>>>>>
>>>>>> On Fri, Nov 5, 2021 at 12:03 PM Colas Fiszman 
>>>>>> wrote:
>>>>>>
>>>>>>> Hey Justin,
>>>>>>> Could you post a new invitation for that discord that one is not
>>>>>>> anymore valid?
>>>>>>> Cheers,
>>>>>>> Colas
>>>>>>>
>>>>>>
>>>>>> Sure. Here is a new 7 day invite: https://discord.gg/q8Be7geF
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Le sam. 16 oct. 2021 à 22:38, Justin Israel  a
>>>>>>> écrit :
>>>>>>>
>>>>>>>> Hi Everyone,
>>>>>>>>
>>>>>>>> If you didn't manage to make it to Siggraph this year, or you did
>>>>>>>> but didn't make it to the Birds of a Feather cloud/pipeline chats, you
>>>>>>>> might have missed that a new discord server was created.
>>>>>>>>
>>>>>>>> Cloud Native Studios
>>>>>>>>
>>>>>>>> Focuses on topics related to studio pipelines and moving towards
>>>>>>>> cloud-based workflows. Lot of topic channels on there and good
>>>>>>>> representation from large and small studios so far. Example channels
>>>>>>>> include: containers, render farm, remote working, databases, careers...
>>>>>>>>
>>>>>>>> Here is an invite that is good for 7 days:
>>>>>>>> https://discord.gg/wn438X5r
>>>>>>>>
>>>>>>>> If you join up, make sure to edit your server nickname to "Your
>>>>>>>> full name (studio)" as it is a server requirement.
>>>>>>>>
>>>>>>>> Enjoy!
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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_m...@googlegroups.com.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com
>>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com?utm_medium=email_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> --
>>>>>>> You received this messa

Re: [Maya-Python] Cloud Native Studios discord invite

2021-12-08 Thread Justin Israel
On Thu, Dec 9, 2021 at 10:16 AM Marty  wrote:

> Cheers, mate. Is there any Maya groups I can join?
>

I'm not aware of any. Only started using Discord for the first time as a
result of Siggraph, where discussions branched out and eventually became a
new Discord server specific to Cloud Native discussions.


>
> On Wednesday, December 8, 2021 at 5:13:22 PM UTC+13 justin...@gmail.com
> wrote:
>
>> On Wed, Dec 8, 2021 at 5:08 PM Hans Harris  wrote:
>>
>>> Hey Justin,
>>> Could you post a new invitation for that discord that one is not
>>> anymore valid?
>>> Cheers,
>>>
>> Hans
>>>
>>
>> Sure!  https://discord.gg/6h82tztY
>>
>>
>>>
>>> On Friday, November 5, 2021 at 3:15:33 PM UTC+13 justin...@gmail.com
>>> wrote:
>>>
>>>> On Fri, Nov 5, 2021 at 12:03 PM Colas Fiszman 
>>>> wrote:
>>>>
>>>>> Hey Justin,
>>>>> Could you post a new invitation for that discord that one is not
>>>>> anymore valid?
>>>>> Cheers,
>>>>> Colas
>>>>>
>>>>
>>>> Sure. Here is a new 7 day invite: https://discord.gg/q8Be7geF
>>>>
>>>>
>>>>>
>>>>> Le sam. 16 oct. 2021 à 22:38, Justin Israel  a
>>>>> écrit :
>>>>>
>>>>>> Hi Everyone,
>>>>>>
>>>>>> If you didn't manage to make it to Siggraph this year, or you did but
>>>>>> didn't make it to the Birds of a Feather cloud/pipeline chats, you might
>>>>>> have missed that a new discord server was created.
>>>>>>
>>>>>> Cloud Native Studios
>>>>>>
>>>>>> Focuses on topics related to studio pipelines and moving towards
>>>>>> cloud-based workflows. Lot of topic channels on there and good
>>>>>> representation from large and small studios so far. Example channels
>>>>>> include: containers, render farm, remote working, databases, careers...
>>>>>>
>>>>>> Here is an invite that is good for 7 days:
>>>>>> https://discord.gg/wn438X5r
>>>>>>
>>>>>> If you join up, make sure to edit your server nickname to "Your full
>>>>>> name (studio)" as it is a server requirement.
>>>>>>
>>>>>> Enjoy!
>>>>>>
>>>>>> --
>>>>>> 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_m...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com?utm_medium=email_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_m...@googlegroups.com.
>>>>>
>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com?utm_medium=email_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_m...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/355115bf-f92e-4e56-898a-3bc07410539fn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/355115bf-f92e-4e56-898a-3bc07410539fn%40googlegroups.com?utm_medium=email_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/f8e08274-78a3-4134-91d2-9b68f99eea95n%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/f8e08274-78a3-4134-91d2-9b68f99eea95n%40googlegroups.com?utm_medium=email_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/CAPGFgA3w_kmYL8DCq4%3DYd23rVrsT0ZX48whiwDBy4%2Bf3YzCZNw%40mail.gmail.com.


Re: [Maya-Python] Cloud Native Studios discord invite

2021-12-07 Thread Justin Israel
On Wed, Dec 8, 2021 at 5:08 PM Hans Harris  wrote:

> Hey Justin,
> Could you post a new invitation for that discord that one is not
> anymore valid?
> Cheers,
> Hans
>

Sure!  https://discord.gg/6h82tztY


>
> On Friday, November 5, 2021 at 3:15:33 PM UTC+13 justin...@gmail.com
> wrote:
>
>> On Fri, Nov 5, 2021 at 12:03 PM Colas Fiszman 
>> wrote:
>>
>>> Hey Justin,
>>> Could you post a new invitation for that discord that one is not
>>> anymore valid?
>>> Cheers,
>>> Colas
>>>
>>
>> Sure. Here is a new 7 day invite: https://discord.gg/q8Be7geF
>>
>>
>>>
>>> Le sam. 16 oct. 2021 à 22:38, Justin Israel  a
>>> écrit :
>>>
>>>> Hi Everyone,
>>>>
>>>> If you didn't manage to make it to Siggraph this year, or you did but
>>>> didn't make it to the Birds of a Feather cloud/pipeline chats, you might
>>>> have missed that a new discord server was created.
>>>>
>>>> Cloud Native Studios
>>>>
>>>> Focuses on topics related to studio pipelines and moving towards
>>>> cloud-based workflows. Lot of topic channels on there and good
>>>> representation from large and small studios so far. Example channels
>>>> include: containers, render farm, remote working, databases, careers...
>>>>
>>>> Here is an invite that is good for 7 days:
>>>> https://discord.gg/wn438X5r
>>>>
>>>> If you join up, make sure to edit your server nickname to "Your full
>>>> name (studio)" as it is a server requirement.
>>>>
>>>> Enjoy!
>>>>
>>>> --
>>>> 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_m...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com?utm_medium=email_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_m...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com?utm_medium=email_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/355115bf-f92e-4e56-898a-3bc07410539fn%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/355115bf-f92e-4e56-898a-3bc07410539fn%40googlegroups.com?utm_medium=email_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/CAPGFgA3mq5x5y0RhzDZzAJWen0Xz4xCHr8Gb8-QBmA9XW0BG5Q%40mail.gmail.com.


Re: [Maya-Python] System running scripts from two different Maya and Houdini interpreters

2021-11-19 Thread Justin Israel
On Sat, 20 Nov 2021, 8:33 am Totally Zen,  wrote:

> Sorry for the delay, I've been very busy !!!
>
> I need to work externally with Maya and Houdini at the same time.
>

Then you will have to arrange to start a python interpreter with a
compatible version of python to both Maya and houdini, and to have access
to both bundled python environments. Read the mayapy and houdini wrapper
scripts for hints.

Otherwise you can try approaching this using subprocess, and to start
either mayapy or hython and then do operations in the other one by starting
a child process. Or start a normal python interpreter and run both Maya and
houdini child processes.


> Em quarta-feira, 10 de novembro de 2021 às 16:50:06 UTC-3,
> justin...@gmail.com escreveu:
>
>> On Thu, Nov 11, 2021 at 7:25 AM Totally Zen  wrote:
>>
>>> Okay, but I'm still aimless, lol
>>> what I have and I don't know if something answers what it says would be
>>> the poath configured for Maya and the other for Houdini.
>>>
>>
>> I'm not sure how to provide more help without better understanding your
>> situation. First off, are you on windows or linux? I don't really know what
>> to suggest as the steps for windows, so someone else might need to chime
>> in. But if you are on linux, you can cat the contents of mayapy and hython
>> and see the way they set up the environment before starting the actual maya
>> or houdini process.
>>
>> Are you trying to run a script from within a Maya or Houdini GUI? Or are
>> you trying to write a command-line script that can load maya and houdini at
>> the same time? If you are trying to run this script within Maya or Houdini
>> GUI, then its going to be more difficult since you need to control the
>> environment before the application starts, to have access to the other
>> application import paths, or you have to add them to your sys.path.
>>
>> Either way, this sounds like it might be a bit complex to describe in
>> steps for you.
>>
>>
>>>
>>> :(
>>> Em quarta-feira, 10 de novembro de 2021 às 14:12:25 UTC-3,
>>> justin...@gmail.com escreveu:
>>>
 I've never tried it, but given the right settings I am guessing it
 should be possible. The key would be to have a compatible python
 major/minor version for both the Maya and Houdini versions in the same env.
 Usually you would bootstrap a Maya process with mayapy, or a houdini
 process with hython. Those are usually wrapper scripts that set environment
 variables to point at the python distribution that comes with that version
 of the dcc. You can set the environment externally in a way where you can
 just start a normal python interpreter and import Maya, as long as it is
 the compatible python version.
 So if you bootstrap a compatible combination of mayapy and hython, you
 might be able to import both of their core libraries.

 On Thu, 11 Nov 2021, 4:25 am Totally Zen,  wrote:

> Hi guys, let me see if I can explain it in an easy way, without
> generating more doubts about what I want.
>
> Can I run Maya and Houdini scripts in the same process?
>
> Example... I'll just be a code in PYTHON that will need the maya
> interpreter for the pymel and hpython code of the houdini...
>
> Can I have these two or is there no such possibility?
>
> --
> 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_m...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/c7179212-45b6-4d11-ac56-fec98e67fa31n%40googlegroups.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_m...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/c0314e9b-9b0b-472b-82fd-5fc5bfaeba53n%40googlegroups.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/9631c354-b551-4e5d-a8a7-b2ea66eccf23n%40googlegroups.com
> 

Re: [Maya-Python] Pyside dynamically creating widgets and attaching signal isse

2021-11-14 Thread Justin Israel
On Mon, Nov 15, 2021 at 8:44 AM Rudi Hammad  wrote:

> Amazing, thanks for the explanation.
> I've used wrappers before in other contexts but not partial.  Didn't found
> that issue until now.
> Nothing much to add! that solved it. Thank you
>

Welcome!

Also, I should point out that I have seen cases in either pyqt or pyside
where using a partial() or local scope function wrapper could lead to a
memory leak on the object with the signal, depending on how objects are
parented and deleted. This can happen because python (I think) won't be
able to automatically disconnect the signal if it doesnt see that the
object owning the slot has been garbage collected. When you use a partial()
or a local wrapper, its a branch new object. So switching to always using
methods bound to your object seems to work better
(self._printFooHandler(self.printFoo, n))
Not saying it happens all the time, but I have seen it before.


>
> El domingo, 14 de noviembre de 2021 a las 20:21:29 UTC+1,
> justin...@gmail.com escribió:
>
>> On Mon, Nov 15, 2021 at 7:15 AM Rudi Hammad  wrote:
>>
>>> Hello,
>>>
>>> I wrote this simple ui to ilustrate the issue. As the title says I am
>>> creating dynamically
>>> some widgets and attaching a signal. In this case 4 buttons that when
>>> clicked, print their name.
>>> The problem if you run the code is that all buttons are printing the
>>> same letter 'D', which is the last signal to be set.
>>>
>>> dynamic widget creation 
>>>
>>> Any ideas how to create dynamic signals that will be attached to the
>>> corresponding widget?
>>>
>>
>> Hey there. So this is caused by the fact that a python lambda does not
>> perform a full closure over the scoped variable, which leads to bugs like
>> this when the locally scope variable (n) is changing over the course of the
>> loop. Each lambda you are passing as a slot function has a reference to
>> that scope, but will evaluate the last value of the variable n.
>>
>> (note: dont do the following)
>> The safer way to express the lambda that properly captures the variable
>> value at that time is something like this double-lambda:
>>
>> fn = lambda val: lambda: self.fooPrint(n)
>> btn.clicked.connect(fn(n))
>>
>>
>> This directly captures the current value of your loop variable and
>> returns a new lambda with a closure over that value.
>>
>> Because this is such a fragile mechanism, PEP advises against using
>> anonymous lambdas in the first place:
>> https://www.flake8rules.com/rules/E731.html
>>
>> So what you could do instead is wrap local def functions (there are
>> multiple ways to do this, but here is one way):
>>
>> for n in 'ABCD':
>> def wrap(val=n, *args):
>> self.fooPrint(val)
>> btn.clicked.connect(wrap)
>>
>>
>> And this is pretty much what functools.partial() is for:
>>
>> from functools import partial
>> for n in 'ABCD':
>> btn.clicked.connect(partial(self.fooPrint, n))
>>
>>
>>
>>
>>> thanks
>>>
>>> R
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/eeb1960d-1e46-43d0-a0d9-1107f695a859n%40googlegroups.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/919b3797-15f2-4dd9-9769-9bcdd55137c2n%40googlegroups.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/CAPGFgA0DwBjPb_A3qzeyrFp95Wxs_fUWEw9-C%3DOJg2fYd7caRA%40mail.gmail.com.


Re: [Maya-Python] Pyside dynamically creating widgets and attaching signal isse

2021-11-14 Thread Justin Israel
On Mon, Nov 15, 2021 at 7:15 AM Rudi Hammad  wrote:

> Hello,
>
> I wrote this simple ui to ilustrate the issue. As the title says I am
> creating dynamically
> some widgets and attaching a signal. In this case 4 buttons that when
> clicked, print their name.
> The problem if you run the code is that all buttons are printing the same
> letter 'D', which is the last signal to be set.
>
> dynamic widget creation 
>
> Any ideas how to create dynamic signals that will be attached to the
> corresponding widget?
>

Hey there. So this is caused by the fact that a python lambda does not
perform a full closure over the scoped variable, which leads to bugs like
this when the locally scope variable (n) is changing over the course of the
loop. Each lambda you are passing as a slot function has a reference to
that scope, but will evaluate the last value of the variable n.

(note: dont do the following)
The safer way to express the lambda that properly captures the variable
value at that time is something like this double-lambda:

fn = lambda val: lambda: self.fooPrint(n)
btn.clicked.connect(fn(n))


This directly captures the current value of your loop variable and returns
a new lambda with a closure over that value.

Because this is such a fragile mechanism, PEP advises against using
anonymous lambdas in the first place:
https://www.flake8rules.com/rules/E731.html

So what you could do instead is wrap local def functions (there are
multiple ways to do this, but here is one way):

for n in 'ABCD':
def wrap(val=n, *args):
self.fooPrint(val)
btn.clicked.connect(wrap)


And this is pretty much what functools.partial() is for:

from functools import partial
for n in 'ABCD':
btn.clicked.connect(partial(self.fooPrint, n))




> thanks
>
> R
>
> --
> 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/eeb1960d-1e46-43d0-a0d9-1107f695a859n%40googlegroups.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/CAPGFgA1gCSMPVmNnPha1J%2BKTB8G44Ho_NyR2y5J1zn%2BG8JpugA%40mail.gmail.com.


Re: [Maya-Python] System running scripts from two different Maya and Houdini interpreters

2021-11-10 Thread Justin Israel
On Thu, 11 Nov 2021, 8:53 am Kenneth Ibrahim,  wrote:

> Justin,
>
> You're now a Unity employee? ;-)
>
> Big news!!
>

This very second, not yet. But effectively yes, within the next month or so
;-)


> On Wed, Nov 10, 2021 at 11:50 AM Justin Israel 
> wrote:
>
>>
>>
>> On Thu, Nov 11, 2021 at 7:25 AM Totally Zen  wrote:
>>
>>> Okay, but I'm still aimless, lol
>>> what I have and I don't know if something answers what it says would be
>>> the poath configured for Maya and the other for Houdini.
>>>
>>
>> I'm not sure how to provide more help without better understanding your
>> situation. First off, are you on windows or linux? I don't really know what
>> to suggest as the steps for windows, so someone else might need to chime
>> in. But if you are on linux, you can cat the contents of mayapy and hython
>> and see the way they set up the environment before starting the actual maya
>> or houdini process.
>>
>> Are you trying to run a script from within a Maya or Houdini GUI? Or are
>> you trying to write a command-line script that can load maya and houdini at
>> the same time? If you are trying to run this script within Maya or Houdini
>> GUI, then its going to be more difficult since you need to control the
>> environment before the application starts, to have access to the other
>> application import paths, or you have to add them to your sys.path.
>>
>> Either way, this sounds like it might be a bit complex to describe in
>> steps for you.
>>
>>
>>>
>>> :(
>>> Em quarta-feira, 10 de novembro de 2021 às 14:12:25 UTC-3,
>>> justin...@gmail.com escreveu:
>>>
>>>> I've never tried it, but given the right settings I am guessing it
>>>> should be possible. The key would be to have a compatible python
>>>> major/minor version for both the Maya and Houdini versions in the same env.
>>>> Usually you would bootstrap a Maya process with mayapy, or a houdini
>>>> process with hython. Those are usually wrapper scripts that set environment
>>>> variables to point at the python distribution that comes with that version
>>>> of the dcc. You can set the environment externally in a way where you can
>>>> just start a normal python interpreter and import Maya, as long as it is
>>>> the compatible python version.
>>>> So if you bootstrap a compatible combination of mayapy and hython, you
>>>> might be able to import both of their core libraries.
>>>>
>>>> On Thu, 11 Nov 2021, 4:25 am Totally Zen,  wrote:
>>>>
>>>>> Hi guys, let me see if I can explain it in an easy way, without
>>>>> generating more doubts about what I want.
>>>>>
>>>>> Can I run Maya and Houdini scripts in the same process?
>>>>>
>>>>> Example... I'll just be a code in PYTHON that will need the maya
>>>>> interpreter for the pymel and hpython code of the houdini...
>>>>>
>>>>> Can I have these two or is there no such possibility?
>>>>>
>>>>> --
>>>>> 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_m...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/c7179212-45b6-4d11-ac56-fec98e67fa31n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/c7179212-45b6-4d11-ac56-fec98e67fa31n%40googlegroups.com?utm_medium=email_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/c0314e9b-9b0b-472b-82fd-5fc5bfaeba53n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/c0314e9b-9b0b-472b-82fd-5fc5bfaeba53n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programmi

Re: [Maya-Python] System running scripts from two different Maya and Houdini interpreters

2021-11-10 Thread Justin Israel
On Thu, Nov 11, 2021 at 7:25 AM Totally Zen  wrote:

> Okay, but I'm still aimless, lol
> what I have and I don't know if something answers what it says would be
> the poath configured for Maya and the other for Houdini.
>

I'm not sure how to provide more help without better understanding your
situation. First off, are you on windows or linux? I don't really know what
to suggest as the steps for windows, so someone else might need to chime
in. But if you are on linux, you can cat the contents of mayapy and hython
and see the way they set up the environment before starting the actual maya
or houdini process.

Are you trying to run a script from within a Maya or Houdini GUI? Or are
you trying to write a command-line script that can load maya and houdini at
the same time? If you are trying to run this script within Maya or Houdini
GUI, then its going to be more difficult since you need to control the
environment before the application starts, to have access to the other
application import paths, or you have to add them to your sys.path.

Either way, this sounds like it might be a bit complex to describe in steps
for you.


>
> :(
> Em quarta-feira, 10 de novembro de 2021 às 14:12:25 UTC-3,
> justin...@gmail.com escreveu:
>
>> I've never tried it, but given the right settings I am guessing it should
>> be possible. The key would be to have a compatible python major/minor
>> version for both the Maya and Houdini versions in the same env.
>> Usually you would bootstrap a Maya process with mayapy, or a houdini
>> process with hython. Those are usually wrapper scripts that set environment
>> variables to point at the python distribution that comes with that version
>> of the dcc. You can set the environment externally in a way where you can
>> just start a normal python interpreter and import Maya, as long as it is
>> the compatible python version.
>> So if you bootstrap a compatible combination of mayapy and hython, you
>> might be able to import both of their core libraries.
>>
>> On Thu, 11 Nov 2021, 4:25 am Totally Zen,  wrote:
>>
>>> Hi guys, let me see if I can explain it in an easy way, without
>>> generating more doubts about what I want.
>>>
>>> Can I run Maya and Houdini scripts in the same process?
>>>
>>> Example... I'll just be a code in PYTHON that will need the maya
>>> interpreter for the pymel and hpython code of the houdini...
>>>
>>> Can I have these two or is there no such possibility?
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/c7179212-45b6-4d11-ac56-fec98e67fa31n%40googlegroups.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/c0314e9b-9b0b-472b-82fd-5fc5bfaeba53n%40googlegroups.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/CAPGFgA0GKDZNnGmoGdwGB8z5nY__Eq9K14C%3DxzJKQfkf1EB0%2Bw%40mail.gmail.com.


Re: [Maya-Python] System running scripts from two different Maya and Houdini interpreters

2021-11-10 Thread Justin Israel
I've never tried it, but given the right settings I am guessing it should
be possible. The key would be to have a compatible python major/minor
version for both the Maya and Houdini versions in the same env.
Usually you would bootstrap a Maya process with mayapy, or a houdini
process with hython. Those are usually wrapper scripts that set environment
variables to point at the python distribution that comes with that version
of the dcc. You can set the environment externally in a way where you can
just start a normal python interpreter and import Maya, as long as it is
the compatible python version.
So if you bootstrap a compatible combination of mayapy and hython, you
might be able to import both of their core libraries.

On Thu, 11 Nov 2021, 4:25 am Totally Zen,  wrote:

> Hi guys, let me see if I can explain it in an easy way, without generating
> more doubts about what I want.
>
> Can I run Maya and Houdini scripts in the same process?
>
> Example... I'll just be a code in PYTHON that will need the maya
> interpreter for the pymel and hpython code of the houdini...
>
> Can I have these two or is there no such possibility?
>
> --
> 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/c7179212-45b6-4d11-ac56-fec98e67fa31n%40googlegroups.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/CAPGFgA2JJMYadsLwgSk_7nqTUD9-_DzHcc2kyo8i8aH6NkNu9g%40mail.gmail.com.


Re: [Maya-Python] accessing maya's interpreter globals from another scripts

2021-11-10 Thread Justin Israel
On Thu, 11 Nov 2021, 12:55 am Rudi Hammad,  wrote:

> in other words, get the result in foo.py that you get when you run
> globals() in maya's script editor.
>

You can reference what I am going in the MayaSublime project. I import
__main__ and access __main__.__dict__ for the globals as you would see them
in the script editor

https://github.com/justinfx/MayaSublime/blob/master/MayaSublime.py#L289


> El miércoles, 10 de noviembre de 2021 a las 12:52:29 UTC+1, Rudi Hammad
> escribió:
>
>> of course, in foo.py you get the module's global, and in maya's script
>> editor you see maya's.
>> So I was wondering if you can query maya's globals (or locals) from an
>> other foo.py.
>> I know, it is a strange question.
>>
>> El miércoles, 10 de noviembre de 2021 a las 12:24:52 UTC+1, Marcus
>> Ottosson escribió:
>>
>>> Global variables are.. global, so anything present in `globals()` from
>>> one module is present in another. Are you seeing different results from
>>> `globals()` in `foo.py` versus Maya's interpreter (by which I assume you
>>> mean the Script Editor)?
>>>
>>> On Wed, 10 Nov 2021 at 09:36, Rudi Hammad  wrote:
>>>
 Hello,

 I was wondering if it is possible to get the globals variables running
 in maya but from another script.
 For instance say you have a module foo.py. Can you use get all maya's
 globals as if you were running 'globals()' withing maya's interpreter?

 thx,

 T

 --
 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_m...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/46ad99b5-42d5-40dd-ba99-74b546516426n%40googlegroups.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/5857d0a2-3851-4ae5-b43f-201bfadf9aafn%40googlegroups.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/CAPGFgA0SYGaOoLtUhsqU_sO-bMd09Ug3jMtChdOygqQfMbZZ2g%40mail.gmail.com.


Re: [Maya-Python] Cloud Native Studios discord invite

2021-11-04 Thread Justin Israel
On Fri, Nov 5, 2021 at 12:03 PM Colas Fiszman 
wrote:

> Hey Justin,
> Could you post a new invitation for that discord that one is not
> anymore valid?
> Cheers,
> Colas
>

Sure. Here is a new 7 day invite: https://discord.gg/q8Be7geF


>
> Le sam. 16 oct. 2021 à 22:38, Justin Israel  a
> écrit :
>
>> Hi Everyone,
>>
>> If you didn't manage to make it to Siggraph this year, or you did but
>> didn't make it to the Birds of a Feather cloud/pipeline chats, you might
>> have missed that a new discord server was created.
>>
>> Cloud Native Studios
>>
>> Focuses on topics related to studio pipelines and moving towards
>> cloud-based workflows. Lot of topic channels on there and good
>> representation from large and small studios so far. Example channels
>> include: containers, render farm, remote working, databases, careers...
>>
>> Here is an invite that is good for 7 days:
>> https://discord.gg/wn438X5r
>>
>> If you join up, make sure to edit your server nickname to "Your full name
>> (studio)" as it is a server requirement.
>>
>> Enjoy!
>>
>> --
>> 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/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com?utm_medium=email_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/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CABwp0vNN6K2%3DK5VTeno6iiMsWJ4f24r_OtYSOAwYbSf7%2B__fTw%40mail.gmail.com?utm_medium=email_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/CAPGFgA3BGhMJi1PA6wdwAnMpvifif5C9maywFC1t116QgA3jNw%40mail.gmail.com.


[Maya-Python] Cloud Native Studios discord invite

2021-10-16 Thread Justin Israel
Hi Everyone,

If you didn't manage to make it to Siggraph this year, or you did but
didn't make it to the Birds of a Feather cloud/pipeline chats, you might
have missed that a new discord server was created.

Cloud Native Studios

Focuses on topics related to studio pipelines and moving towards
cloud-based workflows. Lot of topic channels on there and good
representation from large and small studios so far. Example channels
include: containers, render farm, remote working, databases, careers...

Here is an invite that is good for 7 days:
https://discord.gg/wn438X5r

If you join up, make sure to edit your server nickname to "Your full name
(studio)" as it is a server requirement.

Enjoy!

-- 
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/CAPGFgA1__cMga68y%3D7Qrd6AymL_vPg1xEt7pp86Pj-JNxeTP5g%40mail.gmail.com.


Re: [Maya-Python] Subprocess & PyInstaller

2021-09-29 Thread Justin Israel
On Thu, Sep 30, 2021 at 9:13 AM Benjam901  wrote:

> - I am unsure of the major differences but yes I need it compiled to a
> .app instead of a .exe
> - The crash itself I suspect to be a segfault, previously for unknown
> reasons my IDE was crashing with a SIGABRT error.


I've seen this kind of crash when something in python raises an exception
in certain Qt contexts like in a signal handler, or somewhere async where
the Qt stack freaks out from the python exception.


> - The path to ffmpeg is absolute and uses QStandardPaths to locate the
> documents folder where ffmpeg lives.
> - I have unthreaded the process and it is still the same issue, I will try
> additionally ro run a subprocess to open terminal or some other native app.
>

That is a great debugging point. So then I would focus further on debugging
without a QThread involved since it seems to have no impact on the crash.


> - QProcess I came across recently, what is the major difference between
> QProcess & QThread? Is it the same difference as Threading &
> Multiprocessing?
>

In this case I don't think its a matter of threading + multiprocessing
since you are using subprocess to exec. We have seen python/qt specific
bugs around that though.
You could try QProcess to at least isolate subprocess as the problem, since
it would be using an entirely different way to launch the child process.


>
> I get this error weirdly irregularly and is hard to repro 100%. It pops up
> and then goes away...
>
> *QThread: Destroyed while thread is still running*
> *Fatal Python error: Aborted*
> *Process finished with exit code 134 (interrupted by signal 6: SIGABRT)*
>

I think that is saying that your python QThread object reference is being
destroyed, before the underlying system thread has finished. Are you
keeping a reference to it while it is still running either by holding the
python object, or by having it parented to a Qt object?


>
> // Ben
>
> On Wednesday, 29 September 2021 at 19:30:32 UTC+2 justin...@gmail.com
> wrote:
>
>> On Thu, Sep 30, 2021 at 4:34 AM Benjam901  wrote:
>>
>>> Hello all,
>>>
>>> It is time to finally get a project out as open source but I am having a
>>> serious roadblock issue with subprocess.
>>>
>>> - In the code I create a new QThread for the subprocess function to run
>>> on.
>>> - Once the QThread is running I use subprocess.run() OR subprocess.Popen
>>> (whatever works) to call ffmpeg to convert some audio files.
>>>
>>> This works within PyCharm HOWEVER as soon as I package it up into a .app
>>> for mac it crashes immediately upon trying to run the subprocess without
>>> any errors or stacktrace.
>>>
>>> Has anyone had any issues like this before, I would really like this
>>> project to be finished and this is the last blocker
>>>
>>
>> You are developing on a mac as well and the only difference is source vs
>> app packaging?
>> Is the crash a segfault?
>> Is the path to ffmpeg an absolute path or is it relying on $PATH which
>> may be different in the app?
>> Can you successfully run a subprocess command in the packaged app without
>> a QThread (is the QThread the factor)?
>> Have you tried QProcess?
>>
>>
>>> Cheers,
>>>
>>> Ben
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/672ff5b3-ceac-4d42-acaf-c448ea375013n%40googlegroups.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/ee782b0c-7cae-4807-8d8b-5363660f5328n%40googlegroups.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/CAPGFgA1NSQ4EURrziWa-Oz0%3DR2i2Azq_PZj3cwjUB25dieQwDg%40mail.gmail.com.


Re: [Maya-Python] Subprocess & PyInstaller

2021-09-29 Thread Justin Israel
On Thu, Sep 30, 2021 at 4:34 AM Benjam901  wrote:

> Hello all,
>
> It is time to finally get a project out as open source but I am having a
> serious roadblock issue with subprocess.
>
> - In the code I create a new QThread for the subprocess function to run on.
> - Once the QThread is running I use subprocess.run() OR subprocess.Popen
> (whatever works) to call ffmpeg to convert some audio files.
>
> This works within PyCharm HOWEVER as soon as I package it up into a .app
> for mac it crashes immediately upon trying to run the subprocess without
> any errors or stacktrace.
>
> Has anyone had any issues like this before, I would really like this
> project to be finished and this is the last blocker
>

You are developing on a mac as well and the only difference is source vs
app packaging?
Is the crash a segfault?
Is the path to ffmpeg an absolute path or is it relying on $PATH which may
be different in the app?
Can you successfully run a subprocess command in the packaged app without a
QThread (is the QThread the factor)?
Have you tried QProcess?


> Cheers,
>
> Ben
>
> --
> 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/672ff5b3-ceac-4d42-acaf-c448ea375013n%40googlegroups.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/CAPGFgA2SuS%2BQOKvvf9yBvPb0PnB%3DwPz3BPFfjj%2Bq_2ThtreV0A%40mail.gmail.com.


Re: [Maya-Python] V Crypt System

2021-09-14 Thread Justin Israel
On Wed, Sep 15, 2021 at 11:36 AM Rudi Hammad  wrote:

> So I cam up with a evil idea that seems to work.
> . I create a script node that travels with the scene that will check your
> mac address out from a list of valid addresses (that would be the ones
> corresponding to the people working remotly on their personal computers).
>   if the address doesn't match it wont open (it opens a new file for
> instance)
> . So then, lets say that your address is valid. Now you would think that
> you can just delete the scriptNode and that's it, right? weI
> added a callback that triggers when you delete the scriptNode, that deletes
> everything .
>
> Of course we can just change that to something less evil, but maybe this
> might work? save a scriptnode will what ever callback are needed, and
> prevent this script node from bein delete?
> I don't know...I am starting to lose motivation...
>

What if I just open the scene file with the option to disable script nodes?
If it's somewhat trivial to defeat the security then you have to decide if
you are doing this with the goal of absolute security, or just being a
deterrent and using security-via-obscurity. If there is any way to get the
scene file opened, either by disabling script nodes, or by another binary
to ascii conversion that can then edit the script nodes, it kind of makes
this pointless if the goal is security.



>
>
>
> El lunes, 13 de septiembre de 2021 a las 22:21:47 UTC+2,
> justin...@gmail.com escribió:
>
>> On Tue, Sep 14, 2021 at 7:52 AM Rudi Hammad  wrote:
>>
>>> About V crypt, I got in thouch with them and they sent me the system to
>>> test it in demo mode. It work pretty well, but as Justin anticipated and as
>>> the video showed, all clients are requiered to have the app.
>>> So maya is should be launched from V Crypt, and then you can open the
>>> encrypted files. Which is not ideal because you are enforcing everyone to
>>> purchast their system.
>>>
>>> So as an alternatively I tried to do something with addCheckCallback
>>> that Marcus mention:
>>>
>>> mSceneMsgOpenCheck = OpenMaya.MSceneMessage()
>>> def licenseCheckOnOpen(*args):  # a function that reads your mac address
>>> and if it doesn't match the hardcoded one, it won't open.
>>>  
>>> OpenMaya.MSceneMessage.addCheckCallback(mSceneMsgOpenCheck.kBeforeOpenCheck,
>>> licenseCheckOnOpen)
>>>
>>> but that was a total failit work is you execute that at the
>>> beginning of every maya session (for instance putting it in the
>>> userSetup.py),  but then you just have to find this part of the code and
>>> remove it...
>>>
>>> ps: let me know if this last part is offtopic and I'll just shut up
>>> about it.
>>>
>>
>> Oh I didn't even connect your MEL and callback questions to this topic. I
>> see now that you were experimenting with related custom approaches.
>>
>> Yea I agree with you that it would be cumbersome to require everyone to
>> purchase some encryption app license. But maybe the approach is that a temp
>> license is given to the client on behalf of the owner of the media and the
>> one imposing the workflow? Having full ownership of the Maya process, as V
>> Crypt wants to do, seems like the only way to get close enough to securing
>> the media. If you ever let the user have direct unregulated access to the
>> source then they can disable whatever checks (callbacks or whatever).
>> "Close enough" is maybe just making it hard enough to avoid mistakes and
>> easily sharing things?
>>
>>
>>>
>>> El lunes, 13 de septiembre de 2021 a las 19:22:37 UTC+2, Rudi Hammad
>>> escribió:
>>>
 It was still kind in the context of encrypting a maya scene that
 derived from the main V Crypt topic, but we'll do.
 El lunes, 13 de septiembre de 2021 a las 19:07:28 UTC+2,
 justin...@gmail.com escribió:

> Please make sure to start a new thread if you want to engage in new
> topics. It seems two completely new questions have been asked since the
> original thread was started about V Crypt, and are entirely unrelated.
> Thanks!
>
> On Tue, 14 Sep 2021, 4:25 am Rudi Hammad,  wrote:
>
>> That's it! thanks Juan
>>
>> El lunes, 13 de septiembre de 2021 a las 15:33:57 UTC+2, Juan Moraga
>> escribió:
>>
>>> Try using "def onOpenCallBack(*args):" instead.
>>> Callbacks may pass on arguments to you method, which you can use or
>>> not. But you need to allow the function to receive these arguments,
>>> otherwise it will raise an exception.
>>>
>>>
>>> On Mon, 13 Sep 2021, 15:09 Rudi Hammad,  wrote:
>>>
 Hello,
 any idea why this is not working?
 I opened a scene and created this callback, and then saved the scene

 def onOpenCallBack():
print "this is a test"

 checkCallback =
 OpenMaya.MSceneMessage.addCheckCallback(OpenMaya.MSceneMessage.kBeforeOpenCheck,
 onOpenCallBack)

 Now when I open the scene I 

Re: [Maya-Python] V Crypt System

2021-09-13 Thread Justin Israel
On Tue, Sep 14, 2021 at 7:52 AM Rudi Hammad  wrote:

> About V crypt, I got in thouch with them and they sent me the system to
> test it in demo mode. It work pretty well, but as Justin anticipated and as
> the video showed, all clients are requiered to have the app.
> So maya is should be launched from V Crypt, and then you can open the
> encrypted files. Which is not ideal because you are enforcing everyone to
> purchast their system.
>
> So as an alternatively I tried to do something with addCheckCallback that
> Marcus mention:
>
> mSceneMsgOpenCheck = OpenMaya.MSceneMessage()
> def licenseCheckOnOpen(*args):  # a function that reads your mac address
> and if it doesn't match the hardcoded one, it won't open.
>  OpenMaya.MSceneMessage.addCheckCallback(mSceneMsgOpenCheck.kBeforeOpenCheck,
> licenseCheckOnOpen)
>
> but that was a total failit work is you execute that at the beginning
> of every maya session (for instance putting it in the userSetup.py),  but
> then you just have to find this part of the code and remove it...
>
> ps: let me know if this last part is offtopic and I'll just shut up about
> it.
>

Oh I didn't even connect your MEL and callback questions to this topic. I
see now that you were experimenting with related custom approaches.

Yea I agree with you that it would be cumbersome to require everyone to
purchase some encryption app license. But maybe the approach is that a temp
license is given to the client on behalf of the owner of the media and the
one imposing the workflow? Having full ownership of the Maya process, as V
Crypt wants to do, seems like the only way to get close enough to securing
the media. If you ever let the user have direct unregulated access to the
source then they can disable whatever checks (callbacks or whatever).
"Close enough" is maybe just making it hard enough to avoid mistakes and
easily sharing things?


>
> El lunes, 13 de septiembre de 2021 a las 19:22:37 UTC+2, Rudi Hammad
> escribió:
>
>> It was still kind in the context of encrypting a maya scene that derived
>> from the main V Crypt topic, but we'll do.
>> El lunes, 13 de septiembre de 2021 a las 19:07:28 UTC+2,
>> justin...@gmail.com escribió:
>>
>>> Please make sure to start a new thread if you want to engage in new
>>> topics. It seems two completely new questions have been asked since the
>>> original thread was started about V Crypt, and are entirely unrelated.
>>> Thanks!
>>>
>>> On Tue, 14 Sep 2021, 4:25 am Rudi Hammad,  wrote:
>>>
 That's it! thanks Juan

 El lunes, 13 de septiembre de 2021 a las 15:33:57 UTC+2, Juan Moraga
 escribió:

> Try using "def onOpenCallBack(*args):" instead.
> Callbacks may pass on arguments to you method, which you can use or
> not. But you need to allow the function to receive these arguments,
> otherwise it will raise an exception.
>
>
> On Mon, 13 Sep 2021, 15:09 Rudi Hammad,  wrote:
>
>> Hello,
>> any idea why this is not working?
>> I opened a scene and created this callback, and then saved the scene
>>
>> def onOpenCallBack():
>>print "this is a test"
>>
>> checkCallback =
>> OpenMaya.MSceneMessage.addCheckCallback(OpenMaya.MSceneMessage.kBeforeOpenCheck,
>> onOpenCallBack)
>>
>> Now when I open the scene I get this error:
>> # TypeError: onOpenCallBack() takes no arguments (2 given) //
>> // Warning: line 0: Python callback failed //
>>
>> but I didn't give any arguments. Why is it saying given 2? are they
>> *args and **kwargs? Still, any idea why this is not working?
>> Thanks
>>
>> El lunes, 6 de septiembre de 2021 a las 22:23:04 UTC+2, Rudi Hammad
>> escribió:
>>
>>> oh, about the screenshots. If the rig is encapsulated in a black
>>> box, maybe it would be possible set a callback preventing from unlocking
>>> the blackbox?
>>> That way you can check want is inside and take screenshot.
>>>
>>> El lunes, 6 de septiembre de 2021 a las 22:02:29 UTC+2, Rudi Hammad
>>> escribió:
>>>
 Quick question, I haven't use mel in 4 years now so it is probably
 something foolish but why is this not working?

 string $toEval = "def foo():import uuid; macAddress =
 uuid.getnode(); return macAddress; foo()";
 string $macAddress = python($toEval);
 print $x;

 I would expect $x to print my computer mac address by it is empty.

 El lunes, 6 de septiembre de 2021 a las 15:39:02 UTC+2,
 golu...@gmail.com escribió:

> Marcus, thanks for your comment!
>
> When I talked about export I meant not to ma or mb, I meant for
> example to alembic or other,  because as I knew alembic export is 
> like a
> separate plugin, and .correct me if I am wrong export to alembic will 
> be
> ignored by this callback.
>
> I've not 

Re: [Maya-Python] V Crypt System

2021-09-13 Thread Justin Israel
Please make sure to start a new thread if you want to engage in new topics.
It seems two completely new questions have been asked since the original
thread was started about V Crypt, and are entirely unrelated. Thanks!

On Tue, 14 Sep 2021, 4:25 am Rudi Hammad,  wrote:

> That's it! thanks Juan
>
> El lunes, 13 de septiembre de 2021 a las 15:33:57 UTC+2, Juan Moraga
> escribió:
>
>> Try using "def onOpenCallBack(*args):" instead.
>> Callbacks may pass on arguments to you method, which you can use or not.
>> But you need to allow the function to receive these arguments, otherwise it
>> will raise an exception.
>>
>>
>> On Mon, 13 Sep 2021, 15:09 Rudi Hammad,  wrote:
>>
>>> Hello,
>>> any idea why this is not working?
>>> I opened a scene and created this callback, and then saved the scene
>>>
>>> def onOpenCallBack():
>>>print "this is a test"
>>>
>>> checkCallback =
>>> OpenMaya.MSceneMessage.addCheckCallback(OpenMaya.MSceneMessage.kBeforeOpenCheck,
>>> onOpenCallBack)
>>>
>>> Now when I open the scene I get this error:
>>> # TypeError: onOpenCallBack() takes no arguments (2 given) //
>>> // Warning: line 0: Python callback failed //
>>>
>>> but I didn't give any arguments. Why is it saying given 2? are they
>>> *args and **kwargs? Still, any idea why this is not working?
>>> Thanks
>>>
>>> El lunes, 6 de septiembre de 2021 a las 22:23:04 UTC+2, Rudi Hammad
>>> escribió:
>>>
 oh, about the screenshots. If the rig is encapsulated in a black box,
 maybe it would be possible set a callback preventing from unlocking the
 blackbox?
 That way you can check want is inside and take screenshot.

 El lunes, 6 de septiembre de 2021 a las 22:02:29 UTC+2, Rudi Hammad
 escribió:

> Quick question, I haven't use mel in 4 years now so it is probably
> something foolish but why is this not working?
>
> string $toEval = "def foo():import uuid; macAddress = uuid.getnode();
> return macAddress; foo()";
> string $macAddress = python($toEval);
> print $x;
>
> I would expect $x to print my computer mac address by it is empty.
>
> El lunes, 6 de septiembre de 2021 a las 15:39:02 UTC+2,
> golu...@gmail.com escribió:
>
>> Marcus, thanks for your comment!
>>
>> When I talked about export I meant not to ma or mb, I meant for
>> example to alembic or other,  because as I knew alembic export is like a
>> separate plugin, and .correct me if I am wrong export to alembic will be
>> ignored by this callback.
>>
>> I've not understood you, sorry, yes it is already protected, but if
>> this protected scene to /myrig.mb will be referenced in the main scene,
>> during the main parent scene opening, I will need to decrypt my rig.mb 
>> and
>> any other child scene which is referenced and send to a remote worker,
>> or I understand you wrong)
>>
>> About RAM I'm sorry, that's my mistake, later edited the message, but
>> was too late, you absolutely right!
>>
>> понедельник, 6 сентября 2021 г. в 13:27:48 UTC+3, Marcus Ottosson:
>>
>>> The part of Maya that does the serialisation to ma and mb - be it
>>> via export or save - is a singular point of access. The scene callbacks
>>> should account for all ways in which creating those is possible, 
>>> including
>>> via Python and MEL. It wouldn’t account for manual export to other 
>>> formats,
>>> but there’s no end to that. Screenshotting your viewport is a format 
>>> too,
>>> albeit a lossy one. But I’d argue that depending on what you want to
>>> protect, if that is rigs and animation, the Maya scene format should be
>>> enough.
>>>
>>>- OpenMaya.MSceneMessage.addCheckCallback()
>>>
>>> 
>>>
>>> And all of it must be done recursively on the whole data tree in
>>> scene
>>>
>>> I’d argue not. The information you protect is the information in the
>>> scene file. If that scene file consists of an absolute path to e.g.
>>> c:\myassets\myrig.mb then that is *already* protected; nobody can
>>> access that file but you on your local machine.
>>>
>>> so at some point how to handle your RAM memory, because you can’t
>>> store this encrypted data somewhere…)
>>>
>>> I’d argue not (again :)). Is it to protect against hacker-animators
>>> and hacker-riggers? Or against the general workforce that has no clue 
>>> about
>>> callbacks and encryption? If the latter, then saving it into a temp
>>> directory first, and encrypting it after should suffice. To the user, 
>>> the
>>> file would end up where they said it should. But really, it’s a 
>>> different
>>> file altogether. Then that file is copied back into a temp directory and
>>> decrypted whenever they 

Re: [Maya-Python] V Crypt System

2021-09-04 Thread Justin Israel
On Sun, Sep 5, 2021 at 8:38 AM Marcus Ottosson 
wrote:

> That is true, that does sound like a good idea. Assuming the software
> actually does what it says on the tin, it would at least protect against
> theft and accidental sharing.
>
> It wouldn’t protect against sending files though, because if someone
> wanted to send some model or some rig, they could still just export it to a
> new .ma? For that, you’d probably be better off intermingling it with
> custom nodes. Like how anything rigged with mGear is riddled with mGear
> nodes, making anyone attempting to open that rig without mGear loaded left
> with a sorely broken rig. And no amount of exporting or tampering with the
> scene file could fix it.
>
>From the video it looks like you have to launch Maya from their launcher,
which I assume installs a particular reader/writer plugin. I wonder if it's
specific to ma/mb file types or if it hooks into every type. Because I was
thinking that same thing you said about exporting to other formats, and
would that go through the same hook?  Also once Maya is launched, could
someone turn off the plugin after the scene is loaded?

When it comes to protecting stuff like code, usually you hear the best
security is to just never let the source get onto the client side. But with
DCC scene files if you have to work with them locally then it feels like
there is going to be some way to defeat it. Once its unencrypted in the
DCC, there must be a weakness that might just be more obscure to many
people and the security is really just focused on the obvious act of
copying files around. Probably the better approach is just not letting
people work on their person workstations and only support a remote
workstation solution like teradici.


>
> On Sat, 4 Sept 2021 at 19:50, Rudi Hammad  wrote:
>
>> Yes I am refereing to the actual file, not source code.
>> Here's a usecase:
>> due to covid a lot of production are done remotly. In somecase you can
>> connect  by logging remotly to office computers to work, in which case no
>> protection is needed since it pretty much as if you where in the office.
>> But in many cases, the files are sent to personal computers. Let's say
>> you rig  characters  that are sent to 10 different animators to their
>> personal computers. Despite the NDAs, its impossible to police everyone,
>> specially if you don't know the client but you don't want to miss the
>> opportunity to get a job. There is no guaranty that someone will not leak
>> the file outside the production.
>> So here is where you use in V Crypt system. It is not like you are
>> recieving a file from an untrusted source because you are part of a
>> production and you know that your .mb and .ma files are from the rigger not
>> form a the prince
>> of niggeria that is asking you for money XD.
>>
>> That's seem a pretty secure way of working don't you think? you know you
>> recieve a file that is encrypted because you know you are in production
>> context. You can open it and work with it. It simply won't work outside you
>> computer.
>> El sábado, 4 de septiembre de 2021 a las 20:06:47 UTC+2, Marcus Ottosson
>> escribió:
>>
>>> To protect the contents of a Maya file? Typically protection would
>>> involve software, like Python source, but you mean to protect like a model
>>> or some animation? At that point, why wouldn’t you just hold onto the file,
>>> and not send it or make it publicly available? Maybe you have a particualr
>>> usecase in mind, because I can’t quite see it.
>>>
>>> Also I would be most weary opening an .mb from an untrusted source.
>>> That’s what .ma is for, so you can inspect it for any script-related
>>> things. I’ve been bitten before and, as they saying goes, fool me once.
>>>
>>> On Sat, 4 Sept 2021 at 16:17, Rudi Hammad  wrote:
>>>
 Hi,
 a while a go I create a thread about protecting your work.
 Along the same lines I saw this

 V Crypt maya files 

 So in theory, you can generate a license for the computer mac address,
 and inside your
 .ma and .mb so some kind of assertion make sure sure that the file is
 being open in the right computer. And since both files are crypted, you can
 remove that block of the code.
 Also, if you try to saveAs, it is saved with th crypted format.

 It seems like a good solution right? what do you think?

 R

 --
 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_m...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/a1c4949b-eead-412d-b10a-6750ab07ef85n%40googlegroups.com
 

Re: [Maya-Python] Texture path

2021-07-26 Thread Justin Israel
On Mon, Jul 26, 2021 at 4:19 AM DGFA DAG's GRAPHIC & FOTO ART <
gerome@gmail.com> wrote:

> Hi,
> when I want to change the texture path I struggle on one point.
> Let say the path is now
> project/create/Maya/sourceimages/room/texture.exr
> There could be a deeper sub folder structure like
> project/create/Maya/sourceimages/light/exr/light.exr etc.
>
> How can replace the path just to sourceimages and preserve all after that?
>

You may need to provide some more details about your goal, but this sounds
like it might just be a python string formatting problem.
Assuming you already know how to get and set the texture filepath, and have
the texture path value as a variable:

path = 'project/create/Maya/sourceimages/room/texture.exr'

you should be able to use one of the many possible approaches to extracting
the substring.

First you have to start with some known prefix you want to preserve.

prefix = 'project/create/Maya/sourceimages/'
new_prefix = 'path/to/new/sourceimages/'

You could use some of the built in string methods to replace the prefix:

path.replace(prefix, new_prefix, 1)#
'path/to/new/sourceimages/light/exr/light.exr'

new_prefix + path.partition(prefix)[-1]#
'path/to/new/sourceimages/light/exr/light.exr'

If you want more control over the substitution, such as being able to only
replace it if it actually starts with your prefix,
you could use a regular expression:

import re
re.sub(r'^' + prefix, new_prefix, path)#
'path/to/new/sourceimages/light/exr/light.exr'

re.sub(r'^' + prefix, new_prefix, 'dont_replace/'+path)#
'dont_replace/project/create/Maya/sourceimages/light/exr/light.exr'


Justin


> Justin made a awesome YouTube blog, but I have no clue how to solve
> procedurally this path problem.
>
> Thank you!
>
> --
> 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/a72d98b3-63cf-465d-abaa-4b99e1951f97n%40googlegroups.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/CAPGFgA0Y4Kk_Ho9O50EM%2B0WePGuOC0UdhY4dug4VbtQ5LjFy%2BA%40mail.gmail.com.


Re: [Maya-Python] Open Scene and get references

2021-07-20 Thread Justin Israel
This would tell you the reference nodes:

refnodes = pmc.selLoadSettings(ids, referenceNode=True, q=True)



On Wed, Jul 21, 2021 at 12:17 PM Totally Zen  wrote:

> hey, a million excuses, I was wrong, I didn't pay attention that I was
> with the scene open while I was testing, so I still haven't got it, lol
> Apologies.
>
> Em terça-feira, 20 de julho de 2021 às 21:06:03 UTC-3, Totally Zen
> escreveu:
>
>>
>> I managed to get to the part I wanted...
>>
>> After having the result value as a UNICODE,
>>
>> if we look at it's the path... and using that path I do the following.
>>
>>for res in result:
>>   fileRn = pmc.system.FileReference(pathOrRefNode=res)
>>   print(type(fileRn)) ### Returns to a pymel class
>>   print(fileRn.refNode) ### and I can get the refNode too
>>
>> I think that's it so far, lol thanks a lot for your help!
>>
>>
>> Em terça-feira, 20 de julho de 2021 às 20:39:53 UTC-3, Totally Zen
>> escreveu:
>>
>>> Very good what happened to me, I'll see with more time.
>>>
>>> If I could somehow get the RN from the references I would need to open
>>> the scene.
>>>
>>> I would use:
>>>   fileRN =
>>> pmc.system.FileReference(pathOrRefNode="Animal_RIG_A001_v005RN")
>>>   fileRN.unload()
>>>
>>> So I think I could. Thank you so much for your time helping me.
>>>
>>> Em terça-feira, 20 de julho de 2021 às 17:12:31 UTC-3,
>>> justin...@gmail.com escreveu:
>>>
 I see what you mean now. Yes the API docs say that it is meant to
 return a unicode string for the fileName parameter. I haven't played with
 this API before so I can only guess as to what is going on and had a quick
 play to try and get your expected results.

 When you do buildLoadSettings=True, and loadReferenceDepth='none', Maya
 only checks the paths and doesn't load or create any nodes. It saves an
 internal settings list for the preload reference editor so you can be
 selective about what to actually load. This can be controlled with the
 selLoadSettings function and by default all the references will start out
 as deferred (unloaded). You could selectively load some of them, but that
 doesn't seem to be what you are after right now.

 import pymel.core as pmc

 scene = "/tmp/refs.mb"
 pmc.openFile(scene, force=True, loadReferenceDepth='none', 
 buildLoadSettings=True)
 pmc.getReferences()# Oh no, it's currently empty!# {}


 But if you then tell Maya to load the scene with those previously built
 settings, you should be able to get your FileReferences.

 pmc.openFile(scene, force=True, loadSettings="implicitLoadSettings")
 pmc.getReferences() # or:   list(pmc.iterReferences())# Result: {
  u'ball1': FileReference(u'/tmp/ball1.mb', refnode=u'ball1RN'),
  u'cone1': FileReference(u'/tmp/cone1.mb', refnode=u'cone1RN'),
  u'cube1': FileReference(u'/tmp/cube1.mb', refnode=u'cube1RN')} #


 You could also select the ones you want to have loaded up front:

 pmc.openFile(scene, force=True, loadReferenceDepth='none', 
 buildLoadSettings=True)
 ret = pmc.selLoadSettings(numSettings=True, query=True)
 ids = [str(i) for i in range(ret) if i]
 paths = pmc.selLoadSettings(ids, fileName=True, q=True)
 # tell the ball reference to load
 pmc.system.selLoadSettings(['1'], e=True, deferReference=0)
 pmc.system.selLoadSettings(ids, q=True, deferReference=1)# Result: [False, 
 True, True] #

 pmc.openFile(scene, force=True, loadSettings="implicitLoadSettings")


 Hopefully this is what you were after?


 On Wed, Jul 21, 2021 at 12:32 AM Totally Zen  wrote:

> Yes, in a new code I changed it to use only pymel, but I still have
> the result of the type "unicode" and if it's not a type :  'pymel.core.system.FileReference'> I can't use load() or unload() .. :(
>
> does anyone have any solution?
>
> Em terça-feira, 20 de julho de 2021 às 06:35:04 UTC-3,
> justin...@gmail.com escreveu:
>
>>
>>
>> On Tue, 20 Jul 2021, 1:32 pm Totally Zen,  wrote:
>>
>>> this command:
>>> pmc.system.openFile(sceneNameToOpen, force=True, loadReferenceDepth
>>> = 'none', buildLoadSettings=True)
>>> result:
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>>
>>
>>
>> You started here by using the pymel api.
>>
>>
>>
>>> nsettings = range(cmds.selLoadSettings(numSettings=1, query=1))
>>> ids = [str(i) for i in nsettings if i]
>>> result = cmds.selLoadSettings(ids, fileName=1, query=1)
>>> print result
>>> result:
>>> [u'C:/my_scene/animal_RIG_A001.v002.mb',
>>> u'C:/my_scene/animal_RIG_A001.v002.mb',
>>> u'C:/my_scene/animal_RIG_A001.v002.mb']
>>>
>>> for item in result:
>>>  item.load()
>>> ERROR:
>>> 

Re: [Maya-Python] Open Scene and get references

2021-07-20 Thread Justin Israel
I see what you mean now. Yes the API docs say that it is meant to return a
unicode string for the fileName parameter. I haven't played with this API
before so I can only guess as to what is going on and had a quick play to
try and get your expected results.

When you do buildLoadSettings=True, and loadReferenceDepth='none', Maya
only checks the paths and doesn't load or create any nodes. It saves an
internal settings list for the preload reference editor so you can be
selective about what to actually load. This can be controlled with the
selLoadSettings function and by default all the references will start out
as deferred (unloaded). You could selectively load some of them, but that
doesn't seem to be what you are after right now.

import pymel.core as pmc

scene = "/tmp/refs.mb"
pmc.openFile(scene, force=True, loadReferenceDepth='none',
buildLoadSettings=True)
pmc.getReferences()# Oh no, it's currently empty!# {}


But if you then tell Maya to load the scene with those previously built
settings, you should be able to get your FileReferences.

pmc.openFile(scene, force=True, loadSettings="implicitLoadSettings")
pmc.getReferences() # or:   list(pmc.iterReferences())# Result: {
 u'ball1': FileReference(u'/tmp/ball1.mb', refnode=u'ball1RN'),
 u'cone1': FileReference(u'/tmp/cone1.mb', refnode=u'cone1RN'),
 u'cube1': FileReference(u'/tmp/cube1.mb', refnode=u'cube1RN')} #


You could also select the ones you want to have loaded up front:

pmc.openFile(scene, force=True, loadReferenceDepth='none',
buildLoadSettings=True)
ret = pmc.selLoadSettings(numSettings=True, query=True)
ids = [str(i) for i in range(ret) if i]
paths = pmc.selLoadSettings(ids, fileName=True, q=True)
# tell the ball reference to load
pmc.system.selLoadSettings(['1'], e=True, deferReference=0)
pmc.system.selLoadSettings(ids, q=True, deferReference=1)# Result:
[False, True, True] #

pmc.openFile(scene, force=True, loadSettings="implicitLoadSettings")


Hopefully this is what you were after?


On Wed, Jul 21, 2021 at 12:32 AM Totally Zen  wrote:

> Yes, in a new code I changed it to use only pymel, but I still have the
> result of the type "unicode" and if it's not a type :  'pymel.core.system.FileReference'> I can't use load() or unload() .. :(
>
> does anyone have any solution?
>
> Em terça-feira, 20 de julho de 2021 às 06:35:04 UTC-3, justin...@gmail.com
> escreveu:
>
>>
>>
>> On Tue, 20 Jul 2021, 1:32 pm Totally Zen,  wrote:
>>
>>> this command:
>>> pmc.system.openFile(sceneNameToOpen, force=True, loadReferenceDepth =
>>> 'none', buildLoadSettings=True)
>>> result:
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>> # C:/my_scene/animal_RIG_A001.v002.mb
>>>
>>
>>
>> You started here by using the pymel api.
>>
>>
>>
>>> nsettings = range(cmds.selLoadSettings(numSettings=1, query=1))
>>> ids = [str(i) for i in nsettings if i]
>>> result = cmds.selLoadSettings(ids, fileName=1, query=1)
>>> print result
>>> result:
>>> [u'C:/my_scene/animal_RIG_A001.v002.mb',
>>> u'C:/my_scene/animal_RIG_A001.v002.mb',
>>> u'C:/my_scene/animal_RIG_A001.v002.mb']
>>>
>>> for item in result:
>>>  item.load()
>>> ERROR:
>>> Error: AttributeError: file  line 27: 'unicode' object has
>>> no attribute 'load' #
>>>
>>> This is because my result type is coming "unicode" and not as a : >> 'pymel.core.system.FileReference'>
>>>
>>
>> But then you switched to using the commands api which only deals in
>> strings. You should keep using pymel if that it what you wanted.
>>
>>
>> https://help.autodesk.com/cloudhelp/2018/JPN/Maya-Tech-Docs/PyMel/generated/functions/pymel.core.system/pymel.core.system.selLoadSettings.html
>>
>>
>>> and remembering that I want to run my code to find the references and
>>> enable and disable without having to load it into maya.
>>>
>>>
>>> Em segunda-feira, 19 de julho de 2021 às 22:18:07 UTC-3,
>>> justin...@gmail.com escreveu:
>>>
 Did you give it a try with mayapy.exe?


 https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html

 On Tue, 20 Jul 2021, 11:36 am Totally Zen,  wrote:

> I need to open a scene without loading in maya and get its references,
> to later work on some to load() correctly
> *** I would like to use only pymel ***
>
> code example:
> import maya.cmds as cmds
> sceneNameToOpen = "C:\my_scene\animal.mb"
>
> cmds.file(sceneNameToOpen, loadReferenceDepth = 'none', open=1,
> buildLoadSettings=1):
> mel.eval('PreloadReferenceEditor;')
>
> --
> 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_m...@googlegroups.com.
> To view this discussion on the web visit
> 

Re: [Maya-Python] Open Scene and get references

2021-07-20 Thread Justin Israel
On Tue, 20 Jul 2021, 1:32 pm Totally Zen,  wrote:

> this command:
> pmc.system.openFile(sceneNameToOpen, force=True, loadReferenceDepth =
> 'none', buildLoadSettings=True)
> result:
> # C:/my_scene/animal_RIG_A001.v002.mb
> # C:/my_scene/animal_RIG_A001.v002.mb
> # C:/my_scene/animal_RIG_A001.v002.mb
>


You started here by using the pymel api.



> nsettings = range(cmds.selLoadSettings(numSettings=1, query=1))
> ids = [str(i) for i in nsettings if i]
> result = cmds.selLoadSettings(ids, fileName=1, query=1)
> print result
> result:
> [u'C:/my_scene/animal_RIG_A001.v002.mb',
> u'C:/my_scene/animal_RIG_A001.v002.mb',
> u'C:/my_scene/animal_RIG_A001.v002.mb']
>
> for item in result:
>  item.load()
> ERROR:
> Error: AttributeError: file  line 27: 'unicode' object has
> no attribute 'load' #
>
> This is because my result type is coming "unicode" and not as a :  'pymel.core.system.FileReference'>
>

But then you switched to using the commands api which only deals in
strings. You should keep using pymel if that it what you wanted.

https://help.autodesk.com/cloudhelp/2018/JPN/Maya-Tech-Docs/PyMel/generated/functions/pymel.core.system/pymel.core.system.selLoadSettings.html


> and remembering that I want to run my code to find the references and
> enable and disable without having to load it into maya.
>
>
> Em segunda-feira, 19 de julho de 2021 às 22:18:07 UTC-3,
> justin...@gmail.com escreveu:
>
>> Did you give it a try with mayapy.exe?
>>
>>
>> https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html
>>
>> On Tue, 20 Jul 2021, 11:36 am Totally Zen,  wrote:
>>
>>> I need to open a scene without loading in maya and get its references,
>>> to later work on some to load() correctly
>>> *** I would like to use only pymel ***
>>>
>>> code example:
>>> import maya.cmds as cmds
>>> sceneNameToOpen = "C:\my_scene\animal.mb"
>>>
>>> cmds.file(sceneNameToOpen, loadReferenceDepth = 'none', open=1,
>>> buildLoadSettings=1):
>>> mel.eval('PreloadReferenceEditor;')
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/cbedc1bf-2d09-4921-8d95-8795855708d1n%40googlegroups.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/b9ef65e8-d4c0-4cad-b062-04b0d2662ff2n%40googlegroups.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/CAPGFgA2aK%2Bcd_tXmWLgYZf%2BnYWDb49P6a1Ldk-wQ9tpUT1YL6g%40mail.gmail.com.


Re: [Maya-Python] Open Scene and get references

2021-07-19 Thread Justin Israel
Did you give it a try with mayapy.exe?

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html

On Tue, 20 Jul 2021, 11:36 am Totally Zen,  wrote:

> I need to open a scene without loading in maya and get its references, to
> later work on some to load() correctly
> *** I would like to use only pymel ***
>
> code example:
> import maya.cmds as cmds
> sceneNameToOpen = "C:\my_scene\animal.mb"
>
> cmds.file(sceneNameToOpen, loadReferenceDepth = 'none', open=1,
> buildLoadSettings=1):
> mel.eval('PreloadReferenceEditor;')
>
> --
> 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/cbedc1bf-2d09-4921-8d95-8795855708d1n%40googlegroups.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/CAPGFgA12qPhBSL7FsoupPt619W9CkEQ64wfb4MUOV_Hmb509wQ%40mail.gmail.com.


Re: [Maya-Python] Query Layout Panels?

2021-07-11 Thread Justin Israel
On Sat, Jul 10, 2021 at 1:07 AM João Victor  wrote:

> Hi everyone,
>
> Maybe somebody know how I could query the active layout panels?
> If its a "single" or "four" or "vertical2" and so on..
>

You can query the global main pane layout, and then query its configuration:

import maya.cmds as cmdsimport maya.mel as mm

mainPane = mm.eval("$temp = $gMainPane;")
cmds.paneLayout(mainPane, query=True, numberOfVisiblePanes=True)# 4
cmds.paneLayout(mainPane, query=True, configuration=True)# quad

https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/CommandsPython/paneLayout.html


> Thanks,
>
> João
>
> --
> 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/4cedf497-de9e-4f77-a7f1-c648a889bd21n%40googlegroups.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/CAPGFgA0iFOUKkmPwHKsg4fTEwy2VfQJnLup8%2Bqh5-meqEc6kQw%40mail.gmail.com.


Re: [Maya-Python] printing with python3+

2021-07-11 Thread Justin Israel
On Sat, Jul 10, 2021 at 12:54 AM vince touache 
wrote:

> brilliant, I didn't know that. However, for some reason, it still doesn't
> show up in the main gui one-liner widget.
> Any other suggestions?
>

I don't really know why that behaviour is different. But could you just not
rely on the python print formatting, and instead maybe switch to using the
explicit support in Maya's command api for pushing messages into the
message status line?

https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/CommandsPython/messageLine.html


> Thank you
>
> Le jeudi 8 juillet 2021 à 13:40:25 UTC-4, justin...@gmail.com a écrit :
>
>>
>>
>> On Fri, 9 Jul 2021, 5:05 am vince touache,  wrote:
>>
>>> hi all,
>>>
>>> With previous versions of maya, I was using a lot
>>> print 'foo',
>>> with the coma in the end, which was forcing my print to show up in the
>>> 1-line listener embedded to the maya main window (just like a
>>> mel.eval('print "foo";') would do).
>>> However, with python 3 and the new print() syntax, this trick doesn't
>>> seem to work anymore.
>>>
>>
>>
>> https://docs.python.org/3/library/functions.html#print
>>
>> The python3 print function accepts an end parameter that defaults to a
>> newline. So just set it to some other character.
>>
>> print("my line", end=" ")
>>
>>
>>> Is there another way I could make sure my prints are visible not only
>>> from the script editor but also from the main windows? (other than using
>>> mel.eval)?
>>>
>>> cheers
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/d4761b10-aa3a-45d7-a5ca-b7ad576b1076n%40googlegroups.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/5e459093-46bf-41e8-aaa6-95b0c001e79bn%40googlegroups.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/CAPGFgA0FCoYF3Hx__G189Lo4P6G3703uxD5z%3DC7FEpC7SKzgrQ%40mail.gmail.com.


Re: [Maya-Python] printing with python3+

2021-07-08 Thread Justin Israel
On Fri, 9 Jul 2021, 5:05 am vince touache,  wrote:

> hi all,
>
> With previous versions of maya, I was using a lot
> print 'foo',
> with the coma in the end, which was forcing my print to show up in the
> 1-line listener embedded to the maya main window (just like a
> mel.eval('print "foo";') would do).
> However, with python 3 and the new print() syntax, this trick doesn't
> seem to work anymore.
>


https://docs.python.org/3/library/functions.html#print

The python3 print function accepts an end parameter that defaults to a
newline. So just set it to some other character.

print("my line", end=" ")


> Is there another way I could make sure my prints are visible not only from
> the script editor but also from the main windows? (other than using
> mel.eval)?
>
> cheers
>
> --
> 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/d4761b10-aa3a-45d7-a5ca-b7ad576b1076n%40googlegroups.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/CAPGFgA1fDhqH-bQptB0mhZFfkA-%2B%3Dz_Wxn4SP%3DsWNUsrE2mdBg%40mail.gmail.com.


Re: [Maya-Python] Colapse ChannelBox in Python or Mel?

2021-07-04 Thread Justin Israel
On Sun, Jul 4, 2021 at 11:12 AM João Victor  wrote:

> Hey guys, would somebody know how I could toggle colapse Channel Box (not
> close)?
> I could use mel or python.
>
> thanks a lot!
>

Is this what you are after?

1. Open script editor and enable "History"-> "Echo All Commands"
2. Hit the "Toggle the Channel Box button on the top right"
3. Take note of the mel command used to toggle the visibility of the
Channel Box
4. Disable "Echo All Commands"

So then this snippet should toggle it the same way as the button:


*MEL*
'toggleUIComponentVisibility("Channel Box / Layer Editor");

*PYTHON*
import maya.mel as mm
mm.eval('toggleUIComponentVisibility("Channel Box / Layer Editor");')



> Joao
>
> --
> 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/78f29055-d459-4f96-86be-64c7e60724fcn%40googlegroups.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/CAPGFgA1Me8F5OCeb_BcXjEbgA4rjofd0rEAxoQMJdaJVHZ63UA%40mail.gmail.com.


Re: [Maya-Python] Copy key and paste keys from imported rig to referenced rig

2021-06-28 Thread Justin Israel
On Mon, Jun 28, 2021 at 11:51 PM Utkarsh Agnihotri 
wrote:

> Hi everyone,
> I am trying to copy keys from imported rig and paste it to the reference
> rig. I have written following code:
>
> ```  import pymel.core as pm
>
> # select the ctrls to copy keys
> sel = pm.ls("*CTRL")
>
> print(sel)
>
> # get a list of references
> refs = pm.listReferences()
>
> reference_namespaces = []
>
> # get list of namespaces from reference
> for ref in refs:
> reference_namespaces.append(ref.namespace)
>
> # get time slider range of the scene
> min_timeRange = pm.playbackOptions(q=1, min=1)
> max_timeRange = pm.playbackOptions(q=1, max=1)
>
> time_value = "{}:{}".format(min_timeRange, max_timeRange)
> float_value = "{}:{}".format(min_timeRange, max_timeRange)
>
> for s in sel:
> pm.copyKey(s, time=":", hierarchy="none", controlPoints=0, shape=1)
> for reference_namespace in reference_namespaces:
> if pm.objExists(reference_namespace + ":" + s):
> referenced_ctrl = reference_namespace + ":" + s
> pm.pasteKey(referenced_ctrl, option="replaceCompletely",
> float=(min_timeRange, max_timeRange),
> time=(min_timeRange, max_timeRange), copies=1,
> connect=0)```
>
> It is showing me following error:
> # Traceback (most recent call last):
> #   File "", line 1, in 
> #   File
> "D:/Downloads/Scripts/Scripts/utkarsh/daily_scripts/transferKeys.py", line
> 29, in 
> # pm.pasteKey(referenced_ctrl, option="replaceCompletely",
> time=(min_timeRange, max_timeRange))
> #   File "C:\Program
> Files\Autodesk\Maya2020\Python\lib\site-packages\pymel\core\animation.py",
> line 754, in pasteKey
> # res = cmds.pasteKey(*args, **kwargs)
> #   File "C:\Program
> Files\Autodesk\Maya2020\Python\lib\site-packages\pymel\internal\pmcmds.py",
> line 130, in pasteKey_wrapped
> # res = new_cmd(*new_args, **new_kwargs)
> # RuntimeError: time ranges not valid with given option #
>
> pastekey command seems to be the main issue and I checked with command
> page. I understand what is wrong with the command.
> Please help!!
>

You have created these identical formatted strings:

time_value = "{}:{}".format(min_timeRange, max_timeRange)
float_value = "{}:{}".format(min_timeRange, max_timeRange)

But you never used them:

pm.pasteKey(referenced_ctrl, option="replaceCompletely",
float=(min_timeRange, max_timeRange),
time=(min_timeRange, max_timeRange), copies=1,
connect=0)

Did you mean to pass time_value or float_value to the float/time parameters
instead of the tuples?


>
>
> --
> 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/c920bd24-d2dc-4218-9e17-47e56a469ed0n%40googlegroups.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/CAPGFgA34ByLx%2Bh0zw8mLVbh%3DW5ToTujvFSgkP-o%3D_j_030ZWnQ%40mail.gmail.com.


Re: [Maya-Python] Need to open Pycharm/Notepad++ from Maya python shelf (Windows)

2021-06-23 Thread Justin Israel
On Wed, Jun 23, 2021 at 10:02 PM Alien Ghost Ship Animation <
animat...@alienghostship.com> wrote:

> Hi all, we are porting all scripts since Python3 is now integrated, and
> need to open PyCharm/Notepad++ from within Maya to replace script editor.
>
> *MEL *system()* executes fine and doesn't halt maya, awaiting NP++ to
> close:*
> string $scriptsPath = `internalVar -userScriptDir`;
> chdir $scriptsPath;
> system("start C:/Program Files (x86)/Notepad++/notepad++.exe new_prog.mel")


The start command should be spawning your program into a new detached
background process, which causes the system function to return right away,
as it sees the start command has finished.


>
> *Python version makes maya UI wait until NP++/Pycharm closes if using
> anything other than popen*
> import subprocess as subp
>
> progpath=r'C:/Program Files (x86)/Notepad++/notepad++.exe'
> launch=subp.Popen(progpath)
> ...
>

Well, what other approaches did you use that ended up hanging Maya? In your
MEL example you prefixed your command with "start" to allow it to run in
the background and then return immediately. But if you are not using that
in python, then you might be blocking on the notepad process to finish.
Running this Popen(notepad_command) is going to start the nodepad process
directly and not block Maya unless you wait for the pid to complete
(.wait()). However, it may be possible to start seeing zombie processes (at
least on Linux/mac, not sure about windows) if you launch it this way, and
the notepad command eventually finished but you never check the pid result
(wait()).


>
> *Since the external programs auto-save work, anything wrong with a *
> launch.kill()* shelf double-click (as long as I store & kill the proper
> PID of course)?*
>

Calling the kill() should end up doing the needed waitpid to prevent seeing
zombie child processes. So this approach should work as long as it is
actually killed this way, and not just closed from the child notepad
window. It is possible to also pass the popen instance into a thread that
does the wait(). You could test those situations.


>
> Anything else I should consider when using this method, or better ones
> would be appreciated. Thanks all!
>
>
>
> --
> 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/95da2ba1-f7c2-4626-b2c4-28c1b7945259n%40googlegroups.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/CAPGFgA24t39HgP_tAmzoVO__dox%2B7rwsK-k3mmtJsGr91nhZmg%40mail.gmail.com.


Re: [Maya-Python] Multiple optionMenu lists working with one directory problem

2021-06-22 Thread Justin Israel
On Wed, Jun 23, 2021 at 10:43 AM Anastasia Korol 
wrote:

> Hi guys! I am doing simple UI for choosing textures for two nodes in the
> shader and I can't make the optionMenu command to work one by one with the
> same source for the both optionMenu1 and optionMenu2. I have one directory
> to choose and need two similar lists where user can choose the texture file
> and apply it on two different nodes. So far I am interested only in
> understanding how to make both of the optionMenus work with one folder
> button:


The button should only be able to attach to a single layout, because the
layout takes ownership of its position. You should try creating a second
instance of the button for the second layout.


>
>
>
>
> import maya.cmds as cmds
> from os import listdir
>
> class AK_TextureLink(object):
> def __init__(self):
> self.window = 'ShaderWindow'
> self.title = 'Layered Shader Window'
> self.size = (600, 250)
> self.createWindow()
>
> def createWindow(self):
> if cmds.window(self.window, exists = True):
> cmds.deleteUI(self.window, window = True)
>
> self.window = cmds.window(self.window, title = self.title,
> widthHeight = self.size)
>
>
> self.mainForm = cmds.formLayout(numberOfDivisions = 100);
>
> self.titleDisplay = cmds.text(label = self.title, align="center",
> font = 'boldLabelFont')
> cmds.formLayout(self.mainForm, edit = True, attachForm=(
> [self.titleDisplay, 'top', 5],
>
>  [self.titleDisplay, 'left', 5],
>
>  [self.titleDisplay, 'right', 5] ))
>
>
>
> self.titleSeparator = cmds.separator();
> cmds.formLayout(self.mainForm, edit=True, attachControl =
> [self.titleSeparator, 'top', 10, self.titleDisplay],
>   attachForm =
> ([self.titleSeparator, 'left', 5],
>
> [self.titleSeparator, 'right', 5] ))
> #creating the button for folder choice
>
> self.btnFolderSet1 = cmds.button(label='Set Texture Folder',
> height=30, width=150, command=self.SetFolderBtnCmd1)
> cmds.formLayout(self.mainForm, edit=True, attachControl =
> [self.btnFolderSet1, 'top', 30, self.titleDisplay],
>   attachForm =
> [self.btnFolderSet1, 'left', 5])
>
>
> #the first list which i want to work with folder choice button
> self.firstTextureList = cmds.optionMenu('optionMenu1',label="First
> File List")
> cmds.formLayout(self.mainForm, edit=True, attachControl =
> [self.firstTextureList, 'top', 30, self.btnFolderSet1],
>   attachForm =
> [self.firstTextureList, 'left', 5])
>
>
> #the second list which is working with folder button
>
> self.secondTextureList =
> cmds.optionMenu('optionMenu2',label="Second File List")
> cmds.formLayout(self.mainForm, edit=True, attachControl =
> ([self.secondTextureList, 'top', 30, self.btnFolderSet1],
>
>  [self.secondTextureList, 'left', 20, self.firstTextureList]))
>
>
>
> self.btnApplyShader = cmds.button(label='Apply Shader', height=30,
> width=150, command=self.applyShaderBtnCmd)
> cmds.formLayout(self.mainForm, edit=True, attachControl =
> [self.btnApplyShader, 'top', 20, self.firstTextureList],
>   attachForm =
> [self.btnApplyShader, 'left', 5])
>
> cmds.showWindow()
>
> def SetFolderBtnCmd1(self, *args):
> print 'button pressed'
> basicFilter = "Image Files (*.jpg *.jpeg *.tga *.png *.tiff *.bmp
> *.psd)"
> self.myDir = cmds.fileDialog2 (fileFilter=basicFilter,
> dialogStyle=2, fm=3)
> myFiles = listdir(self.myDir[0])
>
> for items in myFiles:
> fileEndings =
> ('.psd','.PSD','.jpg','JPG','.jpeg','.JPEG','.tga','.TGA','.png','.PNG','.tiff','.TIFF','.bmp','.BMP')
> if items.endswith(fileEndings):
> cmds.menuItem(items)
> else:
> cmds.warning(items + 'This is not a valid image type, you
> fool.')
>
> print myFiles
>
>
> def applyShaderBtnCmd(self, *args):
> print 'shader button pressed'
>
>
> myTextureRelink = AK_TextureLink()
>
>
>
> Thank you!
>
>
>
> --
> 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/56aac8d9-9eaa-47a9-a8e4-f81c6bb70e57n%40googlegroups.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 

[Maya-Python] News: Additional Manager for Group

2021-06-01 Thread Justin Israel
Hi Everyone!

I wanted to let you all know that there is now an additional Manager for 
this group. 
Marcus Ottosson has been a very active and valuable contributor to the 
group since Aug 2010. I'm happy to report that Marcus has accepted my 
request to share the responsibility of approving new members and smashing 
spam!

Thank you Marcus!

Justin

-- 
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/8c46a255-c2e4-47c1-9620-fafe24bfcc85n%40googlegroups.com.


Re: [Maya-Python] Desperately trying to run matplotlib

2021-05-24 Thread Justin Israel
On Tue, 25 May 2021, 5:41 am justin hidair,  wrote:

> here's the best I managed
> https://gist.github.com/yetigit/c2f55bdb8b1798b2936687567f9c6c1e



Looks like maybe the wrong Visual Studio C++ compiler for Maya 2020? In
addition to C++being difficult to build, combining that with Maya on
Windows is even harder.
I don't have much experience compiling on windows so maybe a windows user
will recognize the fix.
A quick look shows that Maya 2020 says it uses Visual Studio C++ 2017.


>
> On Monday, May 24, 2021 at 1:59:52 PM UTC+2 Marcus Ottosson wrote:
>
>> Could you post some of those error messages? Maybe someone here
>> recognises and could help resolve those.
>>
>> I don’t think there’s a silver bullet, each library build has its quirks
>> and challenges despite the community trying to adhere to standards there
>> are like massive disparities on how easy it is to build something versus
>> how confusing and annoying it is to build another
>>
>> I think we’ve got C and C++ to thank for this haha. Or rather, thank
>> Python for shielding us from the horrors of compiled software out there,
>> it’s hard to understate how much more accessible it makes programming for
>> this benefit alone. I bet anyone dabbling with C++ can attest to the pain
>> and recurrence of dependencies in everyday life. For a modern example, just
>> look at USD!
>>
>> That said, it’s certainly possible. One clue might be looking at how the
>> native Python packages are built for matplotlib.
>>
>>-
>>
>> https://github.com/matplotlib/matplotlib/blob/master/.github/workflows/cibuildwheel.yml
>>
>> The curveball Maya throws at you is that most build scripts out there
>> assume a system-wide install of Python, and makes hardcoded assumptions
>> about where to find libraries and headers. In a CI environment like that,
>> it wouldn’t be unreasonable to mount Maya’s files over the native ones, to
>> trick such build scripts into using the proper ones.
>>
>> On Mon, 24 May 2021 at 12:15, justin hidair  wrote:
>>
>>> re, yes forgot to mention my attempts at compiling it were made with
>>> mayapy.exe, still failed with opaque error messages
>>>
>>> I don't think there's a silver bullet, each library build has its quirks
>>> and challenges despite the community trying to adhere to standards
>>> there are like massive disparities on how easy it is to build something
>>> versus how confusing and annoying it is to build another
>>>
>>> On Monday, May 24, 2021 at 9:41:44 AM UTC+2 Marcus Ottosson wrote:
>>>
 This topic is so common it really needs to be highlighted somewhere.
 Maybe as a new Maya splash screen? xD

 [image: notcompatible]

 The problem though is that many packages *are* compatible, it’s only
 the compiled packages that are not. So it’s understandable that it keeps
 getting confused. Can only imagine the number of hours lost trying to
 shoehorn PyPI into Maya, and the subsequent number of hours struggling with
 random crashes due to *suceeding* to shoehorn it in; when it seems to
 work - like NumPy sometime does - but really shouldn’t.

 I even tried to compile it although failing countless times at that .

 The trick is compiling it with *Maya’s* Python, it’s the only way. In
 most cases it really needs to be mayapy, since it itself was built
 with a different compiler than the one on python.org. The same
 compiler as Maya was built with, and the same compiler your library needs
 to be built with. Which is why you most often also need a separate build
 for each major version of Maya, see the development docs for which compiler
 version they use and when they switch. Some versions of Maya use the same.

 I was looking for an example of how PyQt is compiled for Maya that
 isn’t too convoluted. The process would be similar here. The closest one I
 can find that contains each step is this.

-
https://github.com/pyqt/python-qt5/wiki/Compiling-PyQt5-on-Ubuntu-12.04

 Replacing any mention of python with mayapy and (optionally, but
 safest) explicitly passing Maya’s Python headers to configure.py or
 setup.py etc.

 Maybe someone else has a guide on compiling *anything* for Maya
 specifically? It can be really hard, like NumPy, because of all the
 dependencies involved. But sometimes the light shines on you and it’ll be
 over before you know it.

 On Mon, 24 May 2021 at 06:20, Alok Gandhi  wrote:

> I think the only this would work is to compile it against the maya
> version you are using, unless there is some existing pre-built binaries
> that I am not aware of.
>
> Another approach, though very convoluted, would be to first create a
> system level command (one that you can run outside maya from any terminal
> and accepts data, returns the result), call it from maya using either a
> Popen or os.system.
>
> On Mon, May 24, 2021, 

Re: [Maya-Python] maya API ?? reading an external json file

2021-05-18 Thread Justin Israel
On Wed, May 19, 2021 at 7:21 AM Marcus Ottosson 
wrote:

> pybind11 is great, but it is incrdibly slow to compile. Like 20
> seconds for a handful of bound methods. It’s insane.
>
> That aside, I’ve got a recent project that might make a good example of
> what it is and how it can be used to re-create the Maya Python API.
>
>- https://github.com/mottosso/cmdc
>
>
Nice one! Well, slow compile time is probably better than carrying around a
boost dependency and dealing with symbol conflicts :-)


>
>
>
> On Tue, 18 May 2021 at 19:53, Alok Gandhi 
> wrote:
>
>> Thanks Justin! pybind definitely seems interesting.
>>
>> And yes, Cython is definitely great. I have used it in production
>> previously for some generic algorithms implementations where performance
>> was needed in python centric api interface. And it is super easy to write
>> too.
>>
>> On Tue, May 18, 2021, 23:58 Justin Israel  wrote:
>>
>>>
>>>
>>> On Wed, May 19, 2021 at 6:10 AM Alok Gandhi 
>>> wrote:
>>>
>>>> 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
>>>>
>>>
>>> Boost is a super heavy dependency. These days pybind11 might be a better
>>> choice if your project is C++ centric:
>>> https://github.com/pybind/pybind11
>>>
>>> It's header-only so you don't have to worry about boost version
>>> conflicts.
>>>
>>> And if you have a python-centric project, cython is pretty good for
>>> being able to call into C++. It also produces a library that has no runtime
>>> link dependency to anything since it transpiles to C and only links against
>>> Python.
>>>
>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, May 18, 2021, 23:30 Todd Widup  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#af47e37db0e53940620c6cd1fe41d>
>>>>>> or you can embed another Python yourself and call that. The latter would
>>>>>> have the benefit of not polluting

Re: [Maya-Python] maya API ?? reading an external json file

2021-05-18 Thread Justin Israel
On Wed, May 19, 2021 at 6:10 AM Alok Gandhi 
wrote:

> 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
>

Boost is a super heavy dependency. These days pybind11 might be a better
choice if your project is C++ centric:
https://github.com/pybind/pybind11

It's header-only so you don't have to worry about boost version conflicts.

And if you have a python-centric project, cython is pretty good for being
able to call into C++. It also produces a library that has no runtime link
dependency to anything since it transpiles to C and only links against
Python.


>
>
>
>
>
> On Tue, May 18, 2021, 23:30 Todd Widup  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 
>> 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
>>> ,
>>> which will let users browse for a file.
>>>
>>> Once you’ve got access to a path from C++, have a look at RapidJSON
>>>  or 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!')");
>>> 
>>> 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  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
 
 .

>>> --
>>> 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
>>> 
>>> .
>>>
>>
>>
>> --
>> 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 

Re: [Maya-Python] numpy errors fixed when reintializing maya

2021-05-02 Thread Justin Israel
On Mon, May 3, 2021 at 9:59 AM Rudi Hammad  wrote:

> no, I don't used reload(). To avoid using reload everywhere I use this.
> https://pastebin.com/sxhYQNTn


Hmm, but you are still trying to dynamically change the imported module
objects to force a re-import. Might not be related at all, but these
workflows don't play very nicely with compiled extensions (numpy) which
can't really be unloaded entirely from memory.


>
> El domingo, 2 de mayo de 2021 a las 23:45:59 UTC+2, justin...@gmail.com
> escribió:
>
>> Shot in the dark are you using python's reload() functionality
>> anywhere? Does it seem to break after some type of workflow operation?
>>
>> On Mon, May 3, 2021 at 9:38 AM Rudi Hammad  wrote:
>>
>>> I got the log error. Here it is:
>>>
>>> # ==
>>> # ERROR: test_average
>>> (domain._unittest.testmath.test_numeric.TestNumeric)
>>> # --
>>> # # Traceback (most recent call last):
>>> #   File "D:\domain\_unittest\testmath\test_numeric.py", line 8, in
>>> test_average
>>> # assert np.allclose(numeric.average(((0,-2), (1, 2))), [0.5, 0.0] ,
>>> atol=0.01)
>>> #   File "D:\domain\math\numeric.py", line 33, in average
>>> # averageList.append(np.average(_))
>>> #   File "C:\Program
>>> Files\Autodesk\Maya2018\Python\lib\site-packages\numpy\lib\function_base.py",
>>> line 514, in average
>>> # avg = a.mean(axis)
>>> #   File "C:\Program
>>> Files\Autodesk\Maya2018\Python\lib\site-packages\numpy\core\_methods.py",
>>> line 54, in _mean
>>> # arr = asanyarray(a)
>>> TypeError: 'NoneType' object is not callable
>>>
>>>
>>> Remember that this error was fixed on its own just by restarting maya.
>>> Any idea what could be happening?
>>>
>>> El sábado, 1 de mayo de 2021 a las 10:22:04 UTC+2, Juan Moraga escribió:
>>>
 I agree on what Marcus said, pip install Numpy is not reliable (from
 what I have experienced in the past anyway), at least for Maya 2018.7 (and
 I can imagine with MayaPy2.7 in general).

 Kind regards!

 On Sat, 1 May 2021, 07:40 Marcus Ottosson,  wrote:

> > I can use it with no problem, it is just a rare issue that happens
> sometimes.
>
> Ah, ok. The reason I ask is because this sounds like the kind of
> problems you would get with a version compiled for a different Python.
> Random, subtle, memory related. I would double-check where you got it 
> from,
> and make sure it was actually compiled for your version of Maya.
>
>
> On Fri, 30 Apr 2021 at 23:51, Rudi Hammad  wrote:
>
>> sure, I will.
>> I had a similar issue once at work. Not with numpy but with a unitest
>> when comparing matrices using MMatrix.isEquivalent(). In my computer all
>> the tests passed, so I pushed my code into the servered. But strangly
>> enough,
>> in my colleague computer the same code didn't passed. So we reduce
>> the tolerance argument, and then it passed. Almost like my cpu could 
>> handle
>> to compare the float percision but his couldn't.
>> So maybe it is maya messing thing is up depending on how the cpu is
>> feeling that day? I don't know
>>
>> El viernes, 30 de abril de 2021 a las 21:30:19 UTC+2, Alok Gandhi
>> escribió:
>>
>>> And as this is not reliably reproducible, and a restart seems to fix
>>> it for a while, I would not rule out any memory issues. Keep an eye on 
>>> the
>>> memory next time it happens.
>>>
>>> On Sat, May 1, 2021, 00:04 Marcus Ottosson 
>>> wrote:
>>>
 Did you happen to get NumPy from PyPI, via pip install? There was
 a thread here about it not long ago, but the bottom line is if you 
 haven’t
 got a version compiled specifically for your version of Maya, it won’t
 behave.

 On Fri, 30 Apr 2021 at 18:20, Rudi Hammad 
 wrote:

> I'll let you know when the error happens again, since I don't know
> how to cause it. I think it is something related to can't do what 
> ever with
> None, or something referencing a built-in numpy method.
> I know this doesn't help so when  it happens again, I'll post it.
>
> El viernes, 30 de abril de 2021 a las 17:34:22 UTC+2, Alok Gandhi
> escribió:
>
>> And what are the errors? Any logs?
>>
>>
>> On Fri, Apr 30, 2021 at 8:27 PM Rudi Hammad 
>> wrote:
>>
>>>
>>> Hello,
>>>
>>> has anyone experienced this type of behavior working with numpy?
>>> I know my code is correct because I unitest method and all tests 
>>> pass. But
>>> from time to time, complety randomly, when i run the unitest I get 
>>> 17
>>> errors all related to methods that use numpy.
>>> When this 

Re: [Maya-Python] numpy errors fixed when reintializing maya

2021-05-02 Thread Justin Israel
Shot in the dark are you using python's reload() functionality
anywhere? Does it seem to break after some type of workflow operation?

On Mon, May 3, 2021 at 9:38 AM Rudi Hammad  wrote:

> I got the log error. Here it is:
>
> # ==
> # ERROR: test_average (domain._unittest.testmath.test_numeric.TestNumeric)
> # --
> # # Traceback (most recent call last):
> #   File "D:\domain\_unittest\testmath\test_numeric.py", line 8, in
> test_average
> # assert np.allclose(numeric.average(((0,-2), (1, 2))), [0.5, 0.0] ,
> atol=0.01)
> #   File "D:\domain\math\numeric.py", line 33, in average
> # averageList.append(np.average(_))
> #   File "C:\Program
> Files\Autodesk\Maya2018\Python\lib\site-packages\numpy\lib\function_base.py",
> line 514, in average
> # avg = a.mean(axis)
> #   File "C:\Program
> Files\Autodesk\Maya2018\Python\lib\site-packages\numpy\core\_methods.py",
> line 54, in _mean
> # arr = asanyarray(a)
> TypeError: 'NoneType' object is not callable
>
>
> Remember that this error was fixed on its own just by restarting maya. Any
> idea what could be happening?
>
> El sábado, 1 de mayo de 2021 a las 10:22:04 UTC+2, Juan Moraga escribió:
>
>> I agree on what Marcus said, pip install Numpy is not reliable (from what
>> I have experienced in the past anyway), at least for Maya 2018.7 (and I can
>> imagine with MayaPy2.7 in general).
>>
>> Kind regards!
>>
>> On Sat, 1 May 2021, 07:40 Marcus Ottosson,  wrote:
>>
>>> > I can use it with no problem, it is just a rare issue that happens
>>> sometimes.
>>>
>>> Ah, ok. The reason I ask is because this sounds like the kind of
>>> problems you would get with a version compiled for a different Python.
>>> Random, subtle, memory related. I would double-check where you got it from,
>>> and make sure it was actually compiled for your version of Maya.
>>>
>>>
>>> On Fri, 30 Apr 2021 at 23:51, Rudi Hammad  wrote:
>>>
 sure, I will.
 I had a similar issue once at work. Not with numpy but with a unitest
 when comparing matrices using MMatrix.isEquivalent(). In my computer all
 the tests passed, so I pushed my code into the servered. But strangly
 enough,
 in my colleague computer the same code didn't passed. So we reduce the
 tolerance argument, and then it passed. Almost like my cpu could handle to
 compare the float percision but his couldn't.
 So maybe it is maya messing thing is up depending on how the cpu is
 feeling that day? I don't know

 El viernes, 30 de abril de 2021 a las 21:30:19 UTC+2, Alok Gandhi
 escribió:

> And as this is not reliably reproducible, and a restart seems to fix
> it for a while, I would not rule out any memory issues. Keep an eye on the
> memory next time it happens.
>
> On Sat, May 1, 2021, 00:04 Marcus Ottosson 
> wrote:
>
>> Did you happen to get NumPy from PyPI, via pip install? There was a
>> thread here about it not long ago, but the bottom line is if you haven’t
>> got a version compiled specifically for your version of Maya, it won’t
>> behave.
>>
>> On Fri, 30 Apr 2021 at 18:20, Rudi Hammad  wrote:
>>
>>> I'll let you know when the error happens again, since I don't know
>>> how to cause it. I think it is something related to can't do what ever 
>>> with
>>> None, or something referencing a built-in numpy method.
>>> I know this doesn't help so when  it happens again, I'll post it.
>>>
>>> El viernes, 30 de abril de 2021 a las 17:34:22 UTC+2, Alok Gandhi
>>> escribió:
>>>
 And what are the errors? Any logs?


 On Fri, Apr 30, 2021 at 8:27 PM Rudi Hammad 
 wrote:

>
> Hello,
>
> has anyone experienced this type of behavior working with numpy? I
> know my code is correct because I unitest method and all tests pass. 
> But
> from time to time, complety randomly, when i run the unitest I get 17
> errors all related to methods that use numpy.
> When this happened the first time, I spent hours thinking what was
> happening, since I didn't modify anything and no matter how much i 
> looked
> into it everything looked totally okey.
> Then I used the best debuging tool, which is turn off and on again
> maya, and it was fixed.
>
> Since then, I don't waste my time anymore when i get this strange
> errors because i know it is not something wrong in my code. And
> reinitializing maya fix the issue.
> So I wonder if anyone has a similar experience.
>
> Could it be something related with a presicion that need to be set
> somewhere when using numpy? I always set a tolerance aroung 0.001, so 
> I am
> not taking a 

Re: [Maya-Python] docstring on obvious functions

2021-05-02 Thread Justin Israel
Alok makes a good point that "it depends". You can poll for opinions but
ultimately you have to make a decision about the project and just be
consistent.
I tend to lean towards the side of docstrings making it easier for the
reader to quickly pick up what they need to know about the
function/method/class, and it is not always the case that the docstring
would only say a short sentence that matches the name of the function. It
may need to describe other behaviours about the implementation. You should
not require that a user actually dive into the source code to know what
kind of exceptions the function might raise or when it decides to return a
certain value. And at that point, you should probably be consistent with
all the public symbols.

On Mon, May 3, 2021 at 7:56 AM Rudi Hammad  wrote:

>
> So you don't docstring protected or private methods ( understanding that
> there is no 'protected' or 'private'  in python, but that's another
> discussion). Protected methods are meant to be used in subclasses so I
> think you probably want to docstring them too. Maybe just skip private's
> docstring then?
>

I do add docstrings to private and protected functions if I think they need
some explanation for the reader, but I think its less required than members
of your public API.


>
> R
>
> El domingo, 2 de mayo de 2021 a las 21:27:18 UTC+2, justin...@gmail.com
> escribió:
>
>> My take is that I want to see docstrings on public functions (which as
>> you pointed out are different from comments).
>> One added benefit of writing a docstring is that doc generators like
>> sphinx, and IDEs, can produce helpful type linking and hinting. So if your
>> function takes a certain type and returns a certain type, you may be able
>> to get links to those types for more information. Also docstrings are
>> helpful for an IDE to perform type hinting in python2. I know that in
>> python3 we gain proper language-level type annotations, but for now we have
>> to do it through comments and docstrings in python2.
>>
>> It may be subjective for a developer to think
>> that calculate_inverse(matrix) "obviously" accepts a numpy ndarray as its
>> input type, and then chooses not to document it in a docstring. But what if
>> there are different types that could be considered a matrix object and it
>> is really not so obvious to someone reading the docs or the signatures and
>> only sees that your api expects a "matrix"? Better to just use the
>> appropriate docstring formats to add type information, until everything is
>> python3 and you can do it all via type annotations.
>>
>>
>> On Mon, May 3, 2021 at 6:30 AM Rudi Hammad  wrote:
>>
>>>
>>> This not strictly related to maya but I wonder how you feel about it.
>>> In sumary, I found my self in similar situations as this:
>>> docstring example
>>> 
>>>
>>> I think the link above isn't really answering what is was asked.
>>> He was asking about docstrings and people where responding to comments.
>>> I agree that unless necesarry your code shouldn't need any comments if you
>>> respect some programing princpiples. So you never find your self in long
>>> functions that requieres explanations with comments.
>>>
>>> But what about the docstring in that example? If you are methodic in
>>> your documentation and document everything, you will end up many times
>>> writing docstrings longer than the functions it self. I don't think it is
>>> something bad,  just annoying.
>>> Also some programs generate automatically documentation for your api.
>>> For instance I use sphinx-doc and all exisiting docstrings are parsed and
>>> nicely documented automatically.
>>>
>>> what is your take on this?
>>>
>>> R
>>>
>>> --
>>> 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_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/01a95b10-0d22-424d-9d10-b8642efbfab9n%40googlegroups.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/fb391bd2-1019-4be7-9eae-07aa42d12589n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are 

Re: [Maya-Python] docstring on obvious functions

2021-05-02 Thread Justin Israel
My take is that I want to see docstrings on public functions (which as
you pointed out are different from comments).
One added benefit of writing a docstring is that doc generators like
sphinx, and IDEs, can produce helpful type linking and hinting. So if your
function takes a certain type and returns a certain type, you may be able
to get links to those types for more information. Also docstrings are
helpful for an IDE to perform type hinting in python2. I know that in
python3 we gain proper language-level type annotations, but for now we have
to do it through comments and docstrings in python2.

It may be subjective for a developer to think
that calculate_inverse(matrix) "obviously" accepts a numpy ndarray as its
input type, and then chooses not to document it in a docstring. But what if
there are different types that could be considered a matrix object and it
is really not so obvious to someone reading the docs or the signatures and
only sees that your api expects a "matrix"? Better to just use the
appropriate docstring formats to add type information, until everything is
python3 and you can do it all via type annotations.


On Mon, May 3, 2021 at 6:30 AM Rudi Hammad  wrote:

>
> This not strictly related to maya but I wonder how you feel about it.
> In sumary, I found my self in similar situations as this:
> docstring example
> 
>
> I think the link above isn't really answering what is was asked.
> He was asking about docstrings and people where responding to comments. I
> agree that unless necesarry your code shouldn't need any comments if you
> respect some programing princpiples. So you never find your self in long
> functions that requieres explanations with comments.
>
> But what about the docstring in that example? If you are methodic in your
> documentation and document everything, you will end up many times writing
> docstrings longer than the functions it self. I don't think it is something
> bad,  just annoying.
> Also some programs generate automatically documentation for your api. For
> instance I use sphinx-doc and all exisiting docstrings are parsed and
> nicely documented automatically.
>
> what is your take on this?
>
> R
>
> --
> 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/01a95b10-0d22-424d-9d10-b8642efbfab9n%40googlegroups.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/CAPGFgA2MmtAPei1x2rWGzPD6YkjqsTMdxNKBeGLt3-u0GgwMVw%40mail.gmail.com.


Re: [Maya-Python] C++ speed/efficiency in Maya

2021-04-06 Thread Justin Israel
On Tue, 6 Apr 2021, 5:53 pm Marcus Ottosson,  wrote:

> In many cases, MEL should be faster than pure python
>
> I thought so too!
>
> But to my great surprise, for a lot of common operations - like createNode,
> getAttr and setAttr - MEL was consisteny *significantly slower* than cmds.
>
>- https://github.com/mottosso/cmdx#timings
>
> These were done in Maya 2015, so it’s possible but unlikely things have
> changed since then. There’s a script in there to reproduce the results
> (independent of cmdx).
>

Ya totally. I should have emphasized the point even more that "it depends".
On measuring individual function calls, you may find that an OpenMaya api
call through python is faster. Mel is likely faster in comparing basic
language constructs like loops. But the calls into the Maya api depend on
how they are backed by C++
All one can really do is test actual cases. Specific function calls may
have their own micro benchmark timings. I came across this earlier today:
https://www.diva-portal.org/smash/get/diva2:1334763/FULLTEXT02



> On Tue, 6 Apr 2021 at 02:52, Justin Israel  wrote:
>
>>
>>
>> On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma 
>> wrote:
>>
>>> Always wondered if mel or derivative of C# basically is faster than py?
>>> Or as they are both script languages perhaps not much different.
>>>
>>
>>
>> In many cases, MEL should be faster than pure python, because it is a
>> much more limited and special purpose scripting language implemented for
>> Maya. Static typing and less language constructs mean it should have less
>> overhead to execute after it is parsed. But when comparing these things you
>> would have to account for the fact that a lot of function calls in python
>> are backed by C, so it depends what you are doing.
>> Also, while MEL might be faster in some cases, it is also not as
>> convenient as Python when it comes to having more libraries and utilities
>> at your disposal, and better integration with your development environment.
>> MEL is really just glue code for calling all of the pre-built functions.
>>
>>
>>>
>>> *From:* python_inside_maya@googlegroups.com [mailto:
>>> python_inside_maya@googlegroups.com] *On Behalf Of *Justin Israel
>>> *Sent:* Monday, April 05, 2021 4:01 PM
>>> *To:* python_inside_maya@googlegroups.com
>>> *Subject:* Re: [Maya-Python] C++ speed/efficience in Maya
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tue, Apr 6, 2021 at 8:32 AM João Victor 
>>> wrote:
>>>
>>> Hey guys,
>>>
>>> Could somebody help me in some doubt?
>>>
>>> How faster C++ could be in Maya, compared to python API in general?
>>>
>>> Is this something that worth to work with for what kind of programs
>>> (generally)?
>>>
>>>
>>>
>>> Python is considered a relatively "slow" language, compared to C++.
>>> Because python is dynamically typed and interpreted, there is a lot more
>>> overhead involved with every variable access or function call, where python
>>> has to look up attributes and check types. A language like C++ is
>>> statically typed and compiled, so most of that overhead is gone since it
>>> has been determined at compile time.
>>>
>>>
>>>
>>> In terms of real world speed differences, and even more specifically to
>>> Maya, that will come down to what operations you are really doing. If you
>>> were to create a loop that runs over all points on a mesh, that could
>>> definitely be slower in python. C++ helps when there are critical sections
>>> of your code where performance must be very high, and profiling your code
>>> can tell you where the slow spots exist.
>>>
>>>
>>>
>>> There is also a difference between using the Maya Commands module, vs
>>> using the Maya API that wraps the C++ sdk. More of the heavy lifting is
>>> moved into the C++ side when using the Maya API, whereas using the Maya
>>> commands has more python overhead.
>>>
>>>
>>>
>>> You could write a deformed in Python, but you might find it performs too
>>> slowly and then needs to be rewritten in C++. However, Python does help to
>>> speed up prototyping time and figure out where performance problems
>>> actually exist. On the other hand, you could write UI code or file
>>> translators, or renamers, or validators in Python and never see a need for
>>> C++ in those tools.
>>>
>>>

Re: [Maya-Python] C++ speed/efficiency in Maya

2021-04-05 Thread Justin Israel
On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma  wrote:

> Always wondered if mel or derivative of C# basically is faster than py?
> Or as they are both script languages perhaps not much different.
>


In many cases, MEL should be faster than pure python, because it is a much
more limited and special purpose scripting language implemented for Maya.
Static typing and less language constructs mean it should have less
overhead to execute after it is parsed. But when comparing these things you
would have to account for the fact that a lot of function calls in python
are backed by C, so it depends what you are doing.
Also, while MEL might be faster in some cases, it is also not as convenient
as Python when it comes to having more libraries and utilities at your
disposal, and better integration with your development environment. MEL is
really just glue code for calling all of the pre-built functions.


>
> *From:* python_inside_maya@googlegroups.com [mailto:
> python_inside_maya@googlegroups.com] *On Behalf Of *Justin Israel
> *Sent:* Monday, April 05, 2021 4:01 PM
> *To:* python_inside_maya@googlegroups.com
> *Subject:* Re: [Maya-Python] C++ speed/efficience in Maya
>
>
>
>
>
>
>
> On Tue, Apr 6, 2021 at 8:32 AM João Victor 
> wrote:
>
> Hey guys,
>
> Could somebody help me in some doubt?
>
> How faster C++ could be in Maya, compared to python API in general?
>
> Is this something that worth to work with for what kind of programs
> (generally)?
>
>
>
> Python is considered a relatively "slow" language, compared to C++.
> Because python is dynamically typed and interpreted, there is a lot more
> overhead involved with every variable access or function call, where python
> has to look up attributes and check types. A language like C++ is
> statically typed and compiled, so most of that overhead is gone since it
> has been determined at compile time.
>
>
>
> In terms of real world speed differences, and even more specifically to
> Maya, that will come down to what operations you are really doing. If you
> were to create a loop that runs over all points on a mesh, that could
> definitely be slower in python. C++ helps when there are critical sections
> of your code where performance must be very high, and profiling your code
> can tell you where the slow spots exist.
>
>
>
> There is also a difference between using the Maya Commands module, vs
> using the Maya API that wraps the C++ sdk. More of the heavy lifting is
> moved into the C++ side when using the Maya API, whereas using the Maya
> commands has more python overhead.
>
>
>
> You could write a deformed in Python, but you might find it performs too
> slowly and then needs to be rewritten in C++. However, Python does help to
> speed up prototyping time and figure out where performance problems
> actually exist. On the other hand, you could write UI code or file
> translators, or renamers, or validators in Python and never see a need for
> C++ in those tools.
>
>
>
>
>
>
>
> Thanks in advance!
>
> --
> 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/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com?utm_medium=email_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/CAPGFgA26Nns6Nt9NYDvgF0YrhH_8B%3D77rgVQmkSyA32gcz9PgA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA26Nns6Nt9NYDvgF0YrhH_8B%3D77rgVQmkSyA32gcz9PgA%40mail.gmail.com?utm_medium=email_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/003e01d72a76%24bc9e2fb0%2435da8f10%24%40gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/003e0

  1   2   3   4   5   6   7   8   9   10   >