[Mi...] Posted October 14 Share Posted October 14 I am attempting to create an application where I dynamically generate number of checkboxes (the number of checkboxes depends on the number of unique items in a text file). After which the user is required to type in a value. If the value entered is equal to the name assigned to one of the checkboxes, then the checkbox will be checked off. When I run this code, my dialog event handler does not understand that "fixtureDictionary['fixtureName_0']" must actually correspond to the value of 'T30' (as an example). Instead, it's explicitly looking for the variable named 'fixtureDictionary'. I am still a bit new to Python, and I am perplexed as to how to fix this I have been reading that it is generally bad practice to have dynamically named variables, but unfortunately every checkbox in my script is required to have a unique name. Is there anyway to pass the dialog."something".value a dynamic name? Or is there a different approach I should take? Link to comment Share on other sites More sharing options...
[Ja...] Posted October 15 Share Posted October 15 Can you give detail of your ultimate goal , maybe there is a different way round. Dynamic variable handling should be avoided in my experience, just gets messy and its not really geared to handle it When faced with issues that seemed to require this after research ive found dictionaries can be used quite well. Link to comment Share on other sites More sharing options...
[Mi...] Posted October 16 Author Share Posted October 16 Please sign in to view this username. Sure thing! We would like to implement a routine that will ensure our operators are loading the correct fixturing for whichever part number that is put into the scanbox. I initially thought dynamically building a dialog box would be the best way to go about this, which is why I am creating a checkbox for every unique fixture piece. The idea was that as a barcode is scanned, the corresponding checkbox will be ticked off. When all fixture pieces have been verified then the operator can begin scanning. I've tried implementing a dictionary approach to get the script to find the corresponding key/value pairs, but in my troubleshoot it appears that the issue is boiling down to: dialog.fixtureDictionary['fixtureName_0'].value = True where dialog is the dialog box that I have generated, fixtureDictionary['fixtureName_0'] is my dictionary key, and value sets the checkbox to true. Unfortunately it appears that fixtureDictionary['fixtureName_0'] can never actually get resolved with the corresponding key-value pair. Instead, it is looking for a simple variable of just the name 'fixtureDictionary' (see error below). ---- Perhaps a better approach may be to just have something like one description field widget that is updated as a fixture piece is confirmed, or I can also include a log widget. Alternatively, I think I could also "hardcode" in discrete fixture piece names, and then using many try-except blocks, I can cycle through and check off a checkbox if the discrete name corresponds with the actual fixture piece name. This of course is sloppy programming and subject to breaking if I don't code in enough try-except blocks. Link to comment Share on other sites More sharing options...
[Mi...] Posted October 21 Author Share Posted October 21 So, I went a different direction with this. Instead of having individual checkboxes for each fixture piece, I am instead using just one 'continuous text' widget, which allows me to easily control the widget. I am still using a dictionary to grab to track what has or has not been scanned, but now I simply change the appearance as a fixture pieces is scanned. The end result looks something like this: Link to comment Share on other sites More sharing options...
[Ja...] Posted October 22 Share Posted October 22 Nice bit of coding there Please sign in to view this username. I was thinking about this . The systems/software did bring in a feature a few years back now that could utilise the sensor at a very safe distance to check for reference points against a nominal point cloud to address the root cause concern here . This requires the fixture pieces to be kept well and have a stable set of reference points on them. The nominal point cloud created with all pieces in correct location , then in your project template there is a special measurement series just for making the check. Kiosk has the code embedded if using the right names to perform the check , if points not found or position is wrong then it stops. Maybe this is worth a look into also? Imsorry i cantbring to mind all the exact details how to wet this up Link to comment Share on other sites More sharing options...
[Mi...] Posted October 23 Author Share Posted October 23 Please sign in to view this username. Thanks! What you're describing sounds familiar. I remember hearing a story once where they installed large automotive ScanBoxes with full body fixture cages into a brand new automotive facility. I don't remember the full story, but some number of months into their production I believe that they had issues completing their scans (I think the photogrammetry module began to fail?). They eventually discovered that the concrete was still settling and the the sides of the fixture pieces had shifted apart. I imagine that this is where a nominal point cloud of the fixture would greatly come in handy! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in