I am writing a python tool that will store attributes of the stereoscopic camera in a scene into a JSON file.
I use this code to get the selected plane with the attributes I need to store
import maya.OpenMaya as om
selected = om.MSelectionList()
om.MGlobal.getActiveSelectionList(selected)
obj = om.MObject()
selected.getDependNode(0,obj)
sel = om.MFnDependencyNode(obj).name()
if sel != "npl_Near_ZP":
cmds.confirmDialog(title= 'Error:', message = 'Error: Please Select the correct plane', button =['OK'])
else:
jsonCreate(sel)
It was working perfectly before but now when I try to the script, I get the following runtime error and I 've sort of hit a wall here cause I don't understand what the problem is
Error: RuntimeError: file S:\Maya_2018_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 18296: (kInvalidParameter): Index not in valid range #
I m still new to Maya so any help will be greatly appreciated
update I restarted my computer and the script is now running as it should. Can anyone explain this behaviour in case it happens again
Related
I have NO return on child_window when the program is in its state i expect to work in.
I need a way to edit the text field but literally all examples and google searches i have done show no examples of implementation EXCEPT when using child_window
this should put Test into the edit field
from pywinauto.application import Application
app = Application(backend="uia").connect(title="DaVinci Resolve Studio - Template")
#app.DaVinciResolveStudioTemplate.print_control_identifiers()
Title = app.DaVinciResolveStudioTemplate.['TitleEdit', 'Edit8'].wrapper_object()
Title.type_keys("Test")
it returns a syntax error
I have read teh documentation and i HONESTLY have no idea how to initiate the return with out a child window. Googing "no child_window" with multiple iterations has yielded me hours wasted and NOT ONE solution.
if text is entered the child_window appears in returns, but that isnt how the program start's
This is the native return
please, explain it for me how im supposed to seach/grab/interact with out child window? with a example please because this has me at a loss
Syntax error is in line Title = app.DaVinciResolveStudioTemplate.['TitleEdit', 'Edit8'].wrapper_object().
This line should be written as either Title = app.DaVinciResolveStudioTemplate['TitleEdit', 'Edit8'].wrapper_object() or Title = app.DaVinciResolveStudioTemplate.Edit8.wrapper_object().
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I have a python script used as a source code for a ScriptTool in ArcGIS that is supposed to select road segments from a selection by location with a mask (polygon feature class).Everything worked fine until I modified the code to generate a different mask for the selection tool.
It seems that since that modification, the modified code as well as the original code both give me the same executing error for the SelectByLocation tool with the INTERSECT condition.
Here is the specific part of the original code :
import arcpy, os, datetime
from arcpy.sa import *
if __name__ == "__main__":
inRas = r'path\Raster_for_mask'
inRR = r'path\roads'
arcpy.env.overwriteOutput = True
# Mask creation based on the raster file
arcpy.CheckOutExtension('Spatial')
maskZIr = arcpy.Raster(inRas)>-10000
maskZIs = 'Zone_inondee'
arcpy.RasterToPolygon_conversion(maskZIr,maskZIs)
# Road features selections by the mask ############################
inRRLayer = 'inRRLayer'
arcpy.MakeFeatureLayer_management(inRR, inRRLayer)
arcpy.SelectLayerByLocation_management(inRRLayer,"INTERSECT",maskZIs)
And here is the modified code :
import arcpy, os, datetime
from arcpy.sa import *
if __name__ == "__main__":
inRas = r'path\Raster_for_mask'
inRR = r'path\roads'
arcpy.env.overwriteOutput = True
## Real mask to select road features that I want
maskZIr = arcpy.Raster(inRas)
maskZIr2 = SetNull(maskZIr,maskZIr,"VALUE = 0") # Erase the error zones of the raster before conversion to polygon
maskZIr3 = Int(maskZIr2)
maskZIr4 = 'Zone_inondee_multipart'
arcpy.RasterToPolygon_conversion(maskZIr3,maskZIr4)
maskZIs = 'Zone_inondee'
arcpy.Dissolve_management(maskZIr4,maskZIs) # Singlepart polygon mask
##################################
# Road features selections by the mask ############################
inRRLayer = 'inRRLayer'
arcpy.MakeFeatureLayer_management(inRR, inRRLayer)
arcpy.SelectLayerByLocation_management(inRRLayer,"INTERSECT",maskZIs)
(The paths for the files are fake ones just for demonstration purposes)
Concerning the error, a small window named "AddList" appears with only "FetchGeometries" written in it, along with an OK button. When clicked, I get an function execution error for the SelectByLocation_management tool (unknown 999999 Error). This happens too if I run my unmodified code, that worked fine before.
I verified both files used to run the selection tool but they are both in the right format (shapefile, polygon type for the mask and lines for the roads) and populated right. I looked up everywhere on the internet and it appears that nobody had that problem before...
Check a screen shot of the issue : http://imgur.com/jltD0zl.
The problem isn't that much the code itself because it worked fine before but I just can't trace back the source of that error. The code blocks just indicate the context in which the error occured. My guts suggest that something went wrong at some point with the MakeFeatureLayer_management tool. Also, using the source file for the roads without making a feature layer gives an error for non valid parameters for the selection tool.
So my question here is : have you ever seen this error ? And if so, was it with the same geoprocessing tool and how do you get rid of it ?
Thank you guys.
For info I just started learning python and arcpy two months ago for an internship. This is my first ever post here so I apologize in advance if my problem is unclear to some of you.
I am also relatively new to the ArcPy environment, and had the exact same problem on Arc 10.3.
The issue seems to be that ArcMap loses permission to access the personal geodatabase (MDB) that I was working with and could no longer read from or write to it. I do not have this problem with file geodatabases (GDB) or a folder full of shapefiles on the Windows filesystem.
Until this is resolved by Esri, it seems the best bet is to avoid personal geodatabases if you can.
I'm trying to use TideSDK and python tp get the user to select a folder from the hard drive. Everything works, but I have no idea how obtain which folder the user selected.
I can't seem to find documentation on what Ti.UI.UserWindow.openFolderChooseDialog returns and what kind of object the callback function uses. I just get errors that "window" in "onopen" in my code below is a None Type object when I try to print it out.
Is there any documentation on the proper use of the openFolderChooseDialog, what signature the callback needs to be and how to get the Folder/directory from the dialog?
My code:
def onopen(window):
Ti.App.stdout("------------------ Opening Dialog")
Ti.App.stdout(window)
def burndir():
try:
dir = Ti.UI.getCurrentWindow().openFolderChooserDialog(onopen)
Ti.App.stdout(dir)
except:
Ti.App.stderr("------ There was an error: ")
Ti.App.stderr(sys.exc_info()[0])
Ti.App.stderr(sys.exc_info()[1])
Ti.App.stderr(sys.exc_info()[2])
Any help is much appreciated
I found the answer in a Javascript Code example here:
https://github.com/appcelerator/titanium_developer/blob/master/Resources/perspectives/projects/js/projects.js#L1338
It appears that openFolderChooserDialog return nothing (a None object in Python). The callback function passes one argument which is a StaticBoundList (a Tuple object in Python) that contains all of the selected folders (in case of allowing multiple selections)
Here is the updated code:
def onopen(window):
if (len(window) > 0):
Ti.App.stdout("------------------ Opening Dialog")
Ti.App.stdout(window[0])
else:
Ti.App.stdout("------------------ Nothing Selected")
def burndir():
try:
Ti.UI.getCurrentWindow().openFolderChooserDialog(onopen)
except:
Ti.App.stderr("------ There was an error: ")
Ti.App.stderr(sys.exc_info()[0])
Ti.App.stderr(sys.exc_info()[1])
Ti.App.stderr(sys.exc_info()[2])
I hope this helps someone struggling to find the same documentation!
I'm a fairly new Python programmer (started 3 days ago). I'm working as a apprentice for a civil engineer and he asked me to do some simpler tasks for his program, as of the objective I should work with is to not allow numbers from inputs in certain glade objects.
The code I've been struggling with creating is as such:
def testOmHeltal (self, number1):
textviewResultat = self.builder.get_object("textviewResultat")
text = gtk.TextBuffer()
try:
#print number1.get_text()
#temp = number1.get_text() + number1.get_text()
temp = float(number1.get_text())
except ValueError:
text.set_text("ERROR: Endast Nummer")
self.builder.get_object("hboxWarning").show()
self.builder.get_object("image12").show()
self.builder.get_object("textviewResultat").set_buffer(text)
return 0
self.builder.get_object("hboxWarning").hide()
self.builder.get_object("image12").hide()
def quit(self, widget):
sys.exit(0)
This code is called upon at the location of the glade object with this line:
self.testOmHeltal(entryGladeObject)
Now to the problem at hand, I allways get an Float error as such:
File "bvf.py", line 393, in utfora
+float(entryTjockleksskyddslager.get_text<>>>>
ValueError: invalid literal for float<>: 0.04e
0.04e is the invalid input and line 393 is a piece of my Chiefs code, since all he uses is float all the time and I shouldn't meddle with it too much I'm kind of panicking alittle..
I understand that float can only start and end with a number to not give an error, but since my "code" bit wants an error(or rather, an exception) to start the 'hboxWarning' and 'image12' of someone using a letter instead of the supposed number, I'm at a loss at what to do ><
Instead of showing my error with hboxWarning and image12, nothing happens at all...
Any hints or advice would help alot.
I don't know if I understood correctly, but the error is not on your code, right?
All I can assume is that there's a piece of code trying to convert the value to float before your verification. If that's the case, you should verify the value before any processing is done on it, or move the try-except code around the faulty code, depending on the processing itself (for example, if the processing implies database manipulation, it would be safer to do all the verifications previously).
If the error is happening before the line where you run self.testOmHeltal(entryGladeObject), the execution of the signal/method stops right away and your code is never excecuted; that's why the warning isn't showing.
I want to try to add all the step details - Expected, Actual, Status,
etc. to a QC Run for a testcase of a TestSet from a Python Script
living outside the Quality Center.
I have come till here (code given below) and I don't know how to add
Step Expected and Step Actual Result. If anyone knows how do it,
please help me out!! Please, I don't want any QTP solutions.
Thanks,
Code-
# Script name - add_tsrun.py
# C:\Python27\python.exe
# This script lives locally on a Windows machine that has - Python 2.7, Win32 installed, IE8
# Dependencies on Windows Machine - Python 2.7, PythonWin32 installed, IE8, a QC Account, connectivity to QCServer
import win32com.client, os
tdc = win32com.client.Dispatch("TDApiOle80.TDConnection")
tdc.InitConnection('http://QCSERVER:8080/qcbin')
tdc.Login('USERNAME', 'PASSWORD')
tdc.Connect('DOMAIN_NAME', 'PROJECT')
tsFolder = tdc.TestSetTreeManager.NodeByPath('Root\\test_me\\sub_folder')
tsList = tsFolder.FindTestSets('testset1')
ts_object = tsList.Item(1)
ts_dir = os.path.dirname('testset1')
ts_name = os.path.basename('testset1')
tsFolder = tdc.TestSetTreeManager.NodeByPath(ts_dir)
tsList = tsFolder.FindTestSets(ts_name)
ts_object = tsList.Item(1)
TSTestFact = ts_object.TSTestFactory
TestSetTestsList = TSTestFact.NewList("")
ts_instance = TestSetTestsList.Item(1)
newItem = ts_instance.RunFactory.AddItem(None) # newItem == Run Object
newItem.Status = 'No Run'
newItem.Name = 'Run 03'
newItem.Post()
newItem.CopyDesignSteps() # Copy Design Steps
newItem.Post()
steps = newItem.StepFactory.NewList("")
step1 = steps[0]
step1.Status = "Not Completed"
step1.post()
## How do I change the Actual Result??
## I can access the Actual, Expected Result by doing this, but not change it
step1.Field('ST_ACTUAL') = 'My actual result' # This works in VB, not python as its a Syntax error!!
Traceback ( File "<interactive input>", line 1
SyntaxError: can't assign to function call
Hope this helps you guys out there. If you know the answer to set the
Actual Result, please help me out and let me know. Thanks,
Amit
As Ethan Furman answered in your previous question:
In Python () represent calls to functions, while [] represent indexing and mapping.
So in other words, you probably want to do step1.Field['ST_ACTUAL'] = 'My actual result'
Found the answer after a lot of Google Search :)
Simple -> Just do this:
step1.SetField("ST_ACTUAL", "my actual result") # Wohhooooo!!!!
If the above code fails to work, try to do the following:-
(OPTIONAL) Set your win32 com as follows- (Making ''Late Binding'')
# http://oreilly.com/catalog/pythonwin32/chapter/ch12.html
a. Start PythonWin, and from the Tools menu, select the item COM Makepy utility.
b. Using Windows Explorer, locate the client subdirectory (OTA COM Type Library)
under the main win32com directory and double-click the file makepy.py.
Thank you all...