Re: [Maya-Python] Re: transfer vertex ids between different

2021-06-22 Thread Alok Gandhi
t;>> where you have a mesh cut out of the head for the facial rig, that you >>>> blendshape into the full body mesh. So there you have 2 different >>>> topologies. In maya you can do a blendshape between different topologies >>>> but if the ids don't match you

Re: [Maya-Python] Re: transfer vertex ids between different

2021-06-22 Thread Alok Gandhi
22, 2021 at 2:05 PM Rudi Hammad wrote: > It looks similar to maya's transfer attribute tool, but it doesn't look to > do a vertex id transfer. > > El martes, 22 de junio de 2021 a las 9:53:25 UTC+2, Alok Gandhi escribió: > >> There was GATOR >> <https://dow

Re: [Maya-Python] Re: transfer vertex ids between different

2021-06-22 Thread Alok Gandhi
There was GATOR is Softimage XSI that could handle such cases as yours. I remember vaguely that it was being worked upon in Maya (since the Softimage dev team was

Re: [Maya-Python] accurate bezier curve fitting

2021-06-01 Thread Alok Gandhi
This might be a useful read maybe? https://raphlinus.github.io/curves/2021/03/11/bezier-fitting.html On Tue, Jun 1, 2021 at 6:20 PM vince touache wrote: > hello, > > I was looking for an algorithm to predict the best Bezier curve, given a > vector of points. I ended up implementing "An

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

2021-05-23 Thread Alok Gandhi
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

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

2021-05-18 Thread Alok Gandhi
: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/l

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

2021-05-18 Thread Alok Gandhi
As a side note, for generic use (outside of maya) you can use boost python to call python from C++ and vice versa: https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/index.html On Tue, May 18, 2021, 23:30 Todd Widup wrote: > Thanks Marcus, > the txt file will be just a bunch

Re: [Maya-Python] another naming convention topic: get prefix on none getter methods

2021-05-11 Thread Alok Gandhi
I have generously used prefix for methods 'get' without any 'set'. I think there is no convention and my code readability is generally dictated by common sense and ease of understanding. Another point is that functions/methods sgould always be verbs as long as possible. So pointPositions() to me

Re: [Maya-Python] Creating .bat file (launcher) for maya

2021-05-07 Thread Alok Gandhi
There you go: https://en.m.wikibooks.org/wiki/Windows_Batch_Scripting On Fri, May 7, 2021, 20:52 Vlad Afanasjev wrote: > Hmmm... I was looking into some generic tutorials. > Like how to set variables, set path, make conditions ('if', 'else'), how > to run side scripts like python. > Because

Re: [Maya-Python] Maya 2022 and output windows

2021-05-07 Thread Alok Gandhi
At least on latest macOS Big Sur, the print to console still works without the need to use flush() Additionally, setting the env var *PYTHONUNBUFFERED* to a non empty value would cause the output to go to the terminal without being buffered. On Fri, May 7, 2021, 11:12 Marcus Ottosson wrote: >

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

2021-05-02 Thread Alok Gandhi
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

Re: [Maya-Python] docstring on obvious functions

2021-05-02 Thread Alok Gandhi
I wouldn't say you can comoletely ignore private methods while documenting your code. It would save a lot of time(and pain) for the maintainer, whether it's you reading it after 3 months or somebody else for that matter. On Mon, May 3, 2021, 01:26 Rudi Hammad wrote: > Cool, thanks for your

Re: [Maya-Python] docstring on obvious functions

2021-05-02 Thread Alok Gandhi
I would say it depends on the use case. The best practice is always to name things explicitly so you do not need docs (or comments). On that note, there was a movement called extreme programming (XP) in the late 90's that advocated use of no comments at all, amongst other things. Anyway; having

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

2021-04-30 Thread Alok Gandhi
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

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

2021-04-30 Thread Alok Gandhi
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

Re: [Maya-Python] Controlled Class instantiation with multiple constructors

2020-04-16 Thread Alok Gandhi
ombining classmethod and __new__, you would have to > implement your classmethod to also use super().__new__ so that it doesn't > call the constructor. But that is a bit unintuitive if it is a public > classmethod. So maybe you should define private class methods that can be > called by your __n

Re: [Maya-Python] Controlled Class instantiation with multiple constructors

2020-04-15 Thread Alok Gandhi
Python @classmethod were added for this exact reason - Alternative Contructors. class Foo(object): def __init__(self, bar=None, baz=None): self._bar = bar self._baz = baz print 'bar: {}, baz: {}'.format(self._bar, self._baz) @classmethod def from_bar(cls,

Re: [Maya-Python] PyQt - Gui contents got resized but not the window

2019-11-22 Thread Alok Gandhi
In addition to what Justin said, if it is a standalone window and you do not that extra space to show up, the set the size of your main application window to the fixed size and remove the fix size from the widget, so it expands to fill your application window. On Sat, Nov 23, 2019, 13:35 Justin

Re: [Maya-Python] Requests module inconsistent

2019-09-10 Thread Alok Gandhi
I agree with Justin. In our pipeline, we use a host of python package as thirdparty pieces. We have developed our own package manager and make the dependencies available from inside any dcc app environment. Using modules that ships with any dcc can become a scalability issue pretty soon as they

Re: [Maya-Python] plug-in "anti hacking" measures.

2018-08-04 Thread Alok Gandhi
> > you spent a year developing a muscle plugin system. So you spend a year > studying math, anatomy and any other useful resources to finally write your > plugin from scratch. Would you not consider that intellectual property? This definitely constitutes an IP. Not talking about the

Re: [Maya-Python] dynamically changing sys.path

2018-07-27 Thread Alok Gandhi
.. is this a general > behaviour of compiled libraries? > > > 2018-07-27 3:35 GMT+02:00 Alok Gandhi : > >> Try using importlib <https://docs.python.org/2/library/importlib.html>or >> imp <https://docs.python.org/2.7/library/imp.html> >> >> Altho

Re: [Maya-Python] dynamically changing sys.path

2018-07-26 Thread Alok Gandhi
Try using importlib or imp Although, as Justin has already pointed out, it is not recommended to use reload in production code or to dynamically append/insert paths in sys.path. Give more thought to

Re: [Maya-Python] Parallel Evaluation Examples

2018-05-22 Thread Alok Gandhi
Tons of valuable information here. This is all gold to someone who wants to dig. Thanks all for the insights and kudos for Marcus for clear, to-the-point examples and investigation. Cheers! - Alok On Tue, May 22, 2018 at 6:42 PM, Marcus Ottosson wrote: > I’ve added

Re: [Maya-Python] VertexConstraint

2018-05-20 Thread Alok Gandhi
Generally, it is advised to use C++ for querying vertex data, python is definitely slower (than C++) at computing mesh data, especially when the data set is large. You can further test by running this against a simple cube or sphere. You should see higher fps. On Sun, May 20, 2018 at 8:51 PM,

[Maya-Python] Mayapy crashes while loading scene file with locked references (maya 2017 update 4)

2018-04-24 Thread Alok Gandhi
mayapy segfaults when trying to scene files with references locked (not attributes but the ref node itself is locked) Maya Version: Autodesk Maya 2017 Update 4 Repro: 1. Create a file reference(any maya file, contents do not matter) in an empty maya scene. 2. Right-click on the

Re: [Maya-Python] Re: Tagging MB files with metadata

2018-02-12 Thread Alok Gandhi
Why not use the fileInfo() to store the data? Can be read outside maya as well by parsing the ma/mb Sent from my iPhone > On 12-Feb-2018, at 00:10, Juan Cristóbal Quesada > wrote: > > following your attempts at using cPickle in mb files which seems interesting >

Re: [Maya-Python] Re: python list sorting issue

2017-11-07 Thread Alok Gandhi
Being really picky, please do not use lambda in a variable (PEP8) - Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier. Yes: def f(x): return 2*x No: f = lambda x: 2*x The first form means that the name of the resulting

Re: [Maya-Python] python list sorting issue

2017-11-05 Thread Alok Gandhi
use: tmp_list = list[:] this will create a copy instead of a reference. Also `list` is a python object type name, use 'list_' as variable name instead of `list` On Sun, Nov 5, 2017 at 7:37 PM, Virbhadra Gupta wrote: > > > i was trying to sort list by only 0 and other

Re: [Maya-Python] Re: Access Maya UI in Qt way using Python API

2017-09-12 Thread Alok Gandhi
Great! Also in the same folder of examples, you will find a script editMayaWidgets.py that does exactly what you need. Btw, all of these can also be found on github (maya 2016 only), Maya 2017 is available as a free download on Autodesk AppExchange

Re: [Maya-Python] scripting and progrming

2017-08-16 Thread Alok Gandhi
To me, the biggest difference between scripting and programming is this - Scripting - Automate the execution of a task that can be ALTERNATIVELY EXECUTED ONE-BY-ONE A HUMAN OPERATOR (from Wikipedia ) Programming - Everything else you do to send

Re: [Maya-Python] Check and grab the latest value of a certain condition using dictionary

2017-07-11 Thread Alok Gandhi
> > True. Although imagine that the model data is likely to have more fields > than just a status. It seems it would become difficult to support this > model when it contains other types of info. Otherwise you would have to > maintain this as an additional "index" model, and keep it up to date

Re: [Maya-Python] Check and grab the latest value of a certain condition using dictionary

2017-07-10 Thread Alok Gandhi
If you consider creating the model data dict having status as the keys then the whole search becomes increasingly simple: # Force an order for status search STATUS_SEARCH_ORDER = ('Approved', 'In Progress', 'Pending', 'In Use') def get_model(model_data): model = None model_status = None

Re: [Maya-Python] Getting pointer to qmainwindow returns nothing (maya2017+)

2017-06-23 Thread Alok Gandhi
use uuid to give a unique name - '_' + uuid.uuid4().hex On Fri, Jun 23, 2017 at 11:46 PM, Lidia Martinez wrote: > I'm trying to setup a scriptJob for a Qt window. > But in order to do that, I need the name of the window in the UI hierarchy. > > You probably know, we can

Re: [Maya-Python] I create the Shelf,Maya prompts an error # Error: unexpected character after line continuation character # ????

2017-06-18 Thread Alok Gandhi
You need to put quotes in your scripts. Something like this: "win = 'test'\nif mc.window(win, exists=True):\n mc.deleteUI(win)\n" Otherwise, \n is treated as a literal, not a new line character. On Mon, Jun 19, 2017 at 3:28 AM, Eri wrote: > Hi: > > > I ran using a script

Re: [Maya-Python] AABB intersect

2017-05-17 Thread Alok Gandhi
Can you elaborate more on what is not working with your code. There are a lot of algorithms for axis aligned bounding box and ray intersections. This is a good resource for such algorithms. Also, I see that your function is either returning

Re: [Maya-Python] declaring variables on top of the function?

2017-05-17 Thread Alok Gandhi
It depends. Usually, you would declare the variable in __init__(). It has two advantages: 1. Your code becomes more readable and easy to understand. Looking at the __init__() one can tell right away what variables will be used. 2. All the methods using that variable anywhere in the class will have

Re: [Maya-Python] MFnAnimCurve building

2017-05-16 Thread Alok Gandhi
Can you be more specific with the type of change? Is it the slope of the tangents, their length or something else that changes? I think setAngle()

Re: [Maya-Python] ImportError when running terminal command in maya standalone

2017-05-16 Thread Alok Gandhi
Also, this does not solve your problem but is relevant, just so you know, import pymel.core will take care of the initialization in one line, you read more about it here . But if you want to be more explicit about

Re: [Maya-Python] protecting python code

2017-05-15 Thread Alok Gandhi
As already pointed out above, there is no reliable way other than compiling (using cython), to protect your source code. Here's a crazy idea, and I am just thinking aloud so this might sound stupid - - Why not encrypt all your python code as plain text files. - The source files can be

Re: [Maya-Python] Flowchart diagram

2017-05-14 Thread Alok Gandhi
I do it all the time. Here's my process - - I start with rough sketches drawn by hand on paper representing the architecture. Usually, these are UML's - When I have coded a fair bit, I use PyNSource to generate the UML's.

Re: [Maya-Python] declaring variables on top of the function?

2017-05-12 Thread Alok Gandhi
I prefer and use the second one. On Fri, May 12, 2017 at 7:36 PM, Rudi Hammad wrote: > Hello, > quick question. Do you declare the variables on top of the function like > this: > > def myFunc(): > """The description""" > listA = [] > listB = [] > > ''' >

Re: [Maya-Python] Re: Nearest Point On Mesh in Maya

2017-05-05 Thread Alok Gandhi
The little apostrophe character you're using should be `, not ' On a US keyboard, that's the key above Tab. I don't know what it's called (and I've never seen it used for anything other than MEL). Use of backticks (``) is rare in python, but they are legal in python 2.x (deprecated in python 3)

Re: [Maya-Python] using * as variable value

2017-04-07 Thread Alok Gandhi
Just to reiterate, use this, it will work and is much simpler: def delcube(self, *args): todelete = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False) for obj in todelete: try: cmds.delete(obj) except ValueError: # Shape Node already deleted

Re: [Maya-Python] using * as variable value

2017-04-07 Thread Alok Gandhi
> > I tried to use this snippet but it does not work..It does not give any > error but it does not pass the functionality to the button .but if I use > myobj==myobj like old one .it works.even though it is working but still not > satisfied. i'm curious. Look at my last post above, it exactly

Re: [Maya-Python] using * as variable value

2017-04-07 Thread Alok Gandhi
> > I still don't understand comparison between the current item from the > selection and "myObj*". Can objects actually have a literal * in their name > in Maya? When would this check actually pass? You are right. `*` will have no effect in python. There's a bug. using: myobj = 'myCube*' and

Re: [Maya-Python] using * as variable value

2017-04-07 Thread Alok Gandhi
Ah and I forgot to mention, you should not use `myobj` for both the pattern matching and object in selection. It makes the code less clear. Better to use some other name. Here's what I suggest: def delcube(self, *args): sel = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False)

Re: [Maya-Python] using * as variable value

2017-04-07 Thread Alok Gandhi
> > > I use the bug to ignore the error warning that i received .. like this ## > Error: ValueError: file line 14: No object matches name: > myCube1Shape # > not sure whether I did the right thing or misuse the handling exceptions. It is perfectly ok to `pass` exceptions if you know what you

Re: [Maya-Python] Re: Calculate Vector

2017-04-01 Thread Alok Gandhi
erratum: 2. Cross the normal and the tangent to *obtain the bitangent. -- 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] Re: Calculate Vector

2017-04-01 Thread Alok Gandhi
Given a surface normal, the choice for a tangent vector is arbitrary for a flat surface. You have the freedom to decide the direction of the tangent vector. In your case, the tangent vector can be defined from the base point of the normal to any arbitrary point on the polygon, this can be the

Re: [Maya-Python] protecting python code

2017-03-26 Thread Alok Gandhi
> > some of them, they tend to zip up the source and wrap it into an > executable that handles extracting and running it in a reproducible way. > But I was never under the impression that it was a reliable way to hide it. That is true. I agree that ultimately compiling is the only reliable way

Re: [Maya-Python] protecting python code

2017-03-26 Thread Alok Gandhi
The only reliable way to hide your source code is to compile it. Some of the tools that can do this are: freeze , PyInstaller , Py2Exe , Squeeze

Re: [Maya-Python] Command flag in symbolButton keeps erroring for me

2017-03-13 Thread Alok Gandhi
> > I will get `# Error: TypeError: file line 9: Invalid > arguments for flag 'changeCommand'. Expected string or function, got > NoneType # ` > You need to pass the function object to change commands, currently you are passing the result of calling greet(). I think this should work for you:

Re: [Maya-Python] Re: conforming lines to 80 characters limits

2017-02-27 Thread Alok Gandhi
PEP8 stresses on increasing readability. When a line of code is long, it tends to bring in noise, thereby increasing cognitive burden on the reader. The reader has to invest more concentration into reading and comprehension. To reduce this burden, it is advised to keep the line shorter than 80

Re: [Maya-Python] Re: conforming lines to 80 characters limits

2017-02-26 Thread Alok Gandhi
@Justin: Just a side note to your example (though not a big deal): cbk = lambda *args: self.setupCallback("uiSetupNormalCol", True) It is not advised to assign lambda expressions to variables. It beats the whole purpose using the lambda in the first place.

Re: [Maya-Python] conforming lines to 80 characters limits

2017-02-26 Thread Alok Gandhi
I agree with Justin. Personally, I would slightly change this to (which is PEP8 compliant): self.uiSetupNormalSmooth = cmds.radioButton( label='Geometry normal', align='right', onCommand=lambda*args: self.setupCallback( "uiSetupNormalCol", True, ),) -- You

Re: [Maya-Python] Subprocess and deadlock

2017-02-22 Thread Alok Gandhi
And for completeness also pass creationflags=DETACHED_PROCESS in Popen(). On Wed, Feb 22, 2017 at 7:28 PM, Alok Gandhi <alok.gandhi2...@gmail.com> wrote: > Hi Marcus, > > I am not sure if this will surely help, but you can set `close_fds=True` > in subprocess.Pop

Re: [Maya-Python] bakeresults in Python is super slow

2016-12-25 Thread Alok Gandhi
And then there is atom -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya"

Re: [Maya-Python] Re: Trying to make a dict in python from hierarchy

2016-12-15 Thread Alok Gandhi
dard library diff tool library - difflib <https://docs.python.org/2/library/difflib.html>. It can do the heavy lifting for you. I cannot personally vouch for it as I have not used it in production. On Thu, Dec 15, 2016 at 9:16 PM, Alok Gandhi <alok.gandhi2...@gmail.com> wrote: > @rive

Re: [Maya-Python] Re: Trying to make a dict in python from hierarchy

2016-12-15 Thread Alok Gandhi
@river - Start simple (if you do not have any rudimentary pipeline setup). In designing pipeline (and eventually tooling for it) you need to start light but solid with some fundamental principles incorporated. *Core Tenets* Three things are of fundamental importance - Scalability, Reliability,

Re: [Maya-Python] Re: Trying to make a dict in python from hierarchy

2016-12-15 Thread Alok Gandhi
Yea I guess, Justin's post was added to mine while replying. I should have trimmed. On Thu, Dec 15, 2016 at 6:26 PM, Neil Roche wrote: > Hi River, > > Out of interest why does your shading model have different naming to your > animation model? At our studio when the rig is

Re: [Maya-Python] Re: Trying to make a dict in python from hierarchy

2016-12-14 Thread Alok Gandhi
@river: Here's a gist that you might found helpful: https://gist.github.com/hrldcpr/2012250 On Thu, Dec 15, 2016 at 6:19 AM, Justin Israel wrote: > Couple questions... > > Is it a problem to use a defaultdict vs a stdlib dict? The benefit is just > simplifying the need

Re: [Maya-Python] Exclude QFileSystemModel.setNameFilters

2016-12-02 Thread Alok Gandhi
Might I also suggest more pythonic and performant code: fileType = self.sourceModel().fileInfo(idx).suffix() return fileType not in self._excludes On Fri, Dec 2, 2016 at 4:21 PM, Justin Israel wrote: > Sure you can do it like that. It will work fine for testing

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-29 Thread Alok Gandhi
wanted to go in detail because of the first question being asked by someone > trying to learn and probably all this is already very confusing to him. > > Anyway, I feel lke this is going nowhere and I will politelly retire from > this thread. > Good luck! > > On Sat, Oct 29,

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-29 Thread Alok Gandhi
stance just > to destroy it later on without doing any work (contributing to solve the > problem the programmer is trying to solve) is a bit wasteful and I would > not recommend it as good practice to someone trying to learn. > > On 29 Oct 2016 1:21 PM, "Alok Gandhi" <alok.gan

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-28 Thread Alok Gandhi
> > What's the "dounder init method"? Did I miss some code somewhere? I think Cesar is referring to the 'double-underscore' aka 'dunder ' aka 'magic methods' aka 'special methods'- def __init__() On Sat, Oct 29, 2016 at 9:30 AM, Justin Israel wrote: > > > On Sat, Oct

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-27 Thread Alok Gandhi
> > I am not very familiar with using the underscores, in this case, public > and private variables, as a matter of fact. If you read my code, pretty > much everything is not of private variables. Sure, I understand. Please note that nothing is really private in python. There is nothing to

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-27 Thread Alok Gandhi
Sorry about the slight typo in the last code I posted, should be super(HierarchyDialog, self).__init__(parent=parent) -- 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

Re: [Maya-Python] Using strings as a check in __init__?

2016-10-26 Thread Alok Gandhi
Most of what I wanted to comment is already covered by Justin and Marcus. Here are my very very minor comments (consider them as extras): 1. self._state instead self.state (~ by convention, self.state should be used only if `state` is public. From your code, and I presume, `state` is not public.

Re: [Maya-Python] [python] which library using to read / write huge amount of data

2016-10-05 Thread Alok Gandhi
> > Generally speaking, binary compressed data would help in faster io. Just expand a bit on this, I have successfully used modules like gzip (for compression / decompression) and struct (reading/ writing

Re: [Maya-Python] [python] which library using to read / write huge amount of data

2016-10-05 Thread Alok Gandhi
Generally speaking, binary compressed data would help in faster io. On Wed, Oct 5, 2016 at 2:13 PM, Marcus Ottosson wrote: > Before getting into how to make something fast, I must point out that your > journey towards performance is meaningless without having something

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-25 Thread Alok Gandhi
> > Thanks Alok. > See, some people think that, because they have a lot experience and > talent(like marcus, and obviously he is very talented), they have they > right to insult, using sarcastic comments, the people who are learning and > asking questions. > ( or maybe it is just with me, who

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-25 Thread Alok Gandhi
> > And I don´t think it is uglier Both are readable for sure, I agree, 120 is not bad at all. It is good to see that you put some thought not only what your code does but also how does it look. Just another piece of advise - For the perspective of version control system in particular, there is

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-25 Thread Alok Gandhi
> > Strawberry isn't wrong. But tastes differ, and best you can do is cook > something that the largest amount of family members will like. @marcus: My apologies but I fail to get the point. Is it for or against the use of PEP-8? On Sun, Sep 25, 2016 at 10:35 PM, Marcus Ottosson

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-25 Thread Alok Gandhi
> > The 80 characters per line, is definitely crazy When I started programming in python (and that was about 10 years ago) I thought the same. More so, when we have four spaces per indent. But then, now I am completely comfortable with 80 characters per line. There are ways to get your code to

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-24 Thread Alok Gandhi
Because... once you make an instance of your Build class...you have a... > Build instance? > > On Sun, Sep 25, 2016 at 5:24 PM Alok Gandhi <alok.gandhi2...@gmail.com> > wrote: > >> But a class named Skeleton is more descriptive than Build. >> >> >> Of ourse it i

Re: [Maya-Python] pep 8 nameing convention for packages and modules

2016-09-24 Thread Alok Gandhi
> > But a class named Skeleton is more descriptive than Build. Of ourse it is, but only if you do not have a namespace context. I totally agree with Yury here. Your namespace already qualifies what Build class is, so you do not have to worry about the context. Always remeber - Namespaces are

Re: [Maya-Python] Boolean case scenario

2016-09-23 Thread Alok Gandhi
> By the way, when I tried using > if selection_case is None: > ... > It is not working as I expected it would output the same as in the code I > have written Not answering the original question but you can clearly distinguish between True, False and None, as Justin has rightly

Re: [Maya-Python] Re: How to change the text color of an item in a QListWidget?

2016-09-20 Thread Alok Gandhi
Take a loot at the pyside docs here: https://srinikom.github.io/pyside-docs/contents.html You can also use `PySide.QtGui.QWidget.setStyleSheet(styleSheet)` to update the colors. For capturing double click, another approach would be apply an even filter: def clickable(widget): """Re

Re: [Maya-Python] PyQt Model/View not showing in Maya

2016-09-19 Thread Alok Gandhi
Instead of commenting out, you can check for existence of an application instance. def run(): app = QtGui.QApplication.instance() createNew = app is None if createNew: app = QtGui.QApplication(sys.argv) win = BasicDialog() win.show() if createNew:

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-17 Thread Alok Gandhi
my development focus shift from 'just make it work' to 'make it beautiful and readable'. On Sat, Sep 17, 2016 at 1:47 PM, Justin Israel <justinisr...@gmail.com> wrote: > > > On Sat, Sep 17, 2016 at 5:34 PM Alok Gandhi <alok.gandhi2...@gmail.com> > wrote: > >>

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-16 Thread Alok Gandhi
Ah ok, just saw Marcus's answer, so most of my assumptions were correct. I would still say, there are many ways to achieve the same thing in programming. With the kind of flexibility, that python provides, the 'many ways' becomes 'so many ways'. Coming back to some of the points that Ian raised:

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-16 Thread Alok Gandhi
ffort to avoid the scan Alok's solution introduced a number of other > performance penalties (mostly due to pymel, but also due to searching the > scene twice). > > Marcus: > - 49 function calls in 0.005 seconds > Mine: > - 29 function calls (23 primitive calls) in 0.003 seconds >

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-16 Thread Alok Gandhi
> found, like how the dict is being used currently? > > On 16 September 2016 at 15:01, Alok Gandhi <alok.gandhi2...@gmail.com> > wrote: > >> Hi Marcus, >> >> My objective was simple, parenting is the main focus and it should be >> done once and only onc

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-16 Thread Alok Gandhi
Hi Marcus, My objective was simple, parenting is the main focus and it should be done once and only once for each node in the hierarchy. To achieve this, during each iteration the node should have knowledge about his parent just by knowing its position (indent). I did not want complex

Re: [Maya-Python] Optimise this: Hierarchy from String

2016-09-16 Thread Alok Gandhi
ot;\n") if line.strip()): On Fri, Sep 16, 2016 at 4:04 PM, Alok Gandhi <alok.gandhi2...@gmail.com> wrote: > IMHO, parsing the string is just a matter of administrative logic and > should not be bothered with when focussing on the business logic (which, in >

Re: [Maya-Python] How To Get Real Time Feedback from Maya Script Editor to Sublime Text Console??

2016-08-31 Thread Alok Gandhi
Thanks for doing that Justin! (from a happy user of may sublime) On Thu, Sep 1, 2016 at 4:07 AM, Justin Israel wrote: > > > On Thu, 1 Sep 2016, 7:27 AM Eric S wrote: > >> Thanks Justin for your explination. >> Whish this feature we can achive in

Re: [Maya-Python] textField - invoking callback on each keypress, keeping focus after Enter

2016-08-24 Thread Alok Gandhi
+1 for QLineEdit On Thu, Aug 25, 2016 at 3:59 AM, Justin Israel wrote: > Hi > > If the change callback doesn't fire on each keypress (I can't remember) > and you want more custom behaviour than the limited Maya UI objects > provide, then you may need to switch to PySide.

Re: [Maya-Python] 'counter' versioning for object renaming not working

2016-08-24 Thread Alok Gandhi
> > > @alok > I guess I could have made the default base use the pattern that likage had > specified, but I was really just making it generic and then the usage of it > could specify that custom format. Maybe my docstrings clarified the usage > though? > > Justin > > It sure did. I would still

Re: [Maya-Python] 'counter' versioning for object renaming not working

2016-08-23 Thread Alok Gandhi
@Justin : Might I suggest a minor change to your example function : using the *format code* in the default argument would make it more readable (especially in absence of any example usage) so the signature becomes: def uniqueNamePattern(base="whatever_{0}_whatever") This improves readability for

Re: [Maya-Python] maya api question

2016-07-26 Thread Alok Gandhi
You are returning a cross product when smooth is false. A cross product is a vector. Also as I said before, your example does not show implementation of getCrossProduct() so it is not clear what actually you are returning. But again, as I mentioned earlier, if your method name is getCrossProduct()

Re: [Maya-Python] maya api question

2016-07-26 Thread Alok Gandhi
I would comment on the second part of your question : Regarding the getNormal() method, the short answer is yes. To write clean readable code, the only thing that is of importance (more so in python) is to name your methods, variable with utmost care. Since getNormal() would return a MVector in