Have to import maya.cmds multiple times else maya forgets it after button pressHave multiple commands when button is pressedCounting Button pressing timesimporting multiple cache files in Maya using Pythonmaya python + Pass variable on button pressButton press after a delayMaya Python multiple functions to one buttonimporting and renaming multiple objects in maya with pythonHow to handle pressed button more time in Kivy?Assign multiple shaders to imported .OBJ files in Mayaa mel delete attributes in maya after import fbx form 3dmax

What is the difference between lands and mana?

What does Apple's new App Store requirement mean

What is the English pronunciation of "pain au chocolat"?

Giving feedback to someone without sounding prejudiced

Make a Bowl of Alphabet Soup

Why does the Sun have different day lengths, but not the gas giants?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

How can ping know if my host is down

Is this part of the description of the Archfey warlock's Misty Escape feature redundant?

How can I write humor as character trait?

Is this toilet slogan correct usage of the English language?

Why Shazam when there is already Superman?

How to copy file from a list to a new folder?

Why does Java 12 try to convert the result of a switch to a number?

Which was the first story featuring espers?

xxx we would have made had we used xxx, what is had used for?

Mimic lecturing on blackboard, facing audience

When were female captains banned from Starfleet?

awk assign to multiple variables at once

Angel of Condemnation - Exile creature with second ability

What is the duration of the spell Creation when used to create non-precious metals?

What (the heck) is a Super Worm Equinox Moon?

X marks the what?

Why is it that I can sometimes guess the next note?



Have to import maya.cmds multiple times else maya forgets it after button press


Have multiple commands when button is pressedCounting Button pressing timesimporting multiple cache files in Maya using Pythonmaya python + Pass variable on button pressButton press after a delayMaya Python multiple functions to one buttonimporting and renaming multiple objects in maya with pythonHow to handle pressed button more time in Kivy?Assign multiple shaders to imported .OBJ files in Mayaa mel delete attributes in maya after import fbx form 3dmax













0















as for some background, my code is most likely a complete mess, mostly since I've only had a couple of hours scripting in my life.



For class im creating a solar system with all the standard planets and also the option for the user to input their own planet. Everything worked fine up until i tried letting the user spawn the planets with a button in the UI(an ugly button for now but a button nonetheless). If the user presses a button, say 'Sun', then the sun spawns, but only once, if he then decides to spawn sun again or any other planet for that matter, it gives an error stating that the module doesn't contain 'polycube or polysphere'. So basically, the button works once, then doesn't work anymore. If i call them from anywhere but the button, it works perfectly and indefinitely. I figured since he doesn't know polycube or polysphere, its almost as if i didn't import maya.cmds, so lets try recalling it. and low and behold that works.



So basically my question is as follows, does maya forget its imported libraries when you press a button? and How do i solve this without having to re-import maya.cmds in every function?



import maya.cmds as maya

class create_body:

def __init__(self, distance, radius, bonus_scale, r, g, b):
import maya.cmds as maya

self.radius = radius * bonus_scale / 1000
self.bonusScale = bonus_scale
self.distanceScene = distance
self.distanceMeter = distance*1000000000

maya.polyCube()

self.r = r
self.g = g
self.b = b

def color_body_custom(self):
import maya.cmds as maya

value = maya.colorEditor()

self.color = [float(i) for i in value.split()]
self.r = self.color[0]
self.g = self.color[1]
self.b = self.color[2]

def spawn_body(self):
import maya.cmds as maya

maya.polySphere(r = self.radius)
maya.move(self.distanceScene, moveZ = True)
maya.move(0, 0, 0, ".scalePivot", ".rotatePivot", absolute=True)
maya.polyColorPerVertex(rgb=(self.r,self.g,self.b), colorDisplayOption=True)

def animate_body(self):
import maya.cmds as maya

orbitTimeYears = self.get_orbital_time()*10
key = str(orbitTimeYears) + 'sec'
maya.setKeyframe(v=0, at='rotateY', t=['0sec'], itt = 'spline', ott = 'spline')
maya.setKeyframe(v=-360, at='rotateY', t=[key], itt = 'spline', ott = 'spline')
maya.selectKey(attribute='rotateY')
maya.setInfinity(pri='linear', poi='linear')

def get_orbital_time(self):
import math

orbitMeter = self.distanceMeter * 2 * math.pi
gravConst = 132690600000000000000 / self.distanceMeter
orbitSpeed = math.sqrt(gravConst)
orbitTimeSec = orbitMeter / orbitSpeed
orbitTimeYears = orbitTimeSec / 31556926

return orbitTimeYears

class create_ui:
def __init__(self, window_name):
self.myPlanetarySystem = window_name

# Make sure there's only one window open by deleting the window if it exists
self.delete_ui()

# Create the UI
self.myp = maya.window(self.myPlanetarySystem)
maya.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 150), (2, 75), (3, 75)], columnOffset=[(1, 'left', 5)])
maya.showWindow()
maya.window(self.myPlanetarySystem, e=True, title='TileGenerator', w=200, h=190)

maya.button(label = 'Sun', command = partial(self.body, 0, 695.510, 10, True, 1, 1, 0))
maya.button(label='Mercury', command = partial(self.body, 57.9, 2.439, 1000, False, 0.2, 0.2, 0))

#Sun = create_body(0, 695.510, 10, 1, 1, 0)
#Sun.spawn_body()

#Mercury = create_body(57.9, 2.439, 1000, 0.2, 0.2, 0)
#Mercury.spawn_body()
#Mercury.animate_body()

#Venus = create_body(108.2, 6.051, 1000, .5, 0.2, 0)
#Venus.spawn_body()
#Venus.animate_body()

#Earth = create_body(149.6, 6.971, 1000, 0, 0, 1)
#Earth.spawn_body()
#Earth.animate_body()

#Mars = create_body(227.9, 3.389, 1000, 0.6, 0.1, 0)
#Mars.spawn_body()
#Mars.animate_body()

#Jupiter = create_body(778.5, 69.911, 100, 0.9, 0.8, 0.5)
#Jupiter.spawn_body()
#Jupiter.animate_body()

#Saturn = create_body(1433.4, 58.232, 100, 0.8, 0.8, 0.7)
#Saturn.spawn_body()
#Saturn.animate_body()

#Uranus = create_body(2876.6, 25.362, 100, 0.7, 0.8, 1.0)
#Uranus.spawn_body()
#Uranus.animate_body()

#Neptune = create_body(4503.4, 24.622, 100, 0.3, 0.4, 0.7)
#Neptune.spawn_body()
#Neptune.animate_body()

def delete_ui(self):
if maya.window(self.myPlanetarySystem, exists=True):
maya.deleteUI(self.myPlanetarySystem, window=True)

def body(self, distance, radius, bonus_scale, is_sun, r = 0.5, g = 0.5, b = 0.5, *args):
obj = create_body(distance, radius, bonus_scale, r, g, b)
obj.spawn_body()
if not is_sun:
obj.animate_body()

create_ui('myPlanetarySystem')









share|improve this question
























  • Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

    – Green Cell
    Mar 8 at 1:36











  • Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

    – Arnaud Hanssens
    Mar 8 at 8:40






  • 1





    Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

    – Green Cell
    Mar 11 at 1:38











  • I run from pycharm and that was indeed the issue, I've had no further problems

    – Arnaud Hanssens
    Mar 12 at 9:24















0















as for some background, my code is most likely a complete mess, mostly since I've only had a couple of hours scripting in my life.



For class im creating a solar system with all the standard planets and also the option for the user to input their own planet. Everything worked fine up until i tried letting the user spawn the planets with a button in the UI(an ugly button for now but a button nonetheless). If the user presses a button, say 'Sun', then the sun spawns, but only once, if he then decides to spawn sun again or any other planet for that matter, it gives an error stating that the module doesn't contain 'polycube or polysphere'. So basically, the button works once, then doesn't work anymore. If i call them from anywhere but the button, it works perfectly and indefinitely. I figured since he doesn't know polycube or polysphere, its almost as if i didn't import maya.cmds, so lets try recalling it. and low and behold that works.



So basically my question is as follows, does maya forget its imported libraries when you press a button? and How do i solve this without having to re-import maya.cmds in every function?



import maya.cmds as maya

class create_body:

def __init__(self, distance, radius, bonus_scale, r, g, b):
import maya.cmds as maya

self.radius = radius * bonus_scale / 1000
self.bonusScale = bonus_scale
self.distanceScene = distance
self.distanceMeter = distance*1000000000

maya.polyCube()

self.r = r
self.g = g
self.b = b

def color_body_custom(self):
import maya.cmds as maya

value = maya.colorEditor()

self.color = [float(i) for i in value.split()]
self.r = self.color[0]
self.g = self.color[1]
self.b = self.color[2]

def spawn_body(self):
import maya.cmds as maya

maya.polySphere(r = self.radius)
maya.move(self.distanceScene, moveZ = True)
maya.move(0, 0, 0, ".scalePivot", ".rotatePivot", absolute=True)
maya.polyColorPerVertex(rgb=(self.r,self.g,self.b), colorDisplayOption=True)

def animate_body(self):
import maya.cmds as maya

orbitTimeYears = self.get_orbital_time()*10
key = str(orbitTimeYears) + 'sec'
maya.setKeyframe(v=0, at='rotateY', t=['0sec'], itt = 'spline', ott = 'spline')
maya.setKeyframe(v=-360, at='rotateY', t=[key], itt = 'spline', ott = 'spline')
maya.selectKey(attribute='rotateY')
maya.setInfinity(pri='linear', poi='linear')

def get_orbital_time(self):
import math

orbitMeter = self.distanceMeter * 2 * math.pi
gravConst = 132690600000000000000 / self.distanceMeter
orbitSpeed = math.sqrt(gravConst)
orbitTimeSec = orbitMeter / orbitSpeed
orbitTimeYears = orbitTimeSec / 31556926

return orbitTimeYears

class create_ui:
def __init__(self, window_name):
self.myPlanetarySystem = window_name

# Make sure there's only one window open by deleting the window if it exists
self.delete_ui()

# Create the UI
self.myp = maya.window(self.myPlanetarySystem)
maya.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 150), (2, 75), (3, 75)], columnOffset=[(1, 'left', 5)])
maya.showWindow()
maya.window(self.myPlanetarySystem, e=True, title='TileGenerator', w=200, h=190)

maya.button(label = 'Sun', command = partial(self.body, 0, 695.510, 10, True, 1, 1, 0))
maya.button(label='Mercury', command = partial(self.body, 57.9, 2.439, 1000, False, 0.2, 0.2, 0))

#Sun = create_body(0, 695.510, 10, 1, 1, 0)
#Sun.spawn_body()

#Mercury = create_body(57.9, 2.439, 1000, 0.2, 0.2, 0)
#Mercury.spawn_body()
#Mercury.animate_body()

#Venus = create_body(108.2, 6.051, 1000, .5, 0.2, 0)
#Venus.spawn_body()
#Venus.animate_body()

#Earth = create_body(149.6, 6.971, 1000, 0, 0, 1)
#Earth.spawn_body()
#Earth.animate_body()

#Mars = create_body(227.9, 3.389, 1000, 0.6, 0.1, 0)
#Mars.spawn_body()
#Mars.animate_body()

#Jupiter = create_body(778.5, 69.911, 100, 0.9, 0.8, 0.5)
#Jupiter.spawn_body()
#Jupiter.animate_body()

#Saturn = create_body(1433.4, 58.232, 100, 0.8, 0.8, 0.7)
#Saturn.spawn_body()
#Saturn.animate_body()

#Uranus = create_body(2876.6, 25.362, 100, 0.7, 0.8, 1.0)
#Uranus.spawn_body()
#Uranus.animate_body()

#Neptune = create_body(4503.4, 24.622, 100, 0.3, 0.4, 0.7)
#Neptune.spawn_body()
#Neptune.animate_body()

def delete_ui(self):
if maya.window(self.myPlanetarySystem, exists=True):
maya.deleteUI(self.myPlanetarySystem, window=True)

def body(self, distance, radius, bonus_scale, is_sun, r = 0.5, g = 0.5, b = 0.5, *args):
obj = create_body(distance, radius, bonus_scale, r, g, b)
obj.spawn_body()
if not is_sun:
obj.animate_body()

create_ui('myPlanetarySystem')









share|improve this question
























  • Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

    – Green Cell
    Mar 8 at 1:36











  • Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

    – Arnaud Hanssens
    Mar 8 at 8:40






  • 1





    Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

    – Green Cell
    Mar 11 at 1:38











  • I run from pycharm and that was indeed the issue, I've had no further problems

    – Arnaud Hanssens
    Mar 12 at 9:24













0












0








0








as for some background, my code is most likely a complete mess, mostly since I've only had a couple of hours scripting in my life.



For class im creating a solar system with all the standard planets and also the option for the user to input their own planet. Everything worked fine up until i tried letting the user spawn the planets with a button in the UI(an ugly button for now but a button nonetheless). If the user presses a button, say 'Sun', then the sun spawns, but only once, if he then decides to spawn sun again or any other planet for that matter, it gives an error stating that the module doesn't contain 'polycube or polysphere'. So basically, the button works once, then doesn't work anymore. If i call them from anywhere but the button, it works perfectly and indefinitely. I figured since he doesn't know polycube or polysphere, its almost as if i didn't import maya.cmds, so lets try recalling it. and low and behold that works.



So basically my question is as follows, does maya forget its imported libraries when you press a button? and How do i solve this without having to re-import maya.cmds in every function?



import maya.cmds as maya

class create_body:

def __init__(self, distance, radius, bonus_scale, r, g, b):
import maya.cmds as maya

self.radius = radius * bonus_scale / 1000
self.bonusScale = bonus_scale
self.distanceScene = distance
self.distanceMeter = distance*1000000000

maya.polyCube()

self.r = r
self.g = g
self.b = b

def color_body_custom(self):
import maya.cmds as maya

value = maya.colorEditor()

self.color = [float(i) for i in value.split()]
self.r = self.color[0]
self.g = self.color[1]
self.b = self.color[2]

def spawn_body(self):
import maya.cmds as maya

maya.polySphere(r = self.radius)
maya.move(self.distanceScene, moveZ = True)
maya.move(0, 0, 0, ".scalePivot", ".rotatePivot", absolute=True)
maya.polyColorPerVertex(rgb=(self.r,self.g,self.b), colorDisplayOption=True)

def animate_body(self):
import maya.cmds as maya

orbitTimeYears = self.get_orbital_time()*10
key = str(orbitTimeYears) + 'sec'
maya.setKeyframe(v=0, at='rotateY', t=['0sec'], itt = 'spline', ott = 'spline')
maya.setKeyframe(v=-360, at='rotateY', t=[key], itt = 'spline', ott = 'spline')
maya.selectKey(attribute='rotateY')
maya.setInfinity(pri='linear', poi='linear')

def get_orbital_time(self):
import math

orbitMeter = self.distanceMeter * 2 * math.pi
gravConst = 132690600000000000000 / self.distanceMeter
orbitSpeed = math.sqrt(gravConst)
orbitTimeSec = orbitMeter / orbitSpeed
orbitTimeYears = orbitTimeSec / 31556926

return orbitTimeYears

class create_ui:
def __init__(self, window_name):
self.myPlanetarySystem = window_name

# Make sure there's only one window open by deleting the window if it exists
self.delete_ui()

# Create the UI
self.myp = maya.window(self.myPlanetarySystem)
maya.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 150), (2, 75), (3, 75)], columnOffset=[(1, 'left', 5)])
maya.showWindow()
maya.window(self.myPlanetarySystem, e=True, title='TileGenerator', w=200, h=190)

maya.button(label = 'Sun', command = partial(self.body, 0, 695.510, 10, True, 1, 1, 0))
maya.button(label='Mercury', command = partial(self.body, 57.9, 2.439, 1000, False, 0.2, 0.2, 0))

#Sun = create_body(0, 695.510, 10, 1, 1, 0)
#Sun.spawn_body()

#Mercury = create_body(57.9, 2.439, 1000, 0.2, 0.2, 0)
#Mercury.spawn_body()
#Mercury.animate_body()

#Venus = create_body(108.2, 6.051, 1000, .5, 0.2, 0)
#Venus.spawn_body()
#Venus.animate_body()

#Earth = create_body(149.6, 6.971, 1000, 0, 0, 1)
#Earth.spawn_body()
#Earth.animate_body()

#Mars = create_body(227.9, 3.389, 1000, 0.6, 0.1, 0)
#Mars.spawn_body()
#Mars.animate_body()

#Jupiter = create_body(778.5, 69.911, 100, 0.9, 0.8, 0.5)
#Jupiter.spawn_body()
#Jupiter.animate_body()

#Saturn = create_body(1433.4, 58.232, 100, 0.8, 0.8, 0.7)
#Saturn.spawn_body()
#Saturn.animate_body()

#Uranus = create_body(2876.6, 25.362, 100, 0.7, 0.8, 1.0)
#Uranus.spawn_body()
#Uranus.animate_body()

#Neptune = create_body(4503.4, 24.622, 100, 0.3, 0.4, 0.7)
#Neptune.spawn_body()
#Neptune.animate_body()

def delete_ui(self):
if maya.window(self.myPlanetarySystem, exists=True):
maya.deleteUI(self.myPlanetarySystem, window=True)

def body(self, distance, radius, bonus_scale, is_sun, r = 0.5, g = 0.5, b = 0.5, *args):
obj = create_body(distance, radius, bonus_scale, r, g, b)
obj.spawn_body()
if not is_sun:
obj.animate_body()

create_ui('myPlanetarySystem')









share|improve this question
















as for some background, my code is most likely a complete mess, mostly since I've only had a couple of hours scripting in my life.



For class im creating a solar system with all the standard planets and also the option for the user to input their own planet. Everything worked fine up until i tried letting the user spawn the planets with a button in the UI(an ugly button for now but a button nonetheless). If the user presses a button, say 'Sun', then the sun spawns, but only once, if he then decides to spawn sun again or any other planet for that matter, it gives an error stating that the module doesn't contain 'polycube or polysphere'. So basically, the button works once, then doesn't work anymore. If i call them from anywhere but the button, it works perfectly and indefinitely. I figured since he doesn't know polycube or polysphere, its almost as if i didn't import maya.cmds, so lets try recalling it. and low and behold that works.



So basically my question is as follows, does maya forget its imported libraries when you press a button? and How do i solve this without having to re-import maya.cmds in every function?



import maya.cmds as maya

class create_body:

def __init__(self, distance, radius, bonus_scale, r, g, b):
import maya.cmds as maya

self.radius = radius * bonus_scale / 1000
self.bonusScale = bonus_scale
self.distanceScene = distance
self.distanceMeter = distance*1000000000

maya.polyCube()

self.r = r
self.g = g
self.b = b

def color_body_custom(self):
import maya.cmds as maya

value = maya.colorEditor()

self.color = [float(i) for i in value.split()]
self.r = self.color[0]
self.g = self.color[1]
self.b = self.color[2]

def spawn_body(self):
import maya.cmds as maya

maya.polySphere(r = self.radius)
maya.move(self.distanceScene, moveZ = True)
maya.move(0, 0, 0, ".scalePivot", ".rotatePivot", absolute=True)
maya.polyColorPerVertex(rgb=(self.r,self.g,self.b), colorDisplayOption=True)

def animate_body(self):
import maya.cmds as maya

orbitTimeYears = self.get_orbital_time()*10
key = str(orbitTimeYears) + 'sec'
maya.setKeyframe(v=0, at='rotateY', t=['0sec'], itt = 'spline', ott = 'spline')
maya.setKeyframe(v=-360, at='rotateY', t=[key], itt = 'spline', ott = 'spline')
maya.selectKey(attribute='rotateY')
maya.setInfinity(pri='linear', poi='linear')

def get_orbital_time(self):
import math

orbitMeter = self.distanceMeter * 2 * math.pi
gravConst = 132690600000000000000 / self.distanceMeter
orbitSpeed = math.sqrt(gravConst)
orbitTimeSec = orbitMeter / orbitSpeed
orbitTimeYears = orbitTimeSec / 31556926

return orbitTimeYears

class create_ui:
def __init__(self, window_name):
self.myPlanetarySystem = window_name

# Make sure there's only one window open by deleting the window if it exists
self.delete_ui()

# Create the UI
self.myp = maya.window(self.myPlanetarySystem)
maya.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 150), (2, 75), (3, 75)], columnOffset=[(1, 'left', 5)])
maya.showWindow()
maya.window(self.myPlanetarySystem, e=True, title='TileGenerator', w=200, h=190)

maya.button(label = 'Sun', command = partial(self.body, 0, 695.510, 10, True, 1, 1, 0))
maya.button(label='Mercury', command = partial(self.body, 57.9, 2.439, 1000, False, 0.2, 0.2, 0))

#Sun = create_body(0, 695.510, 10, 1, 1, 0)
#Sun.spawn_body()

#Mercury = create_body(57.9, 2.439, 1000, 0.2, 0.2, 0)
#Mercury.spawn_body()
#Mercury.animate_body()

#Venus = create_body(108.2, 6.051, 1000, .5, 0.2, 0)
#Venus.spawn_body()
#Venus.animate_body()

#Earth = create_body(149.6, 6.971, 1000, 0, 0, 1)
#Earth.spawn_body()
#Earth.animate_body()

#Mars = create_body(227.9, 3.389, 1000, 0.6, 0.1, 0)
#Mars.spawn_body()
#Mars.animate_body()

#Jupiter = create_body(778.5, 69.911, 100, 0.9, 0.8, 0.5)
#Jupiter.spawn_body()
#Jupiter.animate_body()

#Saturn = create_body(1433.4, 58.232, 100, 0.8, 0.8, 0.7)
#Saturn.spawn_body()
#Saturn.animate_body()

#Uranus = create_body(2876.6, 25.362, 100, 0.7, 0.8, 1.0)
#Uranus.spawn_body()
#Uranus.animate_body()

#Neptune = create_body(4503.4, 24.622, 100, 0.3, 0.4, 0.7)
#Neptune.spawn_body()
#Neptune.animate_body()

def delete_ui(self):
if maya.window(self.myPlanetarySystem, exists=True):
maya.deleteUI(self.myPlanetarySystem, window=True)

def body(self, distance, radius, bonus_scale, is_sun, r = 0.5, g = 0.5, b = 0.5, *args):
obj = create_body(distance, radius, bonus_scale, r, g, b)
obj.spawn_body()
if not is_sun:
obj.animate_body()

create_ui('myPlanetarySystem')






python-2.7 button scripting python-import maya






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 1:33









Green Cell

2,0761929




2,0761929










asked Mar 8 at 0:24









Arnaud HanssensArnaud Hanssens

1




1












  • Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

    – Green Cell
    Mar 8 at 1:36











  • Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

    – Arnaud Hanssens
    Mar 8 at 8:40






  • 1





    Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

    – Green Cell
    Mar 11 at 1:38











  • I run from pycharm and that was indeed the issue, I've had no further problems

    – Arnaud Hanssens
    Mar 12 at 9:24

















  • Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

    – Green Cell
    Mar 8 at 1:36











  • Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

    – Arnaud Hanssens
    Mar 8 at 8:40






  • 1





    Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

    – Green Cell
    Mar 11 at 1:38











  • I run from pycharm and that was indeed the issue, I've had no further problems

    – Arnaud Hanssens
    Mar 12 at 9:24
















Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

– Green Cell
Mar 8 at 1:36





Running straight from the script editor this is working fine, though you forgot to import your partial module: from functools import partial

– Green Cell
Mar 8 at 1:36













Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

– Arnaud Hanssens
Mar 8 at 8:40





Ahh yes but not actually, I mean I just forgot to place it here, indeed my code here works but if you delete the instances of the import function after the first one the code no longer works

– Arnaud Hanssens
Mar 8 at 8:40




1




1





Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

– Green Cell
Mar 11 at 1:38





Even after deleting all import calls except the top line still works fine. Pressing a button won't magically "erase" imports, as that would be massively broken and honestly make no sense! But yes, good call on switching it to cmds, using it as maya is an odd choice espcially since you can actually run import maya.

– Green Cell
Mar 11 at 1:38













I run from pycharm and that was indeed the issue, I've had no further problems

– Arnaud Hanssens
Mar 12 at 9:24





I run from pycharm and that was indeed the issue, I've had no further problems

– Arnaud Hanssens
Mar 12 at 9:24












1 Answer
1






active

oldest

votes


















0














Answer: apparently importing my maya.cmds in the shorter version: maya conflicted with the program, i should've seen this coming. In other words, there's no more issues if I just import maya.cmds as cmds.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55054976%2fhave-to-import-maya-cmds-multiple-times-else-maya-forgets-it-after-button-press%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Answer: apparently importing my maya.cmds in the shorter version: maya conflicted with the program, i should've seen this coming. In other words, there's no more issues if I just import maya.cmds as cmds.






    share|improve this answer



























      0














      Answer: apparently importing my maya.cmds in the shorter version: maya conflicted with the program, i should've seen this coming. In other words, there's no more issues if I just import maya.cmds as cmds.






      share|improve this answer

























        0












        0








        0







        Answer: apparently importing my maya.cmds in the shorter version: maya conflicted with the program, i should've seen this coming. In other words, there's no more issues if I just import maya.cmds as cmds.






        share|improve this answer













        Answer: apparently importing my maya.cmds in the shorter version: maya conflicted with the program, i should've seen this coming. In other words, there's no more issues if I just import maya.cmds as cmds.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 9:18









        Arnaud HanssensArnaud Hanssens

        1




        1





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55054976%2fhave-to-import-maya-cmds-multiple-times-else-maya-forgets-it-after-button-press%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme